Skip to content

Commit 1672f7d

Browse files
RKSimontru
authored andcommitted
[X86] lowerShuffleAsLanePermuteAndPermute - ensure we've simplified the demanded shuffle mask elts before testing for a matching shuffle (llvm#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 llvm#153457 (cherry picked from commit c96d0da)
1 parent 27fc211 commit 1672f7d

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
@@ -15403,18 +15403,18 @@ static SDValue lowerShuffleAsLanePermuteAndPermute(
1540315403
return SDValue();
1540415404
}
1540515405

15406-
// Avoid returning the same shuffle operation. For example,
15407-
// t7: v16i16 = vector_shuffle<8,9,10,11,4,5,6,7,0,1,2,3,12,13,14,15> t5,
15408-
// undef:v16i16
15409-
if (CrossLaneMask == Mask || InLaneMask == Mask)
15410-
return SDValue();
15411-
1541215406
// Simplify CrossLaneMask based on the actual demanded elements.
1541315407
if (V1.hasOneUse())
1541415408
for (int i = 0; i != NumElts; ++i)
1541515409
if (!DemandedCrossLane[i])
1541615410
CrossLaneMask[i] = SM_SentinelUndef;
1541715411

15412+
// Avoid returning the same shuffle operation. For example,
15413+
// t7: v16i16 = vector_shuffle<8,9,10,11,4,5,6,7,0,1,2,3,12,13,14,15> t5,
15414+
// undef:v16i16
15415+
if (CrossLaneMask == Mask || InLaneMask == Mask)
15416+
return SDValue();
15417+
1541815418
SDValue CrossLane = DAG.getVectorShuffle(VT, DL, V1, V2, CrossLaneMask);
1541915419
return DAG.getVectorShuffle(VT, DL, CrossLane, DAG.getUNDEF(VT),
1542015420
InLaneMask);

0 commit comments

Comments
 (0)