From: Craig Topper Date: Wed, 26 Jun 2019 19:45:48 +0000 (+0000) Subject: [X86] Remove isTypePromotionOfi1ZeroUpBits and its helpers. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8ded3ca9a968d873183c400d8c3bec3db45dab42;p=llvm [X86] Remove isTypePromotionOfi1ZeroUpBits and its helpers. This was trying to optimize concat_vectors with zero of setcc or kand instructions. But I think it produced the same code we produce for a concat_vectors with 0 even it it doesn't come from one of those operations. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364463 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 2475dc46e02..21bb426fcfe 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -5528,19 +5528,6 @@ SDValue SplitOpsAndApply(SelectionDAG &DAG, const X86Subtarget &Subtarget, return DAG.getNode(ISD::CONCAT_VECTORS, DL, VT, Subs); } -// Return true if the instruction zeroes the unused upper part of the -// destination and accepts mask. -static bool isMaskedZeroUpperBitsvXi1(unsigned int Opcode) { - switch (Opcode) { - default: - return false; - case X86ISD::CMPM: - case X86ISD::CMPM_SAE: - case ISD::SETCC: - return true; - } -} - /// Insert i1-subvector to i1-vector. static SDValue insert1BitVector(SDValue Op, SelectionDAG &DAG, const X86Subtarget &Subtarget) { @@ -9690,60 +9677,9 @@ static SDValue LowerAVXCONCAT_VECTORS(SDValue Op, SelectionDAG &DAG, return Vec; } -// Return true if all the operands of the given CONCAT_VECTORS node are zeros -// except for the first one. (CONCAT_VECTORS Op, 0, 0,...,0) -static bool isExpandWithZeros(const SDValue &Op) { - assert(Op.getOpcode() == ISD::CONCAT_VECTORS && - "Expand with zeros only possible in CONCAT_VECTORS nodes!"); - - for (unsigned i = 1; i < Op.getNumOperands(); i++) - if (!ISD::isBuildVectorAllZeros(Op.getOperand(i).getNode())) - return false; - - return true; -} - // Returns true if the given node is a type promotion (by concatenating i1 // zeros) of the result of a node that already zeros all upper bits of // k-register. -static SDValue isTypePromotionOfi1ZeroUpBits(SDValue Op) { - unsigned Opc = Op.getOpcode(); - - assert(Opc == ISD::CONCAT_VECTORS && - Op.getSimpleValueType().getVectorElementType() == MVT::i1 && - "Unexpected node to check for type promotion!"); - - // As long as we are concatenating zeros to the upper part of a previous node - // result, climb up the tree until a node with different opcode is - // encountered - while (Opc == ISD::INSERT_SUBVECTOR || Opc == ISD::CONCAT_VECTORS) { - if (Opc == ISD::INSERT_SUBVECTOR) { - if (ISD::isBuildVectorAllZeros(Op.getOperand(0).getNode()) && - Op.getConstantOperandVal(2) == 0) - Op = Op.getOperand(1); - else - return SDValue(); - } else { // Opc == ISD::CONCAT_VECTORS - if (isExpandWithZeros(Op)) - Op = Op.getOperand(0); - else - return SDValue(); - } - Opc = Op.getOpcode(); - } - - // Check if the first inserted node zeroes the upper bits, or an 'and' result - // of a node that zeros the upper bits (its masked version). - if (isMaskedZeroUpperBitsvXi1(Op.getOpcode()) || - (Op.getOpcode() == ISD::AND && - (isMaskedZeroUpperBitsvXi1(Op.getOperand(0).getOpcode()) || - isMaskedZeroUpperBitsvXi1(Op.getOperand(1).getOpcode())))) { - return Op; - } - - return SDValue(); -} - // TODO: Merge this with LowerAVXCONCAT_VECTORS? static SDValue LowerCONCAT_VECTORSvXi1(SDValue Op, const X86Subtarget &Subtarget, @@ -9755,13 +9691,6 @@ static SDValue LowerCONCAT_VECTORSvXi1(SDValue Op, assert(NumOperands > 1 && isPowerOf2_32(NumOperands) && "Unexpected number of operands in CONCAT_VECTORS"); - // If this node promotes - by concatenating zeroes - the type of the result - // of a node with instruction that zeroes all upper (irrelevant) bits of the - // output register, mark it as legal and catch the pattern in instruction - // selection to avoid emitting extra instructions (for zeroing upper bits). - if (SDValue Promoted = isTypePromotionOfi1ZeroUpBits(Op)) - return widenSubVector(ResVT, Promoted, true, Subtarget, DAG, dl); - unsigned NumZero = 0; unsigned NumNonZero = 0; uint64_t NonZeros = 0;