From 4c948eb373779718e5be36d7674382b52114bf65 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 13 Feb 2007 23:55:16 +0000 Subject: [PATCH] implement expand of truncate. This allows truncates from i128 to i64 to be supported on 32-bit hosts. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34257 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index c8353ebb6f8..7b148f1158f 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -4859,6 +4859,19 @@ void SelectionDAGLegalize::ExpandOp(SDOperand Op, SDOperand &Lo, SDOperand &Hi){ Hi = DAG.getConstant(0, NVT); break; + case ISD::TRUNCATE: { + // The input value must be larger than this value. Expand *it*. + SDOperand NewLo; + ExpandOp(Node->getOperand(0), NewLo, Hi); + + // The low part is now either the right size, or it is closer. If not the + // right size, make an illegal truncate so we recursively expand it. + if (NewLo.getValueType() != Node->getValueType(0)) + NewLo = DAG.getNode(ISD::TRUNCATE, Node->getValueType(0), NewLo); + ExpandOp(NewLo, Lo, Hi); + break; + } + case ISD::BIT_CONVERT: { SDOperand Tmp; if (TLI.getOperationAction(ISD::BIT_CONVERT, VT) == TargetLowering::Custom){