Skip to content

Commit 2c7e7b5

Browse files
authored
[X86] Extend shuf128(concat(x,y),concat(z,w)) -> shuf128(widen(y),widen(w)) folds to peek through bitcasts (llvm#129896)
Peek through bitcasts when looking for freely accessible upper subvectors
1 parent 620c383 commit 2c7e7b5

File tree

5 files changed

+787
-840
lines changed

5 files changed

+787
-840
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42365,10 +42365,10 @@ static SDValue combineTargetShuffle(SDValue N, const SDLoc &DL,
4236542365
// If we're permuting the upper 256-bits subvectors of a concatenation, then
4236642366
// see if we can peek through and access the subvector directly.
4236742367
if (VT.is512BitVector()) {
42368-
// 512-bit mask uses 4 x i2 indices - if the msb is always set then only the
42369-
// upper subvector is used.
42370-
SDValue LHS = N->getOperand(0);
42371-
SDValue RHS = N->getOperand(1);
42368+
// 512-bit mask uses 4 x i2 indices - if the msb is always set then only
42369+
// the upper subvector is used.
42370+
SDValue LHS = peekThroughBitcasts(N->getOperand(0));
42371+
SDValue RHS = peekThroughBitcasts(N->getOperand(1));
4237242372
uint64_t Mask = N->getConstantOperandVal(2);
4237342373
SmallVector<SDValue> LHSOps, RHSOps;
4237442374
SDValue NewLHS, NewRHS;
@@ -42383,8 +42383,9 @@ static SDValue combineTargetShuffle(SDValue N, const SDLoc &DL,
4238342383
Mask &= ~0xA0;
4238442384
}
4238542385
if (NewLHS || NewRHS)
42386-
return DAG.getNode(X86ISD::SHUF128, DL, VT, NewLHS ? NewLHS : LHS,
42387-
NewRHS ? NewRHS : RHS,
42386+
return DAG.getNode(X86ISD::SHUF128, DL, VT,
42387+
DAG.getBitcast(VT, NewLHS ? NewLHS : LHS),
42388+
DAG.getBitcast(VT, NewRHS ? NewRHS : RHS),
4238842389
DAG.getTargetConstant(Mask, DL, MVT::i8));
4238942390
}
4239042391
return SDValue();

0 commit comments

Comments
 (0)