Skip to content

Commit c96d0da

Browse files
authored
[X86] lowerShuffleAsLanePermuteAndPermute - ensure we've simplified the demanded shuffle mask elts before testing for a matching shuffle (#153554)
When lowering using sublane shuffles, we can sometimes end up with the same mask as we started with. We already bail in these occasions, but we weren't fully simplifying the new shuffle mask before testing if it matched. Fixes #153457
1 parent 9255580 commit c96d0da

File tree

2 files changed

+269
-6
lines changed

2 files changed

+269
-6
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15419,18 +15419,18 @@ static SDValue lowerShuffleAsLanePermuteAndPermute(
1541915419
return SDValue();
1542015420
}
1542115421

15422-
// Avoid returning the same shuffle operation. For example,
15423-
// t7: v16i16 = vector_shuffle<8,9,10,11,4,5,6,7,0,1,2,3,12,13,14,15> t5,
15424-
// undef:v16i16
15425-
if (CrossLaneMask == Mask || InLaneMask == Mask)
15426-
return SDValue();
15427-
1542815422
// Simplify CrossLaneMask based on the actual demanded elements.
1542915423
if (V1.hasOneUse())
1543015424
for (int i = 0; i != NumElts; ++i)
1543115425
if (!DemandedCrossLane[i])
1543215426
CrossLaneMask[i] = SM_SentinelUndef;
1543315427

15428+
// Avoid returning the same shuffle operation. For example,
15429+
// t7: v16i16 = vector_shuffle<8,9,10,11,4,5,6,7,0,1,2,3,12,13,14,15> t5,
15430+
// undef:v16i16
15431+
if (CrossLaneMask == Mask || InLaneMask == Mask)
15432+
return SDValue();
15433+
1543415434
SDValue CrossLane = DAG.getVectorShuffle(VT, DL, V1, V2, CrossLaneMask);
1543515435
return DAG.getVectorShuffle(VT, DL, CrossLane, DAG.getUNDEF(VT),
1543615436
InLaneMask);

0 commit comments

Comments
 (0)