@@ -4069,74 +4069,6 @@ SDValue AMDGPUTargetLowering::splitBinaryBitConstantOpImpl(
40694069 return DAG.getNode (ISD::BITCAST, SL, MVT::i64 , Vec);
40704070}
40714071
4072- // Each shift has an optimisation to transform a 64-bit shift into a 32-bit
4073- // shift coupled with an AND if the shift amount is within certain bounds. The
4074- // vector code for this was being completely scalarised by the vector legalizer,
4075- // but when v2i32 is legal the vector legaliser only partially scalarises the
4076- // vector operations and the and is not elided. This function
4077- // scalarises the AND for this optimisation case, ensuring it is elided.
4078- // (shiftop x, (extract_vector_element (and {y0, y1},
4079- // (build_vector 0x1f, 0x1f))), index)
4080- // -> (shiftop x, (and (extract_vector_element {yo, y1}, index), 0x1f))
4081- static SDValue getShiftForReduction (SDNode *N, SelectionDAG &DAG) {
4082- assert ((N->getOpcode () == ISD::SRA || N->getOpcode () == ISD::SRL ||
4083- N->getOpcode () == ISD::SHL) &&
4084- " Expected shift Opcode." );
4085-
4086- if (N->getValueType (0 ) != MVT::i32 )
4087- return SDValue ();
4088-
4089- SDValue LHS = N->getOperand (0 );
4090- SDValue RHS = N->getOperand (1 );
4091-
4092- SDLoc SL = SDLoc (N);
4093- if (RHS->getOpcode () != ISD::EXTRACT_VECTOR_ELT)
4094- return SDValue ();
4095-
4096- SDValue VAND = RHS.getOperand (0 );
4097- if (VAND->getOpcode () != ISD::AND)
4098- return SDValue ();
4099-
4100- ConstantSDNode *CRHS = dyn_cast<ConstantSDNode>(RHS->getOperand (1 ));
4101- if (!CRHS)
4102- return SDValue ();
4103-
4104- SDValue LHSAND = VAND.getOperand (0 );
4105- SDValue RHSAND = VAND.getOperand (1 );
4106- if (RHSAND->getOpcode () != ISD::BUILD_VECTOR)
4107- return SDValue ();
4108-
4109- ConstantSDNode *CANDL = dyn_cast<ConstantSDNode>(RHSAND->getOperand (0 ));
4110- ConstantSDNode *CANDR = dyn_cast<ConstantSDNode>(RHSAND->getOperand (1 ));
4111- if (!CANDL || !CANDR || RHSAND->getConstantOperandVal (0 ) != 0x1f ||
4112- RHSAND->getConstantOperandVal (1 ) != 0x1f )
4113- return SDValue ();
4114-
4115- // Get the non-const AND operands and produce scalar AND
4116- SDValue AndMask = DAG.getConstant (0x1f , SL, MVT::i32 );
4117- // Determine which element of the v2i32 to apply the shift to.
4118- uint64_t AndIndex = RHS->getConstantOperandVal (1 );
4119-
4120- if (AndIndex == 0 ) {
4121- const SDValue Zero = DAG.getConstant (0 , SL, MVT::i32 );
4122- SDValue Lo =
4123- DAG.getNode (ISD::EXTRACT_VECTOR_ELT, SL, MVT::i32 , LHSAND, Zero);
4124- SDValue LoAnd = DAG.getNode (ISD::AND, SL, MVT::i32 , Lo, AndMask);
4125- return DAG.getNode (N->getOpcode (), SL, MVT::i32 , LHS, LoAnd, N->getFlags ());
4126- }
4127-
4128- if (AndIndex == 1 ) {
4129- const SDValue One = DAG.getConstant (1 , SL, MVT::i32 );
4130- SDValue Hi =
4131- DAG.getNode (ISD::EXTRACT_VECTOR_ELT, SL, MVT::i32 , LHSAND, One);
4132- SDValue HiAnd = DAG.getNode (ISD::AND, SL, MVT::i32 , Hi, AndMask);
4133- return DAG.getNode (N->getOpcode (), SL, MVT::i32 , LHS, HiAnd,
4134- RHS->getFlags ());
4135- }
4136-
4137- return SDValue ();
4138- }
4139-
41404072SDValue AMDGPUTargetLowering::performShlCombine (SDNode *N,
41414073 DAGCombinerInfo &DCI) const {
41424074 EVT VT = N->getValueType (0 );
0 commit comments