Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.474 -> 1.475 --- Log message: Implement InstCombine/cast.ll:test29 --- Diffs of the changes: (+40 -0) InstructionCombining.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 40 insertions(+) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.474 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.475 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.474 Thu May 4 12:33:35 2006 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Fri May 5 01:39:07 2006 @@ -2640,6 +2640,19 @@ } } + // fold (and (cast A), (cast B)) -> (cast (and A, B)) + if (CastInst *Op0C = dyn_cast<CastInst>(Op0)) { + if (CastInst *Op1C = dyn_cast<CastInst>(Op1)) + if (Op0C->getOperand(0)->getType() == Op1C->getOperand(0)->getType() && + Op0C->getOperand(0)->getType()->isIntegral()) { + Instruction *NewOp = BinaryOperator::createAnd(Op0C->getOperand(0), + Op1C->getOperand(0), + I.getName()); + InsertNewInstBefore(NewOp, I); + return new CastInst(NewOp, I.getType()); + } + } + return Changed ? &I : 0; } @@ -2865,6 +2878,20 @@ } } } + + // fold (or (cast A), (cast B)) -> (cast (or A, B)) + if (CastInst *Op0C = dyn_cast<CastInst>(Op0)) { + if (CastInst *Op1C = dyn_cast<CastInst>(Op1)) + if (Op0C->getOperand(0)->getType() == Op1C->getOperand(0)->getType() && + Op0C->getOperand(0)->getType()->isIntegral()) { + Instruction *NewOp = BinaryOperator::createOr(Op0C->getOperand(0), + Op1C->getOperand(0), + I.getName()); + InsertNewInstBefore(NewOp, I); + return new CastInst(NewOp, I.getType()); + } + } + return Changed ? &I : 0; } @@ -3030,6 +3057,19 @@ if (Instruction *R = AssociativeOpt(I, FoldSetCCLogical(*this, RHS))) return R; + // fold (xor (cast A), (cast B)) -> (cast (xor A, B)) + if (CastInst *Op0C = dyn_cast<CastInst>(Op0)) { + if (CastInst *Op1C = dyn_cast<CastInst>(Op1)) + if (Op0C->getOperand(0)->getType() == Op1C->getOperand(0)->getType() && + Op0C->getOperand(0)->getType()->isIntegral()) { + Instruction *NewOp = BinaryOperator::createXor(Op0C->getOperand(0), + Op1C->getOperand(0), + I.getName()); + InsertNewInstBefore(NewOp, I); + return new CastInst(NewOp, I.getType()); + } + } + return Changed ? &I : 0; } _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits