[llvm] [RISCV] Add combine for shadd family of instructions. (PR #130829)
Min-Yih Hsu via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 17 09:44:24 PDT 2025
================
@@ -14318,35 +14317,36 @@ static SDValue transformAddShlImm(SDNode *N, SelectionDAG &DAG,
// or 3.
static bool checkAddiForShift(SDValue AddI, int64_t &AddConst,
int64_t &ShlConst) {
+ using namespace llvm::SDPatternMatch;
// Based on testing it seems that performance degrades if the ADDI has
// more than 2 uses.
if (AddI->use_size() > 2)
return false;
- auto *AddConstNode = dyn_cast<ConstantSDNode>(AddI->getOperand(1));
- if (!AddConstNode)
- return false;
+ APInt AddVal;
+ SDValue SHLVal;
+ sd_match(AddI, m_Add(m_Value(SHLVal), m_ConstInt(AddVal)));
- SDValue SHLVal = AddI->getOperand(0);
- if (SHLVal->getOpcode() != ISD::SHL)
+ APInt VShift;
+ if (!sd_match(SHLVal, m_c_BinOp(ISD::SHL, m_Value(), m_ConstInt(VShift))))
----------------
mshockwave wrote:
shift shouldn't be commutative
https://github.com/llvm/llvm-project/pull/130829
More information about the llvm-commits
mailing list