diff options
author | Chris Lattner <sabre@nondot.org> | 2011-02-13 09:10:56 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-02-13 09:10:56 +0000 |
commit | 915eeb488786379250808d47668c43e010efe566 (patch) | |
tree | 7ca78048960929fd07ee81a7f764785aeaabf334 /lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp | |
parent | d3027738856d57ee22930deca0c7977fdc13e633 (diff) |
when legalizing extremely wide shifts, make sure that
the shift amounts are in a suitably wide type so that
we don't generate out of range constant shift amounts.
This fixes PR9028.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125458 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp b/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp index 007f8d658e..4c8cb5253a 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp @@ -1167,13 +1167,19 @@ void DAGTypeLegalizer::ExpandShiftByConstant(SDNode *N, unsigned Amt, unsigned NVTBits = NVT.getSizeInBits(); EVT ShTy = N->getOperand(1).getValueType(); + // If this is a large integer being legalized (e.g. an i512) then plop the + // shift amount down as a fixed i32. The target shift amount may be something + // like i8, but this isn't enough to represent the shift amount. + if (NVTBits > 256) + ShTy = MVT::i32; + if (N->getOpcode() == ISD::SHL) { if (Amt > VTBits) { Lo = Hi = DAG.getConstant(0, NVT); } else if (Amt > NVTBits) { Lo = DAG.getConstant(0, NVT); Hi = DAG.getNode(ISD::SHL, dl, - NVT, InL, DAG.getConstant(Amt-NVTBits,ShTy)); + NVT, InL, DAG.getConstant(Amt-NVTBits, ShTy)); } else if (Amt == NVTBits) { Lo = DAG.getConstant(0, NVT); Hi = InL; |