[all-commits] [llvm/llvm-project] 852459: [NFC][LoopPeel] Add tests for load widening

Guy David via All-commits all-commits at lists.llvm.org
Wed Aug 5 05:13:08 PDT 2026


  Branch: refs/heads/users/guy-david/loop-peel-widen-load
  Home:   https://github.com/llvm/llvm-project
  Commit: 852459d6f9c8f0b155ccacfd091e4d4987040f21
      https://github.com/llvm/llvm-project/commit/852459d6f9c8f0b155ccacfd091e4d4987040f21
  Author: Guy David <guyda96 at gmail.com>
  Date:   2026-08-05 (Wed, 05 Aug 2026)

  Changed paths:
    A llvm/test/Transforms/LoopUnroll/AArch64/peel-last-iteration-load-widening-be.ll
    A llvm/test/Transforms/LoopUnroll/AArch64/peel-last-iteration-load-widening.ll

  Log Message:
  -----------
  [NFC][LoopPeel] Add tests for load widening


  Commit: e85b0c990ba727cc851572571fcd921fcd0b15f5
      https://github.com/llvm/llvm-project/commit/e85b0c990ba727cc851572571fcd921fcd0b15f5
  Author: Guy David <guyda96 at gmail.com>
  Date:   2026-08-05 (Wed, 05 Aug 2026)

  Changed paths:
    M llvm/include/llvm/Analysis/TargetTransformInfo.h
    M llvm/include/llvm/Transforms/Utils/LoopPeel.h
    M llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
    M llvm/lib/Transforms/Utils/LoopPeel.cpp
    M llvm/test/Transforms/LoopUnroll/AArch64/peel-last-iteration-load-widening-be.ll
    A llvm/test/Transforms/LoopUnroll/AArch64/peel-last-iteration-load-widening-disabled.ll
    M llvm/test/Transforms/LoopUnroll/AArch64/peel-last-iteration-load-widening.ll

  Log Message:
  -----------
  [LoopPeel] Peel last iteration to enable load widening

In loops that contain multiple consecutive small loads (e.g., 3 bytes
loading i8's), peeling the last iteration makes it safe to read beyond
the accessed region, enabling the use of a wider load (e.g., b32) for
all other N-1 iterations.

Patterns such as:
```
  %a = load i8, ptr %p
  %b = load i8, ptr %p+1
  %c = load i8, ptr %p+2
  ...
  %p.next = getelementptr i8, ptr %p, 3
```

Can be transformed to:
```
  %wide = load b32, ptr %p     ; Read 4 bytes
  %frozen = freeze b32 %wide
  %value = bitcast b32 %frozen to i32
  %a = trunc
  %b = lshr + trunc
  %c = lshr + trunc
  %p.next = getelementptr i8, ptr %p, 3
  ...
```

The wide load is of a byte type rather than an integer to handle poison
values correctly. Byte values carry poison per bit instead of per value,
so the read-ahead bytes, which the peel makes dereferenceable, cannot
taint the grouped bytes.

This acts as a fallback strategy when vectorization fails and has
significant performance uplifts, most notably in image processing
where processing an RGB buffer is common.

Assisted-by: Opus 4.8


Compare: https://github.com/llvm/llvm-project/compare/f134fb419665...e85b0c990ba7

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