[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sat Apr 30 21:42:28 PDT 2005
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.332 -> 1.333
---
Log message:
Implement getelementptr.ll:test11
---
Diffs of the changes: (+16 -0)
InstructionCombining.cpp | 16 ++++++++++++++++
1 files changed, 16 insertions(+)
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.332 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.333
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.332 Sat Apr 30 23:24:53 2005
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sat Apr 30 23:42:15 2005
@@ -2879,6 +2879,22 @@
if (Constant *RHSC = dyn_cast<Constant>(Op1)) {
if (Instruction *LHSI = dyn_cast<Instruction>(Op0))
switch (LHSI->getOpcode()) {
+ case Instruction::GetElementPtr:
+ if (RHSC->isNullValue()) {
+ // Transform setcc GEP P, int 0, int 0, int 0, null -> setcc P, null
+ bool isAllZeros = true;
+ for (unsigned i = 1, e = LHSI->getNumOperands(); i != e; ++i)
+ if (!isa<Constant>(LHSI->getOperand(i)) ||
+ !cast<Constant>(LHSI->getOperand(i))->isNullValue()) {
+ isAllZeros = false;
+ break;
+ }
+ if (isAllZeros)
+ return new SetCondInst(I.getOpcode(), LHSI->getOperand(0),
+ Constant::getNullValue(LHSI->getOperand(0)->getType()));
+ }
+ break;
+
case Instruction::PHI:
if (Instruction *NV = FoldOpIntoPhi(I))
return NV;
More information about the llvm-commits
mailing list