Index: lib/Transforms/InstCombine/InstCombineAddSub.cpp =================================================================== --- lib/Transforms/InstCombine/InstCombineAddSub.cpp +++ lib/Transforms/InstCombine/InstCombineAddSub.cpp @@ -511,7 +511,7 @@ } Value *FAddCombine::simplify(Instruction *I) { - assert(I->isFast() && "Expected 'fast' instruction"); + assert(I->hasAllowReassoc() && "Expected 'reassoc' instruction"); // Currently we are not able to handle vector type. if (I->getType()->isVectorTy()) @@ -1378,7 +1378,7 @@ if (Value *V = SimplifySelectsFeedingBinaryOp(I, LHS, RHS)) return replaceInstUsesWith(I, V); - if (I.isFast()) { + if (I.hasAllowReassoc()) { if (Value *V = FAddCombine(Builder).simplify(&I)) return replaceInstUsesWith(I, V); } @@ -1747,7 +1747,7 @@ if (Value *V = SimplifySelectsFeedingBinaryOp(I, Op0, Op1)) return replaceInstUsesWith(I, V); - if (I.isFast()) { + if (I.hasAllowReassoc()) { if (Value *V = FAddCombine(Builder).simplify(&I)) return replaceInstUsesWith(I, V); } Index: test/Transforms/Reassociate/fast-MissedTree.ll =================================================================== --- test/Transforms/Reassociate/fast-MissedTree.ll +++ test/Transforms/Reassociate/fast-MissedTree.ll @@ -15,9 +15,7 @@ define float @test1_reassoc(float %A, float %B) { ; CHECK-LABEL: @test1_reassoc( -; CHECK-NEXT: [[W:%.*]] = fadd reassoc float %B, -5.000000e+00 -; CHECK-NEXT: [[Y:%.*]] = fadd reassoc float %A, 5.000000e+00 -; CHECK-NEXT: [[Z:%.*]] = fadd reassoc float [[Y]], [[W]] +; CHECK-NEXT: [[Z:%.*]] = fadd reassoc float %A, %B ; CHECK-NEXT: ret float [[Z]] ; %W = fadd reassoc float %B, -5.0 Index: test/Transforms/Reassociate/fast-SubReassociate.ll =================================================================== --- test/Transforms/Reassociate/fast-SubReassociate.ll +++ test/Transforms/Reassociate/fast-SubReassociate.ll @@ -32,10 +32,7 @@ define float @test2_reassoc(float %A, float %B) { ; CHECK-LABEL: @test2_reassoc( -; CHECK-NEXT: [[W:%.*]] = fadd reassoc float %B, 5.000000e+00 -; CHECK-NEXT: [[X:%.*]] = fadd reassoc float %A, -7.000000e+00 -; CHECK-NEXT: [[Y:%.*]] = fsub reassoc float [[X]], [[W]] -; CHECK-NEXT: [[Z:%.*]] = fadd reassoc float [[Y]], 1.200000e+01 +; CHECK-NEXT: [[Z:%.*]] = fsub reassoc float %A, %B ; CHECK-NEXT: ret float [[Z]] ; %W = fadd reassoc float %B, 5.000000e+00 Index: test/Transforms/Reassociate/fast-basictest.ll =================================================================== --- test/Transforms/Reassociate/fast-basictest.ll +++ test/Transforms/Reassociate/fast-basictest.ll @@ -14,9 +14,8 @@ define float @test1_reassoc(float %arg) { ; CHECK-LABEL: @test1_reassoc( -; CHECK-NEXT: [[T1:%.*]] = fsub reassoc float -1.200000e+01, [[ARG:%.*]] -; CHECK-NEXT: [[T2:%.*]] = fadd reassoc float [[T1]], 1.200000e+01 -; CHECK-NEXT: ret float [[T2]] +; CHECK-NEXT: [[ARG_NEG:%.*]] = fsub reassoc float 0.000000e+00, [[ARG:%.*]] +; CHECK-NEXT: ret float [[ARG_NEG]] ; %t1 = fsub reassoc float -1.200000e+01, %arg %t2 = fadd reassoc float %t1, 1.200000e+01 @@ -212,9 +211,8 @@ define float @test9_reassoc(float %X) { ; CHECK-LABEL: @test9_reassoc( -; CHECK-NEXT: [[Y:%.*]] = fmul reassoc float [[X:%.*]], 4.700000e+01 -; CHECK-NEXT: [[Z:%.*]] = fadd reassoc float [[Y]], [[Y]] -; CHECK-NEXT: ret float [[Z]] +; CHECK-NEXT: [[FACTOR:%.*]] = fmul reassoc float [[X:%.*]], 9.400000e+01 +; CHECK-NEXT: ret float [[FACTOR]] ; %Y = fmul reassoc float %X, 4.700000e+01 %Z = fadd reassoc float %Y, %Y @@ -233,9 +231,8 @@ define float @test10_reassoc(float %X) { ; CHECK-LABEL: @test10_reassoc( -; CHECK-NEXT: [[Y:%.*]] = fadd reassoc float [[X:%.*]], [[X]] -; CHECK-NEXT: [[Z:%.*]] = fadd reassoc float [[Y]], [[X]] -; CHECK-NEXT: ret float [[Z]] +; CHECK-NEXT: [[FACTOR:%.*]] = fmul reassoc float [[X:%.*]], 3.000000e+00 +; CHECK-NEXT: ret float [[FACTOR]] ; %Y = fadd reassoc float %X ,%X %Z = fadd reassoc float %Y, %X @@ -255,10 +252,8 @@ define float @test11_reassoc(float %W) { ; CHECK-LABEL: @test11_reassoc( -; CHECK-NEXT: [[X:%.*]] = fmul reassoc float [[W:%.*]], 1.270000e+02 -; CHECK-NEXT: [[Y:%.*]] = fadd reassoc float [[X]], [[X]] -; CHECK-NEXT: [[Z:%.*]] = fadd reassoc float [[X]], [[Y]] -; CHECK-NEXT: ret float [[Z]] +; CHECK-NEXT: [[FACTOR:%.*]] = fmul reassoc float [[W:%.*]], 3.810000e+02 +; CHECK-NEXT: ret float [[FACTOR]] ; %X = fmul reassoc float %W, 127.0 %Y = fadd reassoc float %X ,%X @@ -282,11 +277,8 @@ define float @test12_reassoc(float %X) { ; CHECK-LABEL: @test12_reassoc( -; CHECK-NEXT: [[A:%.*]] = fsub reassoc float 1.000000e+00, [[X:%.*]] -; CHECK-NEXT: [[B:%.*]] = fsub reassoc float 2.000000e+00, [[X]] -; CHECK-NEXT: [[C:%.*]] = fsub reassoc float 3.000000e+00, [[X]] -; CHECK-NEXT: [[Y:%.*]] = fadd reassoc float [[A]], [[B]] -; CHECK-NEXT: [[Z:%.*]] = fadd reassoc float [[C]], [[Y]] +; CHECK-NEXT: [[FACTOR:%.*]] = fmul reassoc float [[X:%.*]], 3.000000e+00 +; CHECK-NEXT: [[Z:%.*]] = fsub reassoc float 6.000000e+00, [[FACTOR]] ; CHECK-NEXT: ret float [[Z]] ; %A = fsub reassoc float 1.000000e+00, %X @@ -339,10 +331,9 @@ define float @test14_reassoc(float %X1, float %X2) { ; CHECK-LABEL: @test14_reassoc( -; CHECK-NEXT: [[B:%.*]] = fmul reassoc float [[X1:%.*]], 4.700000e+01 -; CHECK-NEXT: [[C:%.*]] = fmul reassoc float [[X2:%.*]], 4.700000e+01 -; CHECK-NEXT: [[D1:%.*]] = fsub reassoc float [[B]], [[C]] -; CHECK-NEXT: ret float [[D1]] +; CHECK-NEXT: [[TMP1:%.*]] = fsub reassoc float [[X1:%.*]], [[X2:%.*]] +; CHECK-NEXT: [[TMP2:%.*]] = fmul reassoc float [[TMP1]], 4.700000e+01 +; CHECK-NEXT: ret float [[TMP2]] ; %B = fmul reassoc float %X1, 47. ; X1*47 %C = fmul reassoc float %X2, -47. ; X2*-47 @@ -385,11 +376,8 @@ define float @test16_reassoc(float %b, float %a) { ; CHECK-LABEL: @test16_reassoc( -; CHECK-NEXT: [[TMP1:%.*]] = fadd reassoc float [[A:%.*]], 1.234000e+03 -; CHECK-NEXT: [[TMP2:%.*]] = fadd reassoc float [[TMP1]], [[B:%.*]] -; CHECK-NEXT: [[TMP3:%.*]] = fsub reassoc float 0.000000e+00, [[A]] -; CHECK-NEXT: [[TMP4:%.*]] = fadd reassoc float [[TMP3]], [[TMP2]] -; CHECK-NEXT: ret float [[TMP4]] +; CHECK-NEXT: [[TMP1:%.*]] = fadd reassoc float [[B:%.*]], 1.234000e+03 +; CHECK-NEXT: ret float [[TMP1]] ; %1 = fadd reassoc float %a, 1234.0 %2 = fadd reassoc float %b, %1