diff options
author | Dan Gohman <gohman@apple.com> | 2009-03-13 23:53:06 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-03-13 23:53:06 +0000 |
commit | 474d3b3f40e117a66946e9fb9d2016b4c05caef0 (patch) | |
tree | e4fe73f5281c4cbfdea7165412bf7d617eff8c60 /lib/CodeGen/SelectionDAG | |
parent | 4425240dbcb6e0da24f4a9f72cfb24f529f5b7af (diff) | |
download | external_llvm-474d3b3f40e117a66946e9fb9d2016b4c05caef0.zip external_llvm-474d3b3f40e117a66946e9fb9d2016b4c05caef0.tar.gz external_llvm-474d3b3f40e117a66946e9fb9d2016b4c05caef0.tar.bz2 |
Improve FastISel's handling of truncates to i1, and implement
ptrtoint and inttoptr in X86FastISel. These casts aren't always
handled in the generic FastISel code because X86 sometimes needs
custom code to do truncation and zero-extension.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66988 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG')
-rw-r--r-- | lib/CodeGen/SelectionDAG/FastISel.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp index 3523dda..6f09f79 100644 --- a/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -477,33 +477,41 @@ bool FastISel::SelectCast(User *I, ISD::NodeType Opcode) { MVT DstVT = TLI.getValueType(I->getType()); if (SrcVT == MVT::Other || !SrcVT.isSimple() || - DstVT == MVT::Other || !DstVT.isSimple() || - !TLI.isTypeLegal(DstVT)) + DstVT == MVT::Other || !DstVT.isSimple()) // Unhandled type. Halt "fast" selection and bail. return false; + // Check if the destination type is legal. Or as a special case, + // it may be i1 if we're doing a truncate because that's + // easy and somewhat common. + if (!TLI.isTypeLegal(DstVT)) + if (DstVT != MVT::i1 || Opcode != ISD::TRUNCATE) + // Unhandled type. Halt "fast" selection and bail. + return false; + // Check if the source operand is legal. Or as a special case, // it may be i1 if we're doing zero-extension because that's - // trivially easy and somewhat common. - if (!TLI.isTypeLegal(SrcVT)) { - if (SrcVT == MVT::i1 && Opcode == ISD::ZERO_EXTEND) - SrcVT = TLI.getTypeToTransformTo(SrcVT); - else + // easy and somewhat common. + if (!TLI.isTypeLegal(SrcVT)) + if (SrcVT != MVT::i1 || Opcode != ISD::ZERO_EXTEND) // Unhandled type. Halt "fast" selection and bail. return false; - } - + unsigned InputReg = getRegForValue(I->getOperand(0)); if (!InputReg) // Unhandled operand. Halt "fast" selection and bail. return false; // If the operand is i1, arrange for the high bits in the register to be zero. - if (I->getOperand(0)->getType() == Type::Int1Ty) { + if (SrcVT == MVT::i1) { + SrcVT = TLI.getTypeToTransformTo(SrcVT); InputReg = FastEmitZExtFromI1(SrcVT.getSimpleVT(), InputReg); if (!InputReg) return false; } + // If the result is i1, truncate to the target's type for i1 first. + if (DstVT == MVT::i1) + DstVT = TLI.getTypeToTransformTo(DstVT); unsigned ResultReg = FastEmit_r(SrcVT.getSimpleVT(), DstVT.getSimpleVT(), |