[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Chris Lattner
lattner at cs.uiuc.edu
Tue Sep 10 18:05:02 PDT 2002
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.54 -> 1.55
---
Log message:
Add cannonicalization of shl X, 1 -> add X, X
---
Diffs of the changes:
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.54 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.55
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.54 Mon Sep 9 22:50:54 2002
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Tue Sep 10 18:04:09 2002
@@ -490,10 +490,18 @@
// a signed value.
//
if (ConstantUInt *CUI = dyn_cast<ConstantUInt>(Op1)) {
- unsigned TypeBits = Op0->getType()->getPrimitiveSize()*8;
- if (CUI->getValue() >= TypeBits &&
- !(Op0->getType()->isSigned() && I.getOpcode() == Instruction::Shr))
- return ReplaceInstUsesWith(I, Constant::getNullValue(Op0->getType()));
+ if (I.getOpcode() == Instruction::Shr) {
+ unsigned TypeBits = Op0->getType()->getPrimitiveSize()*8;
+ if (CUI->getValue() >= TypeBits && !(Op0->getType()->isSigned()))
+ return ReplaceInstUsesWith(I, Constant::getNullValue(Op0->getType()));
+ }
+
+ // Check to see if we are shifting left by 1. If so, turn it into an add
+ // instruction.
+ if (I.getOpcode() == Instruction::Shl && CUI->equalsInt(1))
+ // Convert 'shl int %X, 2' to 'add int %X, %X'
+ return BinaryOperator::create(Instruction::Add, Op0, Op0, I.getName());
+
}
return 0;
}
More information about the llvm-commits
mailing list