@@ -28412,6 +28412,43 @@ SDValue X86TargetLowering::LowerRESET_FPENV(SDValue Op,
2841228412 return createSetFPEnvNodes(Env, Chain, DL, MVT::i32, MMO, DAG, Subtarget);
2841328413}
2841428414
28415+ // Generate a GFNI gf2p8affine bitmask for vXi8 bitreverse/shift/rotate.
28416+ uint64_t getGFNICtrlImm(unsigned Opcode, unsigned Amt = 0) {
28417+ assert((Amt < 8) && "Shift/Rotation amount out of range");
28418+ switch (Opcode) {
28419+ case ISD::BITREVERSE:
28420+ return 0x8040201008040201ULL;
28421+ case ISD::SHL:
28422+ return ((0x0102040810204080ULL >> (Amt)) &
28423+ (0x0101010101010101ULL * (0xFF >> (Amt))));
28424+ case ISD::SRL:
28425+ return ((0x0102040810204080ULL << (Amt)) &
28426+ (0x0101010101010101ULL * ((0xFF << (Amt)) & 0xFF)));
28427+ case ISD::SRA:
28428+ return (getGFNICtrlImm(ISD::SRL, Amt) |
28429+ (0x8080808080808080ULL >> (64 - (8 * Amt))));
28430+ case ISD::ROTL:
28431+ return getGFNICtrlImm(ISD::SRL, 8 - Amt) | getGFNICtrlImm(ISD::SHL, Amt);
28432+ case ISD::ROTR:
28433+ return getGFNICtrlImm(ISD::SHL, 8 - Amt) | getGFNICtrlImm(ISD::SRL, Amt);
28434+ }
28435+ llvm_unreachable("Unsupported GFNI opcode");
28436+ }
28437+
28438+ // Generate a GFNI gf2p8affine bitmask for vXi8 bitreverse/shift/rotate.
28439+ SDValue getGFNICtrlMask(unsigned Opcode, SelectionDAG &DAG, const SDLoc &DL,
28440+ MVT VT, unsigned Amt = 0) {
28441+ assert(VT.getVectorElementType() == MVT::i8 &&
28442+ (VT.getSizeInBits() % 64) == 0 && "Illegal GFNI control type");
28443+ uint64_t Imm = getGFNICtrlImm(Opcode, Amt);
28444+ SmallVector<SDValue> MaskBits;
28445+ for (unsigned I = 0, E = VT.getSizeInBits(); I != E; I += 8) {
28446+ uint64_t Bits = (Imm >> (I % 64)) & 255;
28447+ MaskBits.push_back(DAG.getConstant(Bits, DL, MVT::i8));
28448+ }
28449+ return DAG.getBuildVector(VT, DL, MaskBits);
28450+ }
28451+
2841528452/// Lower a vector CTLZ using native supported vector CTLZ instruction.
2841628453//
2841728454// i8/i16 vector implemented using dword LZCNT vector instruction
@@ -29597,43 +29634,6 @@ SDValue X86TargetLowering::LowerWin64_INT128_TO_FP(SDValue Op,
2959729634 return IsStrict ? DAG.getMergeValues({Result, Chain}, dl) : Result;
2959829635}
2959929636
29600- // Generate a GFNI gf2p8affine bitmask for vXi8 bitreverse/shift/rotate.
29601- uint64_t getGFNICtrlImm(unsigned Opcode, unsigned Amt = 0) {
29602- assert((Amt < 8) && "Shift/Rotation amount out of range");
29603- switch (Opcode) {
29604- case ISD::BITREVERSE:
29605- return 0x8040201008040201ULL;
29606- case ISD::SHL:
29607- return ((0x0102040810204080ULL >> (Amt)) &
29608- (0x0101010101010101ULL * (0xFF >> (Amt))));
29609- case ISD::SRL:
29610- return ((0x0102040810204080ULL << (Amt)) &
29611- (0x0101010101010101ULL * ((0xFF << (Amt)) & 0xFF)));
29612- case ISD::SRA:
29613- return (getGFNICtrlImm(ISD::SRL, Amt) |
29614- (0x8080808080808080ULL >> (64 - (8 * Amt))));
29615- case ISD::ROTL:
29616- return getGFNICtrlImm(ISD::SRL, 8 - Amt) | getGFNICtrlImm(ISD::SHL, Amt);
29617- case ISD::ROTR:
29618- return getGFNICtrlImm(ISD::SHL, 8 - Amt) | getGFNICtrlImm(ISD::SRL, Amt);
29619- }
29620- llvm_unreachable("Unsupported GFNI opcode");
29621- }
29622-
29623- // Generate a GFNI gf2p8affine bitmask for vXi8 bitreverse/shift/rotate.
29624- SDValue getGFNICtrlMask(unsigned Opcode, SelectionDAG &DAG, const SDLoc &DL, MVT VT,
29625- unsigned Amt = 0) {
29626- assert(VT.getVectorElementType() == MVT::i8 &&
29627- (VT.getSizeInBits() % 64) == 0 && "Illegal GFNI control type");
29628- uint64_t Imm = getGFNICtrlImm(Opcode, Amt);
29629- SmallVector<SDValue> MaskBits;
29630- for (unsigned I = 0, E = VT.getSizeInBits(); I != E; I += 8) {
29631- uint64_t Bits = (Imm >> (I % 64)) & 255;
29632- MaskBits.push_back(DAG.getConstant(Bits, DL, MVT::i8));
29633- }
29634- return DAG.getBuildVector(VT, DL, MaskBits);
29635- }
29636-
2963729637// Return true if the required (according to Opcode) shift-imm form is natively
2963829638// supported by the Subtarget
2963929639static bool supportedVectorShiftWithImm(EVT VT, const X86Subtarget &Subtarget,
0 commit comments