[llvm] [X86][AVX] Fix handling of out-of-bounds shift amounts in AVX2 vector shift nodes (PR #84426)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 11 02:52:16 PDT 2024
================
@@ -47291,6 +47291,16 @@ static SDValue combineShiftRightArithmetic(SDNode *N, SelectionDAG &DAG,
if (SDValue V = combineShiftToPMULH(N, DAG, Subtarget))
return V;
+ APInt ShiftAmt;
+ SDNode *UMinNode = N1.getNode();
+ if (UMinNode->getOpcode() == ISD::UMIN &&
+ ISD::isConstantSplatVector(UMinNode->getOperand(1).getNode(), ShiftAmt) &&
+ ShiftAmt == VT.getScalarSizeInBits() - 1) {
+ SDValue ShrAmtVal = UMinNode->getOperand(0);
+ SDLoc DL(N);
+ return DAG.getNode(N->getOpcode(), DL, N->getVTList(), N0, ShrAmtVal);
----------------
SahilPatidar wrote:
Okay, here is the modified code:
```cpp
if (supportedVectorShiftWithImm(VT, Subtarget, ISD::SRA) &&
UMinNode->getOpcode() == ISD::UMIN &&
ISD::isConstantSplatVector(UMinNode->getOperand(1).getNode(), ShiftAmt) &&
ShiftAmt == VT.getScalarSizeInBits() - 1) {
SDValue ShrAmtVal = UMinNode->getOperand(0);
SDLoc DL(N);
return DAG.getNode(X86ISD::VSRAV, DL, N->getVTList(), N0, ShrAmtVal);
}
```
With this code, it still crashes.
https://github.com/llvm/llvm-project/pull/84426
More information about the llvm-commits
mailing list