summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Analysis/InstructionSimplify.cpp2
-rw-r--r--llvm/test/Transforms/InstSimplify/fast-math.ll10
2 files changed, 11 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index aca19de4f17..bb0a275f947 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -839,7 +839,7 @@ static Value *SimplifyFSubInst(Value *Op0, Value *Op1, FastMathFlags FMF,
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;
diff --git a/llvm/test/Transforms/InstSimplify/fast-math.ll b/llvm/test/Transforms/InstSimplify/fast-math.ll
index 90532fa5db8..c499af33f52 100644
--- a/llvm/test/Transforms/InstSimplify/fast-math.ll
+++ b/llvm/test/Transforms/InstSimplify/fast-math.ll
@@ -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) {
OpenPOWER on IntegriCloud