[llvm-commits] [llvm] r57265 - /llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp

Dan Gohman gohman at apple.com
Tue Oct 7 15:03:27 PDT 2008


Author: djg
Date: Tue Oct  7 17:03:27 2008
New Revision: 57265

URL: http://llvm.org/viewvc/llvm-project?rev=57265&view=rev
Log:
Avoid emitting redundant materializations of integer constants
for things like null pointers, which at this level aren't
different from regular integer constants.

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=57265&r1=57264&r2=57265&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Tue Oct  7 17:03:27 2008
@@ -81,7 +81,9 @@
   } else if (isa<AllocaInst>(V)) {
     Reg = TargetMaterializeAlloca(cast<AllocaInst>(V));
   } else if (isa<ConstantPointerNull>(V)) {
-    Reg = FastEmit_i(VT, VT, ISD::Constant, 0);
+    // Translate this as an integer zero so that it can be
+    // local-CSE'd with actual integer zeros.
+    Reg = getRegForValue(Constant::getNullValue(TD.getIntPtrType()));
   } else if (ConstantFP *CF = dyn_cast<ConstantFP>(V)) {
     Reg = FastEmit_f(VT, VT, ISD::ConstantFP, CF);
 
@@ -95,8 +97,7 @@
                                 APFloat::rmTowardZero) != APFloat::opOK) {
         APInt IntVal(IntBitWidth, 2, x);
 
-        unsigned IntegerReg = FastEmit_i(IntVT.getSimpleVT(), IntVT.getSimpleVT(),
-                                         ISD::Constant, IntVal.getZExtValue());
+        unsigned IntegerReg = getRegForValue(ConstantInt::get(IntVal));
         if (IntegerReg != 0)
           Reg = FastEmit_r(IntVT.getSimpleVT(), VT, ISD::SINT_TO_FP, IntegerReg);
       }





More information about the llvm-commits mailing list