[all-commits] [llvm/llvm-project] 87ddd3: [LAA] Rename and fix semantics of MaxSafeDepDistBy...

Michael Maitland via All-commits all-commits at lists.llvm.org
Wed Aug 16 09:54:04 PDT 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 87ddd3a191321c41045b1b9d737583e27a3f6c2a
  Author: Michael Maitland <michaeltmaitland at gmail.com>
  Date:   2023-08-16 (Wed, 16 Aug 2023)

  Changed paths:
    M llvm/include/llvm/Analysis/LoopAccessAnalysis.h
    M llvm/lib/Analysis/LoopAccessAnalysis.cpp
    M llvm/test/Analysis/LoopAccessAnalysis/depend_diff_types.ll
    M llvm/test/Analysis/LoopAccessAnalysis/depend_diff_types_opaque_ptr.ll
    M llvm/test/Analysis/LoopAccessAnalysis/max_safe_dep_dist_non_unit_stride.ll
    M llvm/test/Analysis/LoopAccessAnalysis/safe-with-dep-distance.ll

  Log Message:
  [LAA] Rename and fix semantics of MaxSafeDepDistBytes to MinDepDistBytes

`MaxSafeDepDistBytes` was not correct based on its name an semantics
in instances when there was a non-unit stride loop. For example,

for (int k = 0; k < len; k+=3) {
  a[k] = a[k+4];
  a[k+2] = a[k+6];

Here, the smallest dependence distance is 24 bytes, but only vectorizing 8 bytes
is safe. `MaxSafeVectorWidthInBits` reported the correct number of bits
that could be vectorized as 64 bits.

The semantics of of `MaxSafeDepDistBytes` should be:
  The smallest dependence distance in bytes in the loop. This may not be
  the same as the maximum number of bytes that are safe to operate on

The name of this variable should reflect those semantics and
its docstring should be updated accordingly, `MinDepDistBytes`.

A debug message that used `MaxSafeDepDistBytes` to signify to the user
how many bytes could be accessed in parallel is updated to use
`MaxSafeVectorWidthInBits` instead. That way, the same message if
communicated to the user, just in different units.

This patch makes sure that when `MinDepDistBytes` is modified in a way
that should impact `MaxSafeVectorWidthInBits`, that we update the latter
accordingly. This patch also clarifies why `MaxSafeVectorWidthInBits`
does not to be updated when `MinDepDistBytes` is (i.e. in the case of a
forward dependency).

Differential Revision: https://reviews.llvm.org/D156158

More information about the All-commits mailing list