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

Chandler Carruth chandlerc at google.com
Wed Nov 5 19:09:22 PST 2014


On Wed, Nov 5, 2014 at 9:00 PM, Hal Finkel <hfinkel at anl.gov> wrote:

> > > For instructions which trap, we need a stronger predicate than
> > > 'isKnownNonZero': we need a hypothetical 'isKnownNeverToBeUndef'.
> >
> > Wait, why? If the program produced undefined behavior, then it can
> > trap in response to that. No?
> >
> >
> >
> > Let's consider a loop which will never iterate even once but contains
> > a divide instruction whose operands are invariant of the loop.
> >
> >
> > The behavior of this program is well defined because the divide
> > cannot execute. Hoisting the divide might turn a well-formed program
> > into an ill-formed program if it turns out the dividend is poison.
> >
>
> Fair enough; I see your point.


This is another reason to go away from poison and back to undef.

With undef, speculation is clearly only allowed if you replace the undef
denominator with some non-zero constant (say, one).

But then again, we can also just replace X/undef first, and then it being
speculated isn't relevant at all, so maybe none of that matters. =]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141105/2f9f55c6/attachment.html>


More information about the llvm-commits mailing list