To avoid assertion, we must ensure that the inner shift constant is within range before calling ConstantSDNode::getZExtValue(). We already know that the outer shift constant is in range.
Followup to D23007
llvm-svn: 281362
N0.getOperand(0).getOpcode() == ISD::SRL) {
SDValue N0Op0 = N0.getOperand(0);
if (ConstantSDNode *N0Op0C1 = isConstOrConstSplat(N0Op0.getOperand(1))) {
- uint64_t c1 = N0Op0C1->getZExtValue();
- if (c1 < VT.getScalarSizeInBits()) {
+ if (N0Op0C1->getAPIntValue().ult(VT.getScalarSizeInBits())) {
+ uint64_t c1 = N0Op0C1->getZExtValue();
uint64_t c2 = N1C->getZExtValue();
if (c1 == c2) {
SDValue NewOp0 = N0.getOperand(0);
%3 = shl <2 x i256> %2, <i256 128, i256 128>
ret <2 x i256> %3
}
+
+define <2 x i256> @shl_zext_lshr_outofrange(<2 x i128> %a0) {
+ %1 = lshr <2 x i128> %a0, <i128 -1, i128 -1>
+ %2 = zext <2 x i128> %1 to <2 x i256>
+ %3 = shl <2 x i256> %2, <i256 128, i256 128>
+ ret <2 x i256> %3
+}