From eb5d0468903e0f5cdd96f5a9cac41cc4e1376696 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Thu, 1 Mar 2018 23:39:24 +0000 Subject: [PATCH] revert r326502: [InstCombine] allow fmul fold with less than 'fast' I forgot that I added tests for 'reassoc' to -reassociate, but suprisingly that file calls -instcombine too, so it is affected. I'll update that file and try again. llvm-svn: 326510 --- .../InstCombine/InstCombineMulDivRem.cpp | 2 +- llvm/test/Transforms/InstCombine/fmul.ll | 24 +++++++++---------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp index 1529911c5a9c..2959c09cbb5c 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp @@ -676,7 +676,7 @@ Instruction *InstCombiner::visitFMul(BinaryOperator &I) { // latency of the instruction Y is amortized by the expression of X*X, // and therefore Y is in a "less critical" position compared to what it // was before the transformation. - if (I.hasAllowReassoc()) { + if (I.isFast()) { if (match(Op0, m_OneUse(m_c_FMul(m_Specific(Op1), m_Value(Y)))) && Op1 != Y) { Value *XX = Builder.CreateFMulFMF(Op1, Op1, &I); diff --git a/llvm/test/Transforms/InstCombine/fmul.ll b/llvm/test/Transforms/InstCombine/fmul.ll index 6c0642ba9dc7..4c364f97d25d 100644 --- a/llvm/test/Transforms/InstCombine/fmul.ll +++ b/llvm/test/Transforms/InstCombine/fmul.ll @@ -228,17 +228,15 @@ define float @fabs_x_fabs(float %x, float %y) { } ; (X*Y) * X => (X*X) * Y -; The transform only requires 'reassoc', but test other FMF in -; the commuted variants to make sure FMF propagates as expected. define float @reassoc_common_operand1(float %x, float %y) { ; CHECK-LABEL: @reassoc_common_operand1( -; CHECK-NEXT: [[TMP1:%.*]] = fmul reassoc float [[X:%.*]], [[X]] -; CHECK-NEXT: [[MUL2:%.*]] = fmul reassoc float [[TMP1]], [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[X:%.*]], [[X]] +; CHECK-NEXT: [[MUL2:%.*]] = fmul fast float [[TMP1]], [[Y:%.*]] ; CHECK-NEXT: ret float [[MUL2]] ; %mul1 = fmul float %x, %y - %mul2 = fmul reassoc float %mul1, %x + %mul2 = fmul fast float %mul1, %x ret float %mul2 } @@ -260,13 +258,13 @@ define float @reassoc_common_operand2(float %x, float %y) { define float @reassoc_common_operand3(float %x1, float %y) { ; CHECK-LABEL: @reassoc_common_operand3( ; CHECK-NEXT: [[X:%.*]] = fdiv float [[X1:%.*]], 3.000000e+00 -; CHECK-NEXT: [[TMP1:%.*]] = fmul reassoc nnan float [[X]], [[X]] -; CHECK-NEXT: [[MUL2:%.*]] = fmul reassoc nnan float [[TMP1]], [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[X]], [[X]] +; CHECK-NEXT: [[MUL2:%.*]] = fmul fast float [[TMP1]], [[Y:%.*]] ; CHECK-NEXT: ret float [[MUL2]] ; %x = fdiv float %x1, 3.0 ; thwart complexity-based canonicalization %mul1 = fmul float %x, %y - %mul2 = fmul reassoc nnan float %x, %mul1 + %mul2 = fmul fast float %x, %mul1 ret float %mul2 } @@ -275,13 +273,13 @@ define float @reassoc_common_operand3(float %x1, float %y) { define float @reassoc_common_operand4(float %x1, float %y) { ; CHECK-LABEL: @reassoc_common_operand4( ; CHECK-NEXT: [[X:%.*]] = fdiv float [[X1:%.*]], 3.000000e+00 -; CHECK-NEXT: [[TMP1:%.*]] = fmul reassoc ninf float [[X]], [[X]] -; CHECK-NEXT: [[MUL2:%.*]] = fmul reassoc ninf float [[TMP1]], [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[X]], [[X]] +; CHECK-NEXT: [[MUL2:%.*]] = fmul fast float [[TMP1]], [[Y:%.*]] ; CHECK-NEXT: ret float [[MUL2]] ; %x = fdiv float %x1, 3.0 ; thwart complexity-based canonicalization %mul1 = fmul float %y, %x - %mul2 = fmul reassoc ninf float %x, %mul1 + %mul2 = fmul fast float %x, %mul1 ret float %mul2 } @@ -290,12 +288,12 @@ define float @reassoc_common_operand4(float %x1, float %y) { define float @reassoc_common_operand_multi_use(float %x, float %y) { ; CHECK-LABEL: @reassoc_common_operand_multi_use( ; CHECK-NEXT: [[MUL1:%.*]] = fmul float [[X:%.*]], [[Y:%.*]] -; CHECK-NEXT: [[MUL2:%.*]] = fmul reassoc float [[MUL1]], [[X]] +; CHECK-NEXT: [[MUL2:%.*]] = fmul fast float [[MUL1]], [[X]] ; CHECK-NEXT: call void @use_f32(float [[MUL1]]) ; CHECK-NEXT: ret float [[MUL2]] ; %mul1 = fmul float %x, %y - %mul2 = fmul reassoc float %mul1, %x + %mul2 = fmul fast float %mul1, %x call void @use_f32(float %mul1) ret float %mul2 }