Skip to content

Commit bed7001

Browse files
committed
X86: add pattern for X86ISD::VSRAV
Detect clamping ashr shift amount to max legal value
1 parent 2ffa822 commit bed7001

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

‎lib/Target/X86/X86ISelLowering.cpp‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43813,6 +43813,16 @@ static SDValue combineShiftRightArithmetic(SDNode *N, SelectionDAG &DAG,
4381343813
SDValue N1 = N->getOperand(1);
4381443814
EVT VT = N0.getValueType();
4381543815
unsigned Size = VT.getSizeInBits();
43816+
APInt MinAmnt;
43817+
43818+
// Detect pattern (ashr (a, umin(b, MaxAllowedShiftAmount)))
43819+
if (VT.isVector() && N1.getOpcode() == ISD::UMIN &&
43820+
SupportedVectorVarShift(VT.getSimpleVT(), Subtarget, ISD::SRA) &&
43821+
ISD::isConstantSplatVector(N1.getOperand(1).getNode(), MinAmnt) &&
43822+
MinAmnt == VT.getScalarSizeInBits() - 1) {
43823+
// Use infinite-precision vector variable shift if supported
43824+
return DAG.getNode(X86ISD::VSRAV, SDLoc(N), VT, N0, N1.getOperand(0));
43825+
}
4381643826

4381743827
if (SDValue V = combineShiftToPMULH(N, DAG, Subtarget))
4381843828
return V;

0 commit comments

Comments
 (0)