Index: lib/Transforms/InstCombine/InstCombineMulDivRem.cpp =================================================================== --- lib/Transforms/InstCombine/InstCombineMulDivRem.cpp +++ lib/Transforms/InstCombine/InstCombineMulDivRem.cpp @@ -1424,7 +1424,7 @@ return nullptr; } - if (AllowReassociate) { + if (I.hasAllowReassoc() && I.hasAllowReciprocal()) { Value *X, *Y; if (match(Op0, m_OneUse(m_FDiv(m_Value(X), m_Value(Y)))) && (!isa(Y) || !isa(Op1))) { Index: test/Transforms/InstCombine/fdiv.ll =================================================================== --- test/Transforms/InstCombine/fdiv.ll +++ test/Transforms/InstCombine/fdiv.ll @@ -119,12 +119,12 @@ define float @div_with_div_numerator(float %x, float %y, float %z) { ; CHECK-LABEL: @div_with_div_numerator( -; CHECK-NEXT: [[TMP1:%.*]] = fmul ninf float [[Y:%.*]], [[Z:%.*]] -; CHECK-NEXT: [[DIV2:%.*]] = fdiv fast float [[X:%.*]], [[TMP1]] +; CHECK-NEXT: [[TMP1:%.*]] = fmul float [[Y:%.*]], [[Z:%.*]] +; CHECK-NEXT: [[DIV2:%.*]] = fdiv reassoc arcp float [[X:%.*]], [[TMP1]] ; CHECK-NEXT: ret float [[DIV2]] ; %div1 = fdiv ninf float %x, %y - %div2 = fdiv fast float %div1, %z + %div2 = fdiv arcp reassoc float %div1, %z ret float %div2 } @@ -132,12 +132,12 @@ define <2 x float> @div_with_div_denominator(<2 x float> %x, <2 x float> %y, <2 x float> %z) { ; CHECK-LABEL: @div_with_div_denominator( -; CHECK-NEXT: [[TMP1:%.*]] = fmul nnan <2 x float> [[Y:%.*]], [[Z:%.*]] -; CHECK-NEXT: [[DIV2:%.*]] = fdiv fast <2 x float> [[TMP1]], [[X:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = fmul <2 x float> [[Y:%.*]], [[Z:%.*]] +; CHECK-NEXT: [[DIV2:%.*]] = fdiv reassoc arcp <2 x float> [[TMP1]], [[X:%.*]] ; CHECK-NEXT: ret <2 x float> [[DIV2]] ; %div1 = fdiv nnan <2 x float> %x, %y - %div2 = fdiv fast <2 x float> %z, %div1 + %div2 = fdiv arcp reassoc <2 x float> %z, %div1 ret <2 x float> %div2 }