[PATCH] D27932: InstSimplify: Eliminate fabs on known positive
    Steve Canon via Phabricator via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Wed Jan  4 09:28:30 PST 2017
    
    
  
scanon added inline comments.
================
Comment at: lib/Analysis/ValueTracking.cpp:2614
     if (I->getOperand(0) == I->getOperand(1))
       return true;
     LLVM_FALLTHROUGH;
----------------
arsenm wrote:
> efriedma wrote:
> > IIRC, A*A->A if A is a NaN, so fabs(x*x) isn't equivalent to x*x.
> I think the sign of a NaN is OK to ignore
It's OK [in the IEEE 754 sense] to ignore the sign of NaN with all operations *except* abs, copysign, copy, and negate.  So `fabs(x)` is not equivalent to `x` if `x` is NaN, but `fabs(x*x) -> x*x` is OK if `x` might be NaN, because the sign of `x*x` has no meaning if `x` is NaN.
https://reviews.llvm.org/D27932
    
    
More information about the llvm-commits
mailing list