[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Chris Lattner
lattner at cs.uiuc.edu
Fri Sep 19 14:06:01 PDT 2003
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.121 -> 1.122
---
Log message:
Implement InstCombine/and.ll:test(15|16)
---
Diffs of the changes:
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.121 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.122
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.121 Fri Sep 19 12:17:26 2003
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Fri Sep 19 14:05:02 2003
@@ -798,6 +798,33 @@
}
}
break;
+
+ case Instruction::Shl: {
+ // We know that the AND will not produce any of the bits shifted in, so if
+ // the anded constant includes them, clear them now!
+ //
+ Constant *AllOne = ConstantIntegral::getAllOnesValue(AndRHS->getType());
+ Constant *CI = *AndRHS & *(*AllOne << *OpRHS);
+ if (CI != AndRHS) {
+ TheAnd.setOperand(1, CI);
+ return &TheAnd;
+ }
+ break;
+ }
+ case Instruction::Shr:
+ // We know that the AND will not produce any of the bits shifted in, so if
+ // the anded constant includes them, clear them now! This only applies to
+ // unsigned shifts, because a signed shr may bring in set bits!
+ //
+ if (AndRHS->getType()->isUnsigned()) {
+ Constant *AllOne = ConstantIntegral::getAllOnesValue(AndRHS->getType());
+ Constant *CI = *AndRHS & *(*AllOne >> *OpRHS);
+ if (CI != AndRHS) {
+ TheAnd.setOperand(1, CI);
+ return &TheAnd;
+ }
+ }
+ break;
}
return 0;
}
More information about the llvm-commits
mailing list