[llvm] Add MUL/SHL handling in decomposeLinearExpression (PR #222574)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 17 03:29:43 PDT 2026


================
@@ -935,6 +937,26 @@ LinearExpression llvm::decomposeLinearExpression(const DataLayout &DL,
       VarIndex = Index;
     }
 
+    APInt IndexScale(BitWidth, 1);
+    while (auto *BO = dyn_cast_or_null<BinaryOperator>(VarIndex)) {
+      Value *UnscaledIndex = nullptr;
+      APInt Factor(BitWidth, 0);
+      ConstantInt *Constant;
+      if (match(BO, m_c_Mul(m_Value(UnscaledIndex), m_ConstantInt(Constant)))) {
----------------
nikic wrote:

```suggestion
      if (match(BO, m_Mul(m_Value(UnscaledIndex), m_Constant(Constant)))) {
```
and use m_APInt instead of m_Constant.

https://github.com/llvm/llvm-project/pull/222574


More information about the llvm-commits mailing list