diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -25022,9 +25022,8 @@ APInt APIntShiftAmt; if (!isConstantSplat(Amt, APIntShiftAmt)) return SDValue(); - assert(APIntShiftAmt.ult(VT.getScalarSizeInBits()) && - "Out of range shift amount"); - uint64_t ShiftAmt = APIntShiftAmt.getZExtValue(); + uint64_t ShiftAmt = + APIntShiftAmt.getLimitedValue(VT.getScalarSizeInBits() - 1); if (SupportedVectorShiftWithImm(VT, Subtarget, Op.getOpcode())) return getTargetVShiftByConstNode(X86Opc, dl, VT, R, ShiftAmt, DAG); diff --git a/llvm/test/CodeGen/X86/pr42615.ll b/llvm/test/CodeGen/X86/pr42615.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/X86/pr42615.ll @@ -0,0 +1,20 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc < %s -mtriple=i686-w64-windows-gnu -mattr=sse2 | FileCheck %s + +define <2 x i64> @_ZL14c_v256_ziphi_86c_v256S_() { +; CHECK-LABEL: _ZL14c_v256_ziphi_86c_v256S_: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: movd {{.*#+}} xmm0 = mem[0],zero,zero,zero +; CHECK-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,1,0,0] +; CHECK-NEXT: movdqa %xmm0, %xmm1 +; CHECK-NEXT: psllq $56, %xmm1 +; CHECK-NEXT: psllq $63, %xmm0 +; CHECK-NEXT: movsd {{.*#+}} xmm0 = xmm1[0],xmm0[1] +; CHECK-NEXT: retl +entry: + %a.sroa.0.sroa.1.0.copyload = load i64, i64* undef, align 4 + %0 = insertelement <2 x i64> undef, i64 %a.sroa.0.sroa.1.0.copyload, i32 1 + %1 = shl <2 x i64> %0, + %2 = shufflevector <2 x i64> %1, <2 x i64> undef, <2 x i32> + ret <2 x i64> %2 +}