[all-commits] [llvm/llvm-project] ca4886: [LoongArch] Impl TTI hooks for LoongArch to suppor...

ZhaoQi via All-commits all-commits at lists.llvm.org
Mon Jan 20 00:20:37 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ca4886bf96f0b6dcc151c03bd8c7df414f3f659b
      https://github.com/llvm/llvm-project/commit/ca4886bf96f0b6dcc151c03bd8c7df414f3f659b
  Author: ZhaoQi <zhaoqi01 at loongson.cn>
  Date:   2025-01-20 (Mon, 20 Jan 2025)

  Changed paths:
    M llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.cpp
    M llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.h
    M llvm/test/Transforms/LoopDataPrefetch/LoongArch/basic.ll

  Log Message:
  -----------
  [LoongArch] Impl TTI hooks for LoongArch to support LoopDataPrefetch pass (#118437)

Inspired by https://reviews.llvm.org/D146600, this commit adds
some TTI hooks for LoongArch to make LoopDataPrefetch pass
really work. Including:

- `getCacheLineSize()`: 64 for loongarch64.
- `getPrefetchDistance()`: After testing SPEC CPU 2017, improvements
taken by prefetching are more obvious when set PrefetchDistance to
200(results shown blow), although different benchmarks fit for different
best choice.
- `enableWritePrefetching()`: store prefetch is supported by LoongArch,
so set WritePrefetching to true in default.
- `getMinPrefetchStride()` and `getMaxPrefetchIterationsAhead()` still
use default values: 1 and UINT_MAX, so not override them.

After this commit, the test added by https://reviews.llvm.org/D146600
can generate llvm.prefetch intrinsic IR correctly.

Results of spec2017rate benchmarks (testing date: ref, copies: 1):
- For all C/C++ benchmarks, compared to O3+novec/lsx/lasx, prefetch can
bring about -1.58%/0.31%/0.07% performance improvement for int
benchmarks and 3.26%/3.73%/3.78% improvement for floating point
benchmarks. (Only O3+novec+prefetch decreases when testing intrate.)
- But prefetch results in performance reduction almost for every Fortran
benchmark compiled by flang. While considering all C/C++/Fortran
benchmarks, prefetch performance will decrease about 1% ~ 5%.

FIXME: Keep `loongarch-enable-loop-data-prefetch` option default to
false for now due to the bad effect for Fortran.



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