[LLVMdev] folding x * 0 = 0

Jochen Wilhelmy j.wilhelmy at arcor.de
Wed Mar 3 11:07:11 PST 2010


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

-Jochen




More information about the llvm-dev mailing list