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

Chris Lattner clattner at apple.com
Sat Jan 15 18:32:31 PST 2011


On Jan 13, 2011, at 3:22 PM, Duncan Sands wrote:

> Hi Chris,
> 
>>> The most common simplification missed by instsimplify in unoptimized bitcode
>>> is "X != 0 ->  X" when X is a boolean.  This occurs a lot because of the way
>>> llvm-gcc converts gcc's conditional expressions.  Add this, and a few other
>>> similar transforms for completeness.
>> 
>> Hi Duncan,
>> 
>> I don't really understand the motivation here: unoptimized code has lots of missed stuff, and instsimplify doesn't run for it, no?
> 
> by unoptimized I mean just before the first instcombine run.

Ah ok!

> Since instcombine first sees if SimplifyInstruction can mulch each instruction before working on
> it itself, catching missing simplifies on "unoptimized code" basically means
> finding stuff that could have been moved from instcombine to SimplifyInstruction
> but wasn't.  In the case in question I didn't remove stuff from instcombine but
> it is still a win: if instcombine sees an ICmp with i1 operands it turns it into
> a logical operation, for example
> 
>    case ICmpInst::ICMP_NE:                  // icmp eq i1 A, B -> A^B
>      return BinaryOperator::CreateXor(Op0, Op1);
> 
> By catching cases in SimplifyInstruction you avoid creating a new instruction,
> revisiting it etc.  This change reduced the number of instructions combined by
> 1% without any impact on final bitcode.

Makes a lot of sense.  I'm just hopeful that these simple cases can *move* from instcombine to instsimplify, since instcombine calls into instsimplify.

> 
>> In any case, this looks very familiar to code already in instcombine.  Can the instcombine code be zapped now?
> 
> Unfortunately not because the instcombine logic is too general, see above.

Ok.

> PS: My program that automatically finds simplifications finds all kinds of
> interesting ones [*] in optimized code, this unoptimized code one was just a
> warm up you might say :)
> 
> [*] Interesting = occurs a lot.  The program first harvests IR sequences from
> the test-suite, and orders them by how often they occur, before looking for
> simplifications in them.

Nice, I'm looking forward to hearing more about your tool!

-Chris



More information about the llvm-commits mailing list