[llvm-dev] How to make the optimizer eliminate `fadd zeroinitializer`?

Henning Thielemann via llvm-dev llvm-dev at lists.llvm.org
Fri Aug 12 13:53:54 PDT 2016


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?


More information about the llvm-dev mailing list