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

Owen Anderson resistor at mac.com
Tue Aug 26 17:31:02 PDT 2008


Author: resistor
Date: Tue Aug 26 19:31:01 2008
New Revision: 55399

URL: http://llvm.org/viewvc/llvm-project?rev=55399&view=rev
Log:
Add support for fast isel of inttoptr and ptrtoint in the cases where truncation is not needed.

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=55399&r1=55398&r2=55399&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Tue Aug 26 19:31:01 2008
@@ -388,6 +388,25 @@
         if (!SelectConstantCast(I, ISD::SINT_TO_FP, ValueMap)) return I;
       break;
 
+    case Instruction::IntToPtr: // Deliberate fall-through.
+    case Instruction::PtrToInt: {
+      MVT SrcVT = TLI.getValueType(I->getOperand(0)->getType());
+      MVT DstVT = TLI.getValueType(I->getType());
+      if (SrcVT.getSimpleVT() == DstVT.getSimpleVT()) {
+        ValueMap[I] = ValueMap[I->getOperand(0)];
+        break;
+      } else if (DstVT.bitsGT(SrcVT)) {
+        if (!isa<ConstantInt>(I->getOperand(0))) {
+          if (!SelectCast(I, ISD::ZERO_EXTEND, ValueMap)) return I;
+        } else
+          if (!SelectConstantCast(I, ISD::ZERO_EXTEND, ValueMap)) return I;
+        break;
+      } else {
+        // TODO: Handle SrcVT > DstVT, where truncation is needed.
+        return I;
+      }
+    }
+    
     default:
       // Unhandled instruction. Halt "fast" selection and bail.
       return I;





More information about the llvm-commits mailing list