diff --git a/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp index f35311bb966..99350c538da 100644 --- a/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp +++ b/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp @@ -581,7 +581,7 @@ Instruction *InstCombiner::visitFMul(BinaryOperator &I) { // X * C, C/X, X/C, where C is a constant. // (MDC +/- C1) * C => (MDC * C) +/- (C1 * C) Instruction *FAddSub = dyn_cast(Op0); - if (FAddSub && + if (FAddSub && FAddSub->hasOneUse() && (FAddSub->getOpcode() == Instruction::FAdd || FAddSub->getOpcode() == Instruction::FSub)) { Value *Opnd0 = FAddSub->getOperand(0); diff --git a/test/Transforms/InstCombine/fmul.ll b/test/Transforms/InstCombine/fmul.ll index 423d5e61cdf..18752b1bec9 100644 --- a/test/Transforms/InstCombine/fmul.ll +++ b/test/Transforms/InstCombine/fmul.ll @@ -495,14 +495,11 @@ define float @fmul_fadd_fmul_distribute(float %x) { ret float %t3 } -; FIXME: More instructions than we started with. - define float @fmul_fadd_distribute_extra_use(float %x) { ; CHECK-LABEL: @fmul_fadd_distribute_extra_use( ; CHECK-NEXT: [[T1:%.*]] = fmul float [[X:%.*]], 6.000000e+00 ; CHECK-NEXT: [[T2:%.*]] = fadd float [[T1]], 2.000000e+00 -; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[X]], 3.000000e+01 -; CHECK-NEXT: [[T3:%.*]] = fadd fast float [[TMP1]], 1.000000e+01 +; CHECK-NEXT: [[T3:%.*]] = fmul fast float [[T2]], 5.000000e+00 ; CHECK-NEXT: call void @use_f32(float [[T2]]) ; CHECK-NEXT: ret float [[T3]] ; @@ -559,14 +556,11 @@ define float @fmul_fsub_fmul_distribute(float %x) { ret float %t3 } -; FIXME: More instructions than we started with. - define float @fmul_fsub_fmul_distribute_extra_use(float %x) { ; CHECK-LABEL: @fmul_fsub_fmul_distribute_extra_use( ; CHECK-NEXT: [[T1:%.*]] = fmul float [[X:%.*]], 6.000000e+00 ; CHECK-NEXT: [[T2:%.*]] = fsub float 2.000000e+00, [[T1]] -; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[X]], 3.000000e+01 -; CHECK-NEXT: [[T3:%.*]] = fsub fast float 1.000000e+01, [[TMP1]] +; CHECK-NEXT: [[T3:%.*]] = fmul fast float [[T2]], 5.000000e+00 ; CHECK-NEXT: call void @use_f32(float [[T2]]) ; CHECK-NEXT: ret float [[T3]] ; @@ -591,14 +585,11 @@ define float @fmul_fsub_fmul_distribute2(float %x) { ret float %t3 } -; FIXME: More instructions than we started with. - define float @fmul_fsub_fmul_distribute2_extra_use(float %x) { ; CHECK-LABEL: @fmul_fsub_fmul_distribute2_extra_use( ; CHECK-NEXT: [[T1:%.*]] = fmul float [[X:%.*]], 6.000000e+00 ; CHECK-NEXT: [[T2:%.*]] = fsub float 2.000000e+00, [[T1]] -; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[X]], 3.000000e+01 -; CHECK-NEXT: [[T3:%.*]] = fsub fast float 1.000000e+01, [[TMP1]] +; CHECK-NEXT: [[T3:%.*]] = fmul fast float [[T2]], 5.000000e+00 ; CHECK-NEXT: call void @use_f32(float [[T2]]) ; CHECK-NEXT: ret float [[T3]] ;