[llvm] r366096 - [X86] Return UNDEF from LowerScalarImmediateShift when the shift amount is out of range.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 15 10:56:57 PDT 2019


Author: ctopper
Date: Mon Jul 15 10:56:57 2019
New Revision: 366096

URL: http://llvm.org/viewvc/llvm-project?rev=366096&view=rev
Log:
[X86] Return UNDEF from LowerScalarImmediateShift when the shift amount is out of range.

I think we only turn out of range shiftss to undef when
all elements are out of range or the shift amount is a splat out
of range. I'm not sure which, I didn't check.

During lowering we can split a shift where some elements
are out of range into multiple shifts. This can create a
new shift with a splat shift amount that is out of range.

This patch returns undef for this case.

Fixes PR42615.

Differential Revision: https://reviews.llvm.org/D64699

Modified:
    llvm/trunk/lib/Target/X86/X86ISelLowering.cpp

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=366096&r1=366095&r2=366096&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Jul 15 10:56:57 2019
@@ -25033,8 +25033,11 @@ static SDValue LowerScalarImmediateShift
   APInt APIntShiftAmt;
   if (!isConstantSplat(Amt, APIntShiftAmt))
     return SDValue();
-  assert(APIntShiftAmt.ult(VT.getScalarSizeInBits()) &&
-         "Out of range shift amount");
+
+  // If the shift amount is out of range, return undef.
+  if (APIntShiftAmt.uge(VT.getScalarSizeInBits()))
+    return DAG.getUNDEF(VT);
+
   uint64_t ShiftAmt = APIntShiftAmt.getZExtValue();
 
   if (SupportedVectorShiftWithImm(VT, Subtarget, Op.getOpcode()))




More information about the llvm-commits mailing list