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

via llvm-dev llvm-dev at lists.llvm.org
Fri Aug 12 13:59:26 PDT 2016


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



More information about the llvm-dev mailing list