Thanks Duncan, GVN/EarlyCSE worked as suggested. Any pointers on how to optimize out: %accumulate = fadd double %6, 0.000000e+00 Using the 3.1 release and the C++ API, I can't figure out how FPMathOperator, TargetOptions, nor IRBuilder::SetDefaultFPMathTag work. I also don't see any floating point math transformation passes. I did see IRBuilder::SetFastMathFlags, do I need to update to 3.2 and use this call? -- View this message in context: http://llvm.1065342.n5.nabble.com/Which-transform-passes-to-apply-tp52111p52211.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
Hi, If you want LLVM to do this you'll definitely have to enable unsafe-math flags since the transformation isn't strictly valid in IEEE floating point (the only web ref I can find quickly is http://dlang.org/float.html ). Duncan has been doing some work in implementing stuff in that area that I haven't kept up with. However, it might be worth considering tracking those empty operations you want to at your own DSL level, so that you've got more control over when these fp-unsafe optimizations are applied. (I was doing something with automatic differentiation -- which throws up lots of "multiply by 1"s , "add 0"s, etc --- about a year ago and found this was the way to go then, but as mentioned there's been some activity in the area I haven't been following.) Regards, Dave -----Original Message----- From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Josh Klontz Sent: 04 December 2012 05:24 To: llvmdev at cs.uiuc.edu Subject: Re: [LLVMdev] Which transform passes to apply? Thanks Duncan, GVN/EarlyCSE worked as suggested. Any pointers on how to optimize out: %accumulate = fadd double %6, 0.000000e+00 Using the 3.1 release and the C++ API, I can't figure out how FPMathOperator, TargetOptions, nor IRBuilder::SetDefaultFPMathTag work. I also don't see any floating point math transformation passes. I did see IRBuilder::SetFastMathFlags, do I need to update to 3.2 and use this call? -- View this message in context: http://llvm.1065342.n5.nabble.com/Which-transform-passes-to-apply-tp52111p52 211.html Sent from the LLVM - Dev mailing list archive at Nabble.com. _______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Hi Josh, On 04/12/12 06:23, Josh Klontz wrote:> Thanks Duncan, GVN/EarlyCSE worked as suggested. Any pointers on how to > optimize out: > %accumulate = fadd double %6, 0.000000e+00instcombine, however this transform is only correct if you are adding -0.0 so you won't get it without "fast math", and in 3.2 I think it will only be done by codegen (llc). The situation should be better in 3.3 since a bunch of fast-math support started going in to the IR level transforms.> > Using the 3.1 release and the C++ API, I can't figure out how > FPMathOperator, TargetOptions, nor IRBuilder::SetDefaultFPMathTag work. I > also don't see any floating point math transformation passes. I did see > IRBuilder::SetFastMathFlags, do I need to update to 3.2 and use this call?Please open a bug report since even in mainline this transform isn't done yet (as fast-math support at the IR level only just got going). Ciao, Duncan.> > > > > -- > View this message in context: http://llvm.1065342.n5.nabble.com/Which-transform-passes-to-apply-tp52111p52211.html > Sent from the LLVM - Dev mailing list archive at Nabble.com. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Duncan Sands wrote> Hi Josh, > > instcombine, however this transform is only correct if you are adding -0.0 > so you won't get it without "fast math", and in 3.2 I think it will only > be > done by codegen (llc). The situation should be better in 3.3 since a > bunch > of fast-math support started going in to the IR level transforms. > > ... > > Please open a bug report since even in mainline this transform isn't done > yet > (as fast-math support at the IR level only just got going). > > Ciao, Duncan.Filed under http://llvm.org/bugs/show_bug.cgi?id=14513. The -0.0 trick did the job in my case. Thanks again! -- View this message in context: http://llvm.1065342.n5.nabble.com/Which-transform-passes-to-apply-tp52111p52276.html Sent from the LLVM - Dev mailing list archive at Nabble.com.