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

Sanjoy Das sanjoy at playingwithpointers.com
Sat Nov 8 22:23:34 PST 2014


>>> 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?

Answering my own question (sorry for being thick the first time
around), this is a problem because it prevents the transform "(x + 2)
=> ((x + 1) + 1)".

However, how about splitting LLVM's instruction set into instructions
that propagate poison (like add, and lshr) and instructions that trap
on poison (like udiv, load, call and store)?  This allows us to
optimize "t < (t + 1)" to "true" (the < is UB if (t + 1) overflows),
allows usual reordering of exprs composed only of ops from the first
set (I think!) and allows us to conclude that, say, a load can never
be poison (since the store that stored poison is UB).

-- Sanjoy



More information about the llvm-commits mailing list