[LLVMdev] folding x * 0 = 0
Chris Lattner
clattner at apple.com
Wed Mar 3 10:35:16 PST 2010
On Mar 3, 2010, at 10:23 AM, Jochen Wilhelmy wrote:
>
>> You should check out the -enable-finite-only-fp-math and -enable-unsafe-fp-math options.
>
> Good hint, but
>
> llvm::UnsafeFPMath = true;
> llvm::FiniteOnlyFPMathOption = true;
>
> at the beginning of my code does not help.
> I found llvm::Reassociate::OptimizeExpression in
> llvm\lib\Transforms\Scalar\Reassociate.cpp
> which looks like it does X * 0 = 0 for int, but it does not get called
> for int,
> but it works for int.
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
However, this is far from being a concrete proposal.
-Chris
More information about the llvm-dev
mailing list