[LLVMdev] folding x * 0 = 0

Chris Lattner clattner at apple.com
Wed Mar 3 11:13:50 PST 2010


On Mar 3, 2010, at 11:07 AM, Jochen Wilhelmy wrote:

> 
>> These flags only affect the code generator. If you want to add this optimization to your copy of llvm, you can do so by adding it to the instcombine pass.  We'd need IR enhancements to do this sort of thing for real in the mid-level optimizer, some thoughts are here:
>> http://nondot.org/sabre/LLVMNotes/FloatingPointChanges.txt
>>   
> 
> Thanks, now it works. I inserted
> 
>      if (Op1F->isNullValue())
>        return ReplaceInstUsesWith(I, Op1C);  // X * 0  == 0
> 
> into llvm::InstCombiner::visitFMul
> 
> Why not at first create a compile time option for this so that the
> code is already available for special purposes?

I'm not sure how that would work, but it most likely wouldn't fit with the design of llvm.  If this is important, I'd rather fix the representational issue.

-Chris



More information about the llvm-dev mailing list