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

Andrew Lenharth alenhar2 at cs.uiuc.edu
Mon Feb 26 13:34:52 PST 2007



Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.536.2.1.2.2 -> 1.536.2.1.2.3
---
Log message:

This happens a lot in the kernel.  Getting rid of the int to ptr casts really helps DSA

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

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


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.536.2.1.2.2 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.536.2.1.2.3
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.536.2.1.2.2	Fri Feb 23 11:24:11 2007
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Mon Feb 26 15:34:35 2007
@@ -5921,6 +5921,17 @@
         }
       }
     }
+
+    //and x,c -> cast int to ptr ==> cast (GEP (cast x to sbyte*), 0 - (and x, ~c)) to ptr
+    if (SrcI->getOpcode() == Instruction::And && isa<PointerType>(CI.getType()) && SrcI->getType()->isInteger()
+        && isa<ConstantInt>(SrcI->getOperand(1))) {
+      Value* BC = InsertCastBefore(SrcI->getOperand(0), PointerType::get(Type::SByteTy), CI);
+      Value* Tp = InsertNewInstBefore(BinaryOperator::createNot(SrcI->getOperand(1)), CI);
+      Tp = InsertNewInstBefore(BinaryOperator::createAnd(SrcI->getOperand(0), Tp), CI);
+      Tp = InsertNewInstBefore(BinaryOperator::createSub(ConstantInt::get(SrcI->getType(), 0), Tp), CI);
+      Tp = InsertNewInstBefore(new GetElementPtrInst(BC, Tp), CI);
+      return new CastInst(Tp, CI.getType());
+    }
   }
       
   return 0;






More information about the llvm-commits mailing list