summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2019-09-11 16:17:03 +0000
committerFlorian Hahn <flo@fhahn.com>2019-09-11 16:17:03 +0000
commit51de22c8ee6578bf7ae126913d4b24b5cf08ef7c (patch)
treea18864105ff53ee17b5350508cb36e9e22ce7bbf
parent0c1257f517e00f67c9fbb969671e85509a7f8ac9 (diff)
downloadbcm5719-llvm-51de22c8ee6578bf7ae126913d4b24b5cf08ef7c.tar.gz
bcm5719-llvm-51de22c8ee6578bf7ae126913d4b24b5cf08ef7c.zip
Revert [InstCombine] Use SimplifyFMulInst to simplify multiply in fma.
This introduces additional rounding error in some cases. See D67434. This reverts r371518 (git commit 18a1f0818b659cee13865b4fad2648d85984a4ed) llvm-svn: 371634
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp8
-rw-r--r--llvm/test/Transforms/InstCombine/fma.ll15
2 files changed, 13 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 1cef8d956b7..e96e45e802a 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -2258,11 +2258,9 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
return II;
}
- // Try to simplify the underlying FMul.
- if (Value *V = SimplifyFMulInst(II->getArgOperand(0), II->getArgOperand(1),
- II->getFastMathFlags(),
- SQ.getWithInstruction(II))) {
- auto *FAdd = BinaryOperator::CreateFAdd(V, II->getArgOperand(2));
+ // fma x, 1, z -> fadd x, z
+ if (match(Src1, m_FPOne())) {
+ auto *FAdd = BinaryOperator::CreateFAdd(Src0, II->getArgOperand(2));
FAdd->copyFastMathFlags(II);
return FAdd;
}
diff --git a/llvm/test/Transforms/InstCombine/fma.ll b/llvm/test/Transforms/InstCombine/fma.ll
index 42ed587bb3d..89fdc6bc9a5 100644
--- a/llvm/test/Transforms/InstCombine/fma.ll
+++ b/llvm/test/Transforms/InstCombine/fma.ll
@@ -372,7 +372,8 @@ define float @fmuladd_x_1_z_fast(float %x, float %z) {
define <2 x double> @fmuladd_a_0_b(<2 x double> %a, <2 x double> %b) {
; CHECK-LABEL: @fmuladd_a_0_b(
; CHECK-NEXT: entry:
-; CHECK-NEXT: ret <2 x double> [[B:%.*]]
+; CHECK-NEXT: [[RES:%.*]] = call nnan nsz <2 x double> @llvm.fmuladd.v2f64(<2 x double> [[A:%.*]], <2 x double> zeroinitializer, <2 x double> [[B:%.*]])
+; CHECK-NEXT: ret <2 x double> [[RES]]
;
entry:
%res = call nnan nsz <2 x double> @llvm.fmuladd.v2f64(<2 x double> %a, <2 x double> zeroinitializer, <2 x double> %b)
@@ -382,7 +383,8 @@ entry:
define <2 x double> @fmuladd_0_a_b(<2 x double> %a, <2 x double> %b) {
; CHECK-LABEL: @fmuladd_0_a_b(
; CHECK-NEXT: entry:
-; CHECK-NEXT: ret <2 x double> [[B:%.*]]
+; CHECK-NEXT: [[RES:%.*]] = call nnan nsz <2 x double> @llvm.fmuladd.v2f64(<2 x double> [[A:%.*]], <2 x double> zeroinitializer, <2 x double> [[B:%.*]])
+; CHECK-NEXT: ret <2 x double> [[RES]]
;
entry:
%res = call nnan nsz <2 x double> @llvm.fmuladd.v2f64(<2 x double> zeroinitializer, <2 x double> %a, <2 x double> %b)
@@ -405,7 +407,8 @@ declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double
define <2 x double> @fma_a_0_b(<2 x double> %a, <2 x double> %b) {
; CHECK-LABEL: @fma_a_0_b(
; CHECK-NEXT: entry:
-; CHECK-NEXT: ret <2 x double> [[B:%.*]]
+; CHECK-NEXT: [[RES:%.*]] = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> [[A:%.*]], <2 x double> zeroinitializer, <2 x double> [[B:%.*]])
+; CHECK-NEXT: ret <2 x double> [[RES]]
;
entry:
%res = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> %a, <2 x double> zeroinitializer, <2 x double> %b)
@@ -415,7 +418,8 @@ entry:
define <2 x double> @fma_0_a_b(<2 x double> %a, <2 x double> %b) {
; CHECK-LABEL: @fma_0_a_b(
; CHECK-NEXT: entry:
-; CHECK-NEXT: ret <2 x double> [[B:%.*]]
+; CHECK-NEXT: [[RES:%.*]] = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> [[A:%.*]], <2 x double> zeroinitializer, <2 x double> [[B:%.*]])
+; CHECK-NEXT: ret <2 x double> [[RES]]
;
entry:
%res = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> zeroinitializer, <2 x double> %a, <2 x double> %b)
@@ -436,7 +440,8 @@ entry:
define <2 x double> @fma_sqrt(<2 x double> %a, <2 x double> %b) {
; CHECK-LABEL: @fma_sqrt(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[RES:%.*]] = fadd fast <2 x double> [[A:%.*]], [[B:%.*]]
+; CHECK-NEXT: [[SQRT:%.*]] = call fast <2 x double> @llvm.sqrt.v2f64(<2 x double> [[A:%.*]])
+; CHECK-NEXT: [[RES:%.*]] = call fast <2 x double> @llvm.fma.v2f64(<2 x double> [[SQRT]], <2 x double> [[SQRT]], <2 x double> [[B:%.*]])
; CHECK-NEXT: ret <2 x double> [[RES]]
;
entry:
OpenPOWER on IntegriCloud