[llvm] [VPlan] Recognize lshr in getSCEVExprForVPValue. (PR #203496)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 14 20:43:52 PDT 2026


================
@@ -228,6 +228,14 @@ const SCEV *vputils::getSCEVExprForVPValue(const VPValue *V,
       return SE.getMulExpr(Ops[0],
                            SE.getPowerOfTwo(Ops[0]->getType(), ShiftAmt));
     });
+  if (match(V, m_LShr(m_VPValue(LHSVal), m_ConstantInt(ShiftAmt)))) {
+    Type *Ty = V->getScalarType();
+    if (ShiftAmt < SE.getTypeSizeInBits(Ty))
+      return CreateSCEV(LHSVal, [&](ArrayRef<SCEVUse> Ops) {
+        return SE.getUDivExpr(Ops[0],
+                              SE.getPowerOfTwo(Ops[0]->getType(), ShiftAmt));
----------------
lukel97 wrote:

Can this be
```suggestion
                              SE.getPowerOfTwo(V, ShiftAmt));
```

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


More information about the llvm-commits mailing list