[llvm-commits] [see] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp

Andrew Lenharth alenhar2 at cs.uiuc.edu
Thu Feb 22 07:11:44 PST 2007



Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.536.2.1 -> 1.536.2.1.2.1
---
Log message:

catch a missed * to int conversion

---
Diffs of the changes:  (+15 -0)

 InstructionCombining.cpp |   15 +++++++++++++++
 1 files changed, 15 insertions(+)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.536.2.1 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.536.2.1.2.1
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.536.2.1	Wed Feb  7 16:32:03 2007
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Thu Feb 22 09:11:27 2007
@@ -4837,6 +4837,21 @@
       return BinaryOperator::create(I.getOpcode(), Op0, Op1);
     }
 
+    //Handle special case of setcc (cast T* to uint) (cast T* to uint)
+    //Generalize to seteq (cast T to >= T') (cast T to >= T')
+    //restrict to ints and pointers (so casts are sext or zext, no reinterpret)
+    if (CastInst* CI1 = dyn_cast<CastInst>(Op1)) {
+      Value* CastOp1 = CI1->getOperand(0);
+      if (I.isEquality() && CastOp0->getType() == CastOp1->getType() &&
+          TD->getTypeSize(Op1->getType()) >= TD->getTypeSize(CastOp1->getType()) &&
+          (CastOp1->getType()->isInteger() || isa<PointerType>(CastOp1->getType())) &&
+          (Op1->getType()->isInteger() || isa<PointerType>(Op1->getType()))
+          ) {
+        std::cerr << "Triggered\n";
+        return BinaryOperator::create(I.getOpcode(), CastOp0, CastOp1);
+      }
+    }
+
     // Handle the special case of: setcc (cast bool to X), <cst>
     // This comes up when you have code like
     //   int X = A < B;






More information about the llvm-commits mailing list