[llvm] r221318 - Analysis: Make isSafeToSpeculativelyExecute fire less for divides

Sanjoy Das sanjoy at playingwithpointers.com
Sat Nov 8 21:56:56 PST 2014


On Sat, Nov 8, 2014 at 9:49 PM, Chandler Carruth <chandlerc at google.com> wrote:
>
> On Sat, Nov 8, 2014 at 11:43 PM, David Majnemer <david.majnemer at gmail.com>
> wrote:
>>
>>
>> I'm pretty sure the LangRef has a bug here.  It cannot literally mean
>> undefined behavior or the program hits UB once an add nsw that produces
>> poison is used as the operand to another add.

Why is this a problem?

> Yes this is the known bug in the poison spec. None have wanted to fix it
> because it seems likely better to remove the need for poison by specifying
> (and implementing if necessary) the relevant optimization opportunities in
> terms of undef, which is a much simpler construct.

Do you mean an "add nsw" that overflows is undef?  In that case, we
won't be able to optimize "t < (t + 1)" to "true" (+ is add nsw and <
is icmp slt) -- there is no i32 undef (which t+1 will be if t is
i32_signed_max) that is > i32_signed_max.  I'm not sure this is a real
optimization problem, though.

-- Sanjoy



More information about the llvm-commits mailing list