[llvm] r348776 - [x86] fix formatting; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 10 09:23:44 PST 2018
Author: spatel
Date: Mon Dec 10 09:23:44 2018
New Revision: 348776
URL: http://llvm.org/viewvc/llvm-project?rev=348776&view=rev
Log:
[x86] fix formatting; NFC
This should really be generalized to allow increment and/or
we should replace it by using ISD::matchUnaryPredicate().
See D55515 for context.
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=348776&r1=348775&r2=348776&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Dec 10 09:23:44 2018
@@ -19148,34 +19148,32 @@ static SDValue LowerIntVSETCC_AVX512(SDV
return DAG.getSetCC(dl, VT, Op0, Op1, SetCCOpcode);
}
-/// Try to turn a VSETULT into a VSETULE by modifying its second
-/// operand \p Op1. If non-trivial (for example because it's not constant)
-/// return an empty value.
-static SDValue ChangeVSETULTtoVSETULE(const SDLoc &dl, SDValue Op1,
- SelectionDAG &DAG) {
- BuildVectorSDNode *BV = dyn_cast<BuildVectorSDNode>(Op1.getNode());
+/// Given a simple buildvector constant, return a new vector constant with each
+/// element decremented. If decrementing would result in underflow or this
+/// is not a simple vector constant, return an empty value.
+static SDValue decrementVectorConstant(SDValue V, SelectionDAG &DAG) {
+ auto *BV = dyn_cast<BuildVectorSDNode>(V.getNode());
if (!BV)
return SDValue();
- MVT VT = Op1.getSimpleValueType();
- MVT EVT = VT.getVectorElementType();
- unsigned n = VT.getVectorNumElements();
- SmallVector<SDValue, 8> ULTOp1;
-
- for (unsigned i = 0; i < n; ++i) {
- ConstantSDNode *Elt = dyn_cast<ConstantSDNode>(BV->getOperand(i));
- if (!Elt || Elt->isOpaque() || Elt->getSimpleValueType(0) != EVT)
+ MVT VT = V.getSimpleValueType();
+ MVT EltVT = VT.getVectorElementType();
+ unsigned NumElts = VT.getVectorNumElements();
+ SmallVector<SDValue, 8> NewVecC;
+ SDLoc DL(V);
+ for (unsigned i = 0; i < NumElts; ++i) {
+ auto *Elt = dyn_cast<ConstantSDNode>(BV->getOperand(i));
+ if (!Elt || Elt->isOpaque() || Elt->getSimpleValueType(0) != EltVT)
return SDValue();
// Avoid underflow.
- APInt Val = Elt->getAPIntValue();
- if (Val == 0)
+ if (Elt->getAPIntValue().isNullValue())
return SDValue();
- ULTOp1.push_back(DAG.getConstant(Val - 1, dl, EVT));
+ NewVecC.push_back(DAG.getConstant(Elt->getAPIntValue() - 1, DL, EltVT));
}
- return DAG.getBuildVector(VT, dl, ULTOp1);
+ return DAG.getBuildVector(VT, DL, NewVecC);
}
/// As another special case, use PSUBUS[BW] when it's profitable. E.g. for
@@ -19204,7 +19202,7 @@ static SDValue LowerVSETCCWithSUBUS(SDVa
// Only do this pre-AVX since vpcmp* is no longer destructive.
if (Subtarget.hasAVX())
return SDValue();
- SDValue ULEOp1 = ChangeVSETULTtoVSETULE(dl, Op1, DAG);
+ SDValue ULEOp1 = decrementVectorConstant(Op1, DAG);
if (!ULEOp1)
return SDValue();
Op1 = ULEOp1;
More information about the llvm-commits
mailing list