From 134f56e70209719e4ece6b33235f2a4b87dcb253 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Mon, 10 Dec 2018 17:23:44 +0000 Subject: [PATCH] [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. llvm-svn: 348776 --- llvm/lib/Target/X86/X86ISelLowering.cpp | 36 ++++++++++++++++----------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index a9bc93f..e82a79f 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -19148,34 +19148,32 @@ static SDValue LowerIntVSETCC_AVX512(SDValue Op, SelectionDAG &DAG) { 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(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(V.getNode()); if (!BV) return SDValue(); - MVT VT = Op1.getSimpleValueType(); - MVT EVT = VT.getVectorElementType(); - unsigned n = VT.getVectorNumElements(); - SmallVector ULTOp1; - - for (unsigned i = 0; i < n; ++i) { - ConstantSDNode *Elt = dyn_cast(BV->getOperand(i)); - if (!Elt || Elt->isOpaque() || Elt->getSimpleValueType(0) != EVT) + MVT VT = V.getSimpleValueType(); + MVT EltVT = VT.getVectorElementType(); + unsigned NumElts = VT.getVectorNumElements(); + SmallVector NewVecC; + SDLoc DL(V); + for (unsigned i = 0; i < NumElts; ++i) { + auto *Elt = dyn_cast(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(SDValue Op0, SDValue Op1, MVT VT, // 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; -- 2.7.4