OSDN Git Service

[X86] foldVectorXorShiftIntoCmp - use isConstOrConstSplat. NFCI.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Fri, 21 Jun 2019 10:54:30 +0000 (10:54 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Fri, 21 Jun 2019 10:54:30 +0000 (10:54 +0000)
Use the isConstOrConstSplat helper instead of inspecting the build vector manually.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364024 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86ISelLowering.cpp

index 4e93ca6..e15acc7 100644 (file)
@@ -38842,13 +38842,10 @@ static SDValue foldVectorXorShiftIntoCmp(SDNode *N, SelectionDAG &DAG,
     return SDValue();
 
   // The shift should be smearing the sign bit across each vector element.
-  auto *ShiftBV = dyn_cast<BuildVectorSDNode>(Shift.getOperand(1));
-  if (!ShiftBV)
-    return SDValue();
-
-  EVT ShiftEltTy = Shift.getValueType().getVectorElementType();
-  auto *ShiftAmt = ShiftBV->getConstantSplatNode();
-  if (!ShiftAmt || ShiftAmt->getZExtValue() != ShiftEltTy.getSizeInBits() - 1)
+  auto *ShiftAmt =
+      isConstOrConstSplat(Shift.getOperand(1), /*AllowUndefs*/ true);
+  if (!ShiftAmt ||
+      ShiftAmt->getAPIntValue() != (Shift.getScalarValueSizeInBits() - 1))
     return SDValue();
 
   // Create a greater-than comparison against -1. We don't use the more obvious