diff options
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index f3ffcf2e4b..462824d1f8 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -1546,8 +1546,9 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) { case Instruction::Add: // Replace ((add A, B) != C) with (A != C-B) if B & C are constants. if (ConstantInt *BOp1C = dyn_cast<ConstantInt>(BO->getOperand(1))) { - return new SetCondInst(I.getOpcode(), BO->getOperand(0), - ConstantExpr::getSub(CI, BOp1C)); + if (BO->hasOneUse()) + return new SetCondInst(I.getOpcode(), BO->getOperand(0), + ConstantExpr::getSub(CI, BOp1C)); } else if (CI->isNullValue()) { // Replace ((add A, B) != 0) with (A != -B) if A or B is // efficiently invertible, or if the add has just this one use. |