[all-commits] [llvm/llvm-project] 309843: [DA] Fix absolute value calculation (#164967)

Ryotaro Kasuga via All-commits all-commits at lists.llvm.org
Fri Oct 24 08:42:49 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 30984358ff94f3f71f4ac50ea58f6ab32ccc7c23
      https://github.com/llvm/llvm-project/commit/30984358ff94f3f71f4ac50ea58f6ab32ccc7c23
  Author: Ryotaro Kasuga <kasuga.ryotaro at fujitsu.com>
  Date:   2025-10-25 (Sat, 25 Oct 2025)

  Changed paths:
    M llvm/lib/Analysis/DependenceAnalysis.cpp
    A llvm/test/Analysis/DependenceAnalysis/compute-absolute-value.ll

  Log Message:
  -----------
  [DA] Fix absolute value calculation (#164967)

This patch fixes the computation of the absolute value for SCEV.
Previously, it was calculated as `AbsX = SE->isKnownNonNegative(X) ? X :
-X`, which would incorrectly assume that `!isKnownNonNegative` implies
`isKnownNegative`. This assumption does not hold in general, for
example, when `X` is a `SCEVUnknown` and it can be an arbitrary value.
To compute the absolute value properly, we should use
ScalarEvolution::getAbsExpr instead.

Fix #149977



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list