|
38 | 38 | #include "llvm/CodeGen/MachineLoopInfo.h"
|
39 | 39 | #include "llvm/CodeGen/MachineModuleInfo.h"
|
40 | 40 | #include "llvm/CodeGen/MachineRegisterInfo.h"
|
| 41 | +#include "llvm/CodeGen/SDPatternMatch.h" |
41 | 42 | #include "llvm/CodeGen/TargetLowering.h"
|
42 | 43 | #include "llvm/CodeGen/WinEHFuncInfo.h"
|
43 | 44 | #include "llvm/IR/CallingConv.h"
|
@@ -48084,22 +48085,22 @@ static SDValue combineShiftLeft(SDNode *N, SelectionDAG &DAG,
|
48084 | 48085 |
|
48085 | 48086 | static SDValue combineShiftRightArithmetic(SDNode *N, SelectionDAG &DAG,
|
48086 | 48087 | const X86Subtarget &Subtarget) {
|
| 48088 | + using namespace llvm::SDPatternMatch; |
48087 | 48089 | SDValue N0 = N->getOperand(0);
|
48088 | 48090 | SDValue N1 = N->getOperand(1);
|
48089 | 48091 | EVT VT = N0.getValueType();
|
48090 | 48092 | unsigned Size = VT.getSizeInBits();
|
| 48093 | + SDLoc DL(N); |
48091 | 48094 |
|
48092 | 48095 | if (SDValue V = combineShiftToPMULH(N, DAG, Subtarget))
|
48093 | 48096 | return V;
|
48094 | 48097 |
|
48095 |
| - APInt ShiftAmt; |
48096 |
| - if (supportedVectorVarShift(VT, Subtarget, ISD::SRA) && |
48097 |
| - N1.getOpcode() == ISD::UMIN && |
48098 |
| - ISD::isConstantSplatVector(N1.getOperand(1).getNode(), ShiftAmt) && |
48099 |
| - ShiftAmt == VT.getScalarSizeInBits() - 1) { |
48100 |
| - SDValue ShrAmtVal = N1.getOperand(0); |
48101 |
| - SDLoc DL(N); |
48102 |
| - return DAG.getNode(X86ISD::VSRAV, DL, N->getVTList(), N0, ShrAmtVal); |
| 48098 | + // fold sra(x,umin(amt,bw-1)) -> avx2 psrav(x,amt) |
| 48099 | + if (supportedVectorVarShift(VT, Subtarget, ISD::SRA)) { |
| 48100 | + SDValue ShrAmtVal; |
| 48101 | + if (sd_match(N1, m_UMin(m_Value(ShrAmtVal), |
| 48102 | + m_SpecificInt(VT.getScalarSizeInBits() - 1)))) |
| 48103 | + return DAG.getNode(X86ISD::VSRAV, DL, VT, N0, ShrAmtVal); |
48103 | 48104 | }
|
48104 | 48105 |
|
48105 | 48106 | // fold (SRA (SHL X, ShlConst), SraConst)
|
@@ -48137,7 +48138,6 @@ static SDValue combineShiftRightArithmetic(SDNode *N, SelectionDAG &DAG,
|
48137 | 48138 | // Only deal with (Size - ShlConst) being equal to 8, 16 or 32.
|
48138 | 48139 | if (ShiftSize >= Size || ShlConst != Size - ShiftSize)
|
48139 | 48140 | continue;
|
48140 |
| - SDLoc DL(N); |
48141 | 48141 | SDValue NN =
|
48142 | 48142 | DAG.getNode(ISD::SIGN_EXTEND_INREG, DL, VT, N00, DAG.getValueType(SVT));
|
48143 | 48143 | if (SraConst.eq(ShlConst))
|
|
0 commit comments