[llvm-commits] [llvm] r125267 - in /llvm/trunk: lib/Transforms/InstCombine/ test/Transforms/InstCombine/

Duncan Sands baldrick at free.fr
Thu Feb 10 01:08:03 PST 2011


Hi Chris,

> Enhance a bunch of transformations in instcombine to start generating
> exact/nsw/nuw shifts and have instcombine infer them when it can prove
> that the relevant properties are true for a given shift without them.

I didn't have time to read the patch, but as a general comment you need to be
careful when inferring exact/nw flags not to make use of undef.  The danger is
that an undef value causes the creation of a trap value.  For example, suppose
you have a lshr x, 1 and you try to prove that this is exact.  If you can show
that bit 0 is undefined (due to an undef value somewhere upstream in the
definition of x) then it would tempting but wrong to say that you are allowed
to assume that the bit is zero and flag the shift as being exact.  The danger
is that other optimizers decide to resolve the undef to a specific value which
causes bit 0 of x to become 1.  The optimizers will then see that the result of
the shift is a trap value and may do something nasty.

Ciao, Duncan.



More information about the llvm-commits mailing list