[PATCH] D65399: [InstCombine] canonicalize fneg before fmul/fdiv
    Cameron McInally via Phabricator via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Mon Jul 29 11:37:10 PDT 2019
    
    
  
cameron.mcinally added a comment.
> 2. The reassociation tests show that we were missing an optimization opportunity to fold away fneg-of-fneg. My reading of IEEE-754 says that all of these transforms are allowed (regardless of binop/unop fneg version) because:
> 
>   "For all other operations [besides copy/abs/negate/copysign], this standard does not specify the sign bit of a NaN result."
> 
>   In all of these transforms, we always have some other binop (fadd/fsub/fmul/fdiv), so we are free to flip the sign bit of a potential intermediate NaN operand. (If that interpretation is wrong, then we must already have a bug in the existing transforms?)
Oh, that's an interesting thought...
There's one edge-case I've been playing with that is worth mentioning. This transform could cause problems with denormals and Flush-To-Zero (FTZ). For example:
  -0.0 - D           -->  0.0
  negate(D)          -->  -D
AFAICT, FTZ breaks IEEE-754 compatibility already, so all bets are off at that point. My certainty-level is low about this though. I still need to work through it.
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65399/new/
https://reviews.llvm.org/D65399
    
    
More information about the llvm-commits
mailing list