aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2008-08-27 00:31:01 +0000
committerOwen Anderson <resistor@mac.com>2008-08-27 00:31:01 +0000
commitd5d9a90ab4c97946e242ff3072cbff591e8ddb68 (patch)
tree84e9c77ee4a0cbee2f8a050d97f837de31ef01ca /lib/CodeGen
parentc619ed247847c6b4b523f8148a9c5a65cfe5fde8 (diff)
downloadexternal_llvm-d5d9a90ab4c97946e242ff3072cbff591e8ddb68.zip
external_llvm-d5d9a90ab4c97946e242ff3072cbff591e8ddb68.tar.gz
external_llvm-d5d9a90ab4c97946e242ff3072cbff591e8ddb68.tar.bz2
Add support for fast isel of inttoptr and ptrtoint in the cases where truncation is not needed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55399 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/SelectionDAG/FastISel.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp
index 59bc8c5..64843f8 100644
--- a/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ b/lib/CodeGen/SelectionDAG/FastISel.cpp
@@ -388,6 +388,25 @@ FastISel::SelectInstructions(BasicBlock::iterator Begin,
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;