Skip to content

Commit 10b0dee

Browse files
TDeckingRKSimon
andauthored
[X86] Ensure that bit reversals of byte vectors are properly lowered on pure GFNI targets (#148304)
Fixes #148238. When GFNI is present, custom bit reversal lowerings for scalar integers become active. They work by swapping the bytes in the scalar value and then reversing bits in a vector of bytes. However, the custom bit reversal lowering for a vector of bytes is disabled if GFNI is present in isolation, resulting messed up code. --------- Co-authored-by: Simon Pilgrim <[email protected]>
1 parent 4bf4e87 commit 10b0dee

File tree

2 files changed

+313
-84
lines changed

2 files changed

+313
-84
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,11 +1323,15 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
13231323
setOperationAction(ISD::STRICT_FDIV, MVT::v2f64, Legal);
13241324
}
13251325

1326-
if (Subtarget.hasGFNI()) {
1326+
if (!Subtarget.useSoftFloat() && Subtarget.hasGFNI()) {
13271327
setOperationAction(ISD::BITREVERSE, MVT::i8, Custom);
13281328
setOperationAction(ISD::BITREVERSE, MVT::i16, Custom);
13291329
setOperationAction(ISD::BITREVERSE, MVT::i32, Custom);
13301330
setOperationAction(ISD::BITREVERSE, MVT::i64, Custom);
1331+
1332+
for (auto VT : {MVT::v16i8, MVT::v8i16, MVT::v4i32, MVT::v2i64}) {
1333+
setOperationAction(ISD::BITREVERSE, VT, Custom);
1334+
}
13311335
}
13321336

13331337
if (!Subtarget.useSoftFloat() && Subtarget.hasSSSE3()) {
@@ -32694,7 +32698,8 @@ static SDValue LowerBITREVERSE(SDValue Op, const X86Subtarget &Subtarget,
3269432698
if (Subtarget.hasXOP() && !VT.is512BitVector())
3269532699
return LowerBITREVERSE_XOP(Op, DAG);
3269632700

32697-
assert(Subtarget.hasSSSE3() && "SSSE3 required for BITREVERSE");
32701+
assert((Subtarget.hasSSSE3() || Subtarget.hasGFNI()) &&
32702+
"SSSE3 or GFNI required for BITREVERSE");
3269832703

3269932704
SDValue In = Op.getOperand(0);
3270032705
SDLoc DL(Op);

0 commit comments

Comments
 (0)