[llvm-commits] [llvm] r123754 - in /llvm/trunk: lib/Analysis/InstructionSimplify.cpp test/Transforms/InstSimplify/2010-12-20-Distribute.ll

Chris Lattner clattner at apple.com
Sun Jan 23 18:37:16 PST 2011


On Jan 18, 2011, at 11:36 PM, Duncan Sands wrote:

> Hi Chris,
> 
>>> Simplify (X<<1)-X into X.  According to my auto-simplier this is the most common missed
>>> simplification in fully optimized code.  It occurs sporadically in the testsuite, and
>>> many times in 403.gcc: the final bitcode has 131 fewer subtractions after this change.
>>> The reason that the multiplies are not eliminated is the same reason that instcombine
>>> did not catch this: they are used by other instructions (instcombine catches this with
>>> a more general transform which in general is only profitable if the operands have only
>>> one use).
>> 
>> Cool.  Please add a comment to the code about why the explicit multiply is checked.  I still don't understand what the multiply having multiple uses has to do with it.  It seems that you can completely drop "match(Op0, m_Mul(m_Specific(Op1), m_ConstantInt<2>())) ||" since it should always be canonicalized to a shift.
> 
> the explicit multiply is because when compiling at -O2 this code is called by
> Early-CSE before multiplies have been canonicalized (the first Early-CSE pass
> occurs before instcombine has run).

Ah, makes perfect sense then, thanks Duncan!

-Chris



More information about the llvm-commits mailing list