[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] TCG sar UB (fwd)
From: |
Richard Henderson |
Subject: |
Re: [Qemu-devel] TCG sar UB (fwd) |
Date: |
Wed, 07 Sep 2011 10:49:38 +0530 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.20) Gecko/20110817 Fedora/3.1.12-1.fc14 Thunderbird/3.1.12 |
On 09/06/2011 08:50 PM, malc wrote:
> Correct me if i'm wrong, previously the code worked like this:
>
> mov tmp, 0
> sub tmp, 1
> sar r, r, tmp
>
> Still UB as far as TCG is concerned but since no immediates are involved
> things worked, now, with constant folding, we are asked to sar by -1
> directly.
You are exactly correct.
That's why I thought my patch to re-arrange the order of operations
and only perform the subtraction inside the %cl != 0 test was a good
idea. No point in performing the shift if we're not going to use the
result.
> I did that when first hit this problem, but decided not to push it.
I think pushing it is a good idea. Just because the result is not
defined, according to tcg/README, is no reason to SIGILL.
r~