1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 10:32:48 +02:00

X86: add pattern for X86ISD::VSRAV

Detect clamping ashr shift amount to max legal value
This commit is contained in:
Nekotekina 2018-07-04 02:35:29 +03:00
parent 2ffa82223f
commit bed700114e

View File

@ -43813,6 +43813,16 @@ static SDValue combineShiftRightArithmetic(SDNode *N, SelectionDAG &DAG,
SDValue N1 = N->getOperand(1); SDValue N1 = N->getOperand(1);
EVT VT = N0.getValueType(); EVT VT = N0.getValueType();
unsigned Size = VT.getSizeInBits(); unsigned Size = VT.getSizeInBits();
APInt MinAmnt;
// Detect pattern (ashr (a, umin(b, MaxAllowedShiftAmount)))
if (VT.isVector() && N1.getOpcode() == ISD::UMIN &&
SupportedVectorVarShift(VT.getSimpleVT(), Subtarget, ISD::SRA) &&
ISD::isConstantSplatVector(N1.getOperand(1).getNode(), MinAmnt) &&
MinAmnt == VT.getScalarSizeInBits() - 1) {
// Use infinite-precision vector variable shift if supported
return DAG.getNode(X86ISD::VSRAV, SDLoc(N), VT, N0, N1.getOperand(0));
}
if (SDValue V = combineShiftToPMULH(N, DAG, Subtarget)) if (SDValue V = combineShiftToPMULH(N, DAG, Subtarget))
return V; return V;