[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Chris Lattner
lattner at cs.uiuc.edu
Tue Aug 12 14:18:01 PDT 2003
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.110 -> 1.111
---
Log message:
Simplify code
---
Diffs of the changes:
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.110 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.111
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.110 Tue Aug 12 14:11:07 2003
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Tue Aug 12 14:17:27 2003
@@ -241,7 +241,8 @@
// dyn_castMaskingAnd - If this value is an And instruction masking a value with
// a constant, return the constant being anded with.
//
-static inline Constant *dyn_castMaskingAnd(Value *V) {
+template<class ValueType>
+static inline Constant *dyn_castMaskingAnd(ValueType *V) {
if (Instruction *I = dyn_cast<Instruction>(V))
if (I->getOpcode() == Instruction::And)
return dyn_cast<Constant>(I->getOperand(1));
@@ -613,16 +614,12 @@
}
// (A & C1)|(A & C2) == A & (C1|C2)
- if (BinaryOperator *BO0 = dyn_cast<BinaryOperator>(Op0))
- if (BinaryOperator *BO1 = dyn_cast<BinaryOperator>(Op1))
- if (BO0->getOperand(0) == BO1->getOperand(0) &&
- BO0->getOpcode() == Instruction::And &&
- BO1->getOpcode() == Instruction::And)
- if (ConstantIntegral *C0 =
- dyn_cast<ConstantIntegral>(BO0->getOperand(1)))
- if (ConstantIntegral *C1 =
- dyn_cast<ConstantIntegral>(BO1->getOperand(1)))
- return BinaryOperator::create(Instruction::And, BO0->getOperand(0),
+ if (Instruction *LHS = dyn_cast<BinaryOperator>(Op0))
+ if (Instruction *RHS = dyn_cast<BinaryOperator>(Op1))
+ if (LHS->getOperand(0) == RHS->getOperand(0))
+ if (Constant *C0 = dyn_castMaskingAnd(LHS))
+ if (Constant *C1 = dyn_castMaskingAnd(RHS))
+ return BinaryOperator::create(Instruction::And, LHS->getOperand(0),
*C0 | *C1);
Value *Op0NotVal = dyn_castNotVal(Op0);
More information about the llvm-commits
mailing list