Henning Thielemann via llvm-dev
2016-Aug-12 20:53 UTC
[llvm-dev] How to make the optimizer eliminate `fadd zeroinitializer`?
I have the module: target triple = "x86_64-pc-linux-gnu" define void @round(<8 x float>*) { _L1: %1 = load <8 x float>, <8 x float>* %0 %2 = fadd <8 x float> %1, zeroinitializer store <8 x float> %2, <8 x float>* %0 ret void } Optimizing it with -O3 does not remove the add with zero. Also options like -enable-no-infs-fp-math -enable-no-nans-fp-math -enable-unsafe-fp-math -enable-fp-mad do not eliminate it. I understand that floating point arithmetic exposes strange behavior that disables many obvious simplifications. I cannot see the corner case here. If there exist one, how can I convince 'opt' to remove the add with zero?
via llvm-dev
2016-Aug-12 20:59 UTC
[llvm-dev] How to make the optimizer eliminate `fadd zeroinitializer`?
Adding ‘fast’ to the fadd should simplify it. Note that adding zero is not a no-op in floating point arithmetic; adding negative zero is. —escha> On Aug 12, 2016, at 1:53 PM, Henning Thielemann via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > > I have the module: > > target triple = "x86_64-pc-linux-gnu" > > define void @round(<8 x float>*) { > _L1: > %1 = load <8 x float>, <8 x float>* %0 > %2 = fadd <8 x float> %1, zeroinitializer > store <8 x float> %2, <8 x float>* %0 > ret void > } > > > Optimizing it with -O3 does not remove the add with zero. Also options like -enable-no-infs-fp-math -enable-no-nans-fp-math -enable-unsafe-fp-math -enable-fp-mad do not eliminate it. I understand that floating point arithmetic exposes strange behavior that disables many obvious simplifications. I cannot see the corner case here. If there exist one, how can I convince 'opt' to remove the add with zero? > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Henning Thielemann via llvm-dev
2016-Aug-12 21:47 UTC
[llvm-dev] How to make the optimizer eliminate `fadd zeroinitializer`?
On Fri, 12 Aug 2016, escha at apple.com wrote:> Adding ‘fast’ to the fadd should simplify it. Note that adding zero is > not a no-op in floating point arithmetic; adding negative zero is.Ah, that is adding zero to negative zero is the corner case! It seems that opt -enable-no-infs-fp-math adds ninf globally opt -enable-no-nans-fp-math adds nnan globally but I do not see a counterpart for the flags 'nsz', 'arcp' and 'fast'. :-(
Seemingly Similar Threads
- Trouble when suppressing a portion of fast-math-transformations
- RFC: Consider changing the semantics of 'fast' flag implying all fast-math-flags
- RFC: Consider changing the semantics of 'fast' flag implying all fast-math-flags
- [LLVMdev] use AVX automatically if present
- Trouble when suppressing a portion of fast-math-transformations