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

Chandler Carruth chandlerc at google.com
Sat Nov 8 13:41:28 PST 2014


On Sat, Nov 8, 2014 at 3:37 PM, Chandler Carruth <chandlerc at google.com>
wrote:

> On Sat, Nov 8, 2014 at 3:24 PM, Nick Lewycky <nicholas at mxc.ca> wrote:
>
>> David Majnemer wrote:
>>
>>> It's a correctness issue.
>>>
>>> In general one cannot know whether or not a divide instruction is safe
>>> to execute because isKnownNonZero returns true for poison.
>>>
>>> It is possible for the right hand side of the divide to always be poison
>>> in a valid program so long as the divide cannot ever be executed.
>>>
>>
>> Actually wait, how does that happen in practice? You need to have already
>> had an integer overflow or something to trigger poison, right?
>>
>
> I think poison may be misleading... I think this is true for undef as well
> unless you actually *transform* the divisor into some non-zero value so
> that undef is collapsed to 1 for example. Otherwise something else can
> collapse the undef to 0 invalidating the query. So divide is just not safe
> to speculate with an undef (or poison?) divisor, even though such a divisor
> satisfies "non-zero". Speculation of divide requires transforming the
> divisor.


And Hal just corrected me. =]

Poison is *also* relevant because we might only know that the divisor is
non-zero because of something like no-signed-wrap. Speculating the divide
transforms that control-dependent-hidden poison into UB.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141108/5fdae58e/attachment.html>


More information about the llvm-commits mailing list