[llvm] [VPlan] Add SCEV support for abs intrinsic (PR #195678)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Mon May 4 10:53:57 PDT 2026


================
@@ -258,6 +258,13 @@ const SCEV *vputils::getSCEVExprForVPValue(const VPValue *V,
     return CreateSCEV({LHSVal, RHSVal}, [&](ArrayRef<SCEVUse> Ops) {
       return SE.getSMinExpr(Ops[0], Ops[1]);
     });
+  const APInt *IsIntMinPoison;
+  if (match(V, m_Intrinsic<Intrinsic::abs>(m_VPValue(LHSVal),
+                                           m_APInt(IsIntMinPoison))) &&
+      IsIntMinPoison->getBitWidth() == 1)
+    return CreateSCEV({LHSVal}, [&](ArrayRef<SCEVUse> Ops) {
+      return SE.getAbsExpr(Ops[0], IsIntMinPoison->isOne());
----------------
efriedma-quic wrote:

IsNSW is a really strong assertion: it's asserting that the value in question is never INT_MIN in any context (not just inside the vectorized loop, but potentially across the whole function).  I don't think that's correct here.

(This might change in the future with SCEVUse.)

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


More information about the llvm-commits mailing list