[llvm] r262215 - [InstSimplify] Restore fsub 0.0, (fsub 0.0, X) ==> X optzn

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 29 04:18:26 PST 2016


Author: d0k
Date: Mon Feb 29 06:18:25 2016
New Revision: 262215

URL: http://llvm.org/viewvc/llvm-project?rev=262215&view=rev
Log:
[InstSimplify] Restore fsub 0.0, (fsub 0.0, X) ==> X optzn

I accidentally removed this in r262212 but there was no test coverage to
detect it.

Modified:
    llvm/trunk/lib/Analysis/InstructionSimplify.cpp
    llvm/trunk/test/Transforms/InstSimplify/fast-math.ll

Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=262215&r1=262214&r2=262215&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Mon Feb 29 06:18:25 2016
@@ -839,7 +839,7 @@ static Value *SimplifyFSubInst(Value *Op
     return X;
 
   // fsub 0.0, (fsub 0.0, X) ==> X if signed zeros are ignored.
-  if (FMF.noSignedZeros() && match(Op0, m_NegZero()) &&
+  if (FMF.noSignedZeros() && match(Op0, m_AnyZero()) &&
       match(Op1, m_FSub(m_AnyZero(), m_Value(X))))
     return X;
 

Modified: llvm/trunk/test/Transforms/InstSimplify/fast-math.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/fast-math.ll?rev=262215&r1=262214&r2=262215&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstSimplify/fast-math.ll (original)
+++ llvm/trunk/test/Transforms/InstSimplify/fast-math.ll Mon Feb 29 06:18:25 2016
@@ -91,6 +91,16 @@ define float @fsub_x_x(float %a) {
   ret float %ret
 }
 
+; fsub nsz 0.0, (fsub 0.0, X) ==> X
+; CHECK-LABEL: @fsub_0_0_x(
+define float @fsub_0_0_x(float %a) {
+  %t1 = fsub float 0.0, %a
+  %ret = fsub nsz float 0.0, %t1
+
+; CHECK: ret float %a
+  ret float %ret
+}
+
 ; fadd nsz X, 0 ==> X
 ; CHECK-LABEL: @nofold_fadd_x_0(
 define float @nofold_fadd_x_0(float %a) {




More information about the llvm-commits mailing list