1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

Add support for fast isel of inttoptr and ptrtoint in the cases where truncation is not needed.

llvm-svn: 55399
This commit is contained in:
Owen Anderson 2008-08-27 00:31:01 +00:00
parent a8911f33f8
commit c5d2fe6354

View File

@ -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;