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 | 6e07936ed2d197d2ed40d575c6e93b4de475c799 (patch) | |
tree | 0b13f32eebec339cb3770b0d76bcac0db22862ef /llvm/lib/Transforms/Scalar/InstructionCombining.cpp | |
parent | 0da061fa1ee9885e9e03ce51163e5f278c66d7ce (diff) | |
download | bcm5719-llvm-6e07936ed2d197d2ed40d575c6e93b4de475c799.tar.gz bcm5719-llvm-6e07936ed2d197d2ed40d575c6e93b4de475c799.zip |
Implement InstCombine/add.ll:test21
llvm-svn: 14443
Diffstat (limited to 'llvm/lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index 826e2c765e7..28e2eec0b41 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/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)) |