diff options
author | Chris Lattner <sabre@nondot.org> | 2004-06-27 22:51:36 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-06-27 22:51:36 +0000 |
commit | 15d58b638a1e42f4cd9da13848061b3d267ca2c5 (patch) | |
tree | 92ad35ecdc0de02602ab40a18fe8ff77afdbff19 /lib/Transforms | |
parent | 8d5e05bb710b509d8b2e2843aa7526f3172e86c6 (diff) |
Implement InstCombine/add.ll:test21
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14443 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 826e2c765e..28e2eec0b4 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -1520,10 +1520,15 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) { if (BinaryOperator *BO = dyn_cast<BinaryOperator>(Op0)) { switch (BO->getOpcode()) { case Instruction::Add: - if (CI->isNullValue()) { + // 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)); + } 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. Value *BOp0 = BO->getOperand(0), *BOp1 = BO->getOperand(1); + if (Value *NegVal = dyn_castNegVal(BOp1)) return new SetCondInst(I.getOpcode(), BOp0, NegVal); else if (Value *NegVal = dyn_castNegVal(BOp0)) |