[all-commits] [llvm/llvm-project] 3cd6b8: [MachinePipeliner] Use AliasAnalysis properly when...

Ryotaro Kasuga via All-commits all-commits at lists.llvm.org
Wed Apr 23 02:11:57 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3cd6b86cc1e1fd1d8d62ca1bcb8498362a4f7b68
      https://github.com/llvm/llvm-project/commit/3cd6b86cc1e1fd1d8d62ca1bcb8498362a4f7b68
  Author: Ryotaro Kasuga <kasuga.ryotaro at fujitsu.com>
  Date:   2025-04-23 (Wed, 23 Apr 2025)

  Changed paths:
    M llvm/include/llvm/CodeGen/MachinePipeliner.h
    M llvm/lib/CodeGen/MachinePipeliner.cpp
    A llvm/test/CodeGen/Hexagon/swp-alias-cross-iteration.mir
    A llvm/test/CodeGen/Hexagon/swp-no-alias.mir

  Log Message:
  -----------
  [MachinePipeliner] Use AliasAnalysis properly when analyzing loop-carried dependencies (#136691)

MachinePipeliner uses AliasAnalysis to collect loop-carried memory
dependencies. To analyze loop-carried dependencies, we need to
explicitly tell AliasAnalysis that the values may come from different
iterations. Before this patch, MachinePipeliner didn't do this, so some
loop-carried dependencies might be missed. For example, in the following
case, there is a loop-carried dependency from the load to the store, but
it wasn't considered.

```
def @f(ptr noalias %p0, ptr noalias %p1) {
entry:
  br label %body

loop:
  %idx0 = phi ptr [ %p0, %entry ], [ %p1, %body ]
  %idx1 = phi ptr [ %p1, %entry ], [ %p0, %body ]
  %v0 = load %idx0
  ...
  store %v1, %idx1
  ...
}
```

Further, the handling of the underlying objects was not sound. If there
is no information about memory operands (i.e., `memoperands()` is
empty), it must be handled conservatively. However, Machinepipeliner
uses a dummy value (namely `UnknownValue`). It is distinguished from
other "known" objects, causing necessary dependencies to be missed.
(NOTE: in such cases, `buildSchedGraph` adds non-loop-carried
dependencies correctly, so perhaps a critical problem has not occurred.)

This patch fixes the above problems. This change has increased false
dependencies that didn't exist before. Therefore, this patch also
introduces additional alias checks with the underlying objects.

Split off from #135148



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