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

Chris Lattner lattner at cs.uiuc.edu
Fri May 5 13:51:44 PDT 2006



Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.475 -> 1.476
---
Log message:

Fix an infinite loop compiling oggenc last night.


---
Diffs of the changes:  (+9 -6)

 InstructionCombining.cpp |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.475 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.476
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.475	Fri May  5 01:39:07 2006
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Fri May  5 15:51:30 2006
@@ -2642,9 +2642,10 @@
 
   // fold (and (cast A), (cast B)) -> (cast (and A, B))
   if (CastInst *Op0C = dyn_cast<CastInst>(Op0)) {
+    const Type *SrcTy = Op0C->getOperand(0)->getType();
     if (CastInst *Op1C = dyn_cast<CastInst>(Op1))
-      if (Op0C->getOperand(0)->getType() == Op1C->getOperand(0)->getType() &&
-          Op0C->getOperand(0)->getType()->isIntegral()) {
+      if (SrcTy == Op1C->getOperand(0)->getType() && SrcTy->isIntegral() &&
+          !SrcTy->isLosslesslyConvertibleTo(Op0C->getType())) {
         Instruction *NewOp = BinaryOperator::createAnd(Op0C->getOperand(0),
                                                        Op1C->getOperand(0),
                                                        I.getName());
@@ -2881,9 +2882,10 @@
     
   // fold (or (cast A), (cast B)) -> (cast (or A, B))
   if (CastInst *Op0C = dyn_cast<CastInst>(Op0)) {
+    const Type *SrcTy = Op0C->getOperand(0)->getType();
     if (CastInst *Op1C = dyn_cast<CastInst>(Op1))
-      if (Op0C->getOperand(0)->getType() == Op1C->getOperand(0)->getType() &&
-          Op0C->getOperand(0)->getType()->isIntegral()) {
+      if (SrcTy == Op1C->getOperand(0)->getType() && SrcTy->isIntegral() &&
+          !SrcTy->isLosslesslyConvertibleTo(Op0C->getType())) {
         Instruction *NewOp = BinaryOperator::createOr(Op0C->getOperand(0),
                                                       Op1C->getOperand(0),
                                                       I.getName());
@@ -3059,9 +3061,10 @@
 
   // fold (xor (cast A), (cast B)) -> (cast (xor A, B))
   if (CastInst *Op0C = dyn_cast<CastInst>(Op0)) {
+    const Type *SrcTy = Op0C->getOperand(0)->getType();
     if (CastInst *Op1C = dyn_cast<CastInst>(Op1))
-      if (Op0C->getOperand(0)->getType() == Op1C->getOperand(0)->getType() &&
-          Op0C->getOperand(0)->getType()->isIntegral()) {
+      if (SrcTy == Op1C->getOperand(0)->getType() && SrcTy->isIntegral() &&
+          !SrcTy->isLosslesslyConvertibleTo(Op0C->getType())) {
         Instruction *NewOp = BinaryOperator::createXor(Op0C->getOperand(0),
                                                        Op1C->getOperand(0),
                                                        I.getName());






More information about the llvm-commits mailing list