[PATCH] D148622: [LoongArch] Prefer to align functions and tight loops to 16 bytes

WÁNG Xuěruì via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 18 02:20:21 PDT 2023


xen0n created this revision.
xen0n added reviewers: SixWeining, wangleiat, xry111, gonglingqin, benshi001.
Herald added a subscriber: hiraditya.
Herald added a project: All.
xen0n requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The LA464 micro-architecture is very sensitive to alignment of tight
loops, with performance variation of up to ~12% in the go1 benchmark
suite of the Go language (as observed by me during my work on the Go
loong64 port).
[ Manual alignment of certain loops | https://go.dev/cl/479816 ] and
[ automatic alignment of loop heads | https://go.dev/cl/479817 ] helps
a lot there, so we naturally want to do the same.

Practically, LA464 is the only LoongArch micro-architecture in wide use,
and we are currently supporting just that. The first "4" in "LA464"
stands for "4-issue", meaning the micro-architecture's instruction fetch
and decode are 4-wide, so its preferred function and loop alignment is
initially set to 16. Max loop size for alignment consideration is also
conservatively set to 16, although without concrete numbers to back the
decision. (I don't have access to a SPEC CPU suite, for example.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148622

Files:
  llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
  llvm/lib/Target/LoongArch/LoongArchSubtarget.cpp
  llvm/lib/Target/LoongArch/LoongArchSubtarget.h
  llvm/test/CodeGen/LoongArch/atomicrmw-uinc-udec-wrap.ll
  llvm/test/CodeGen/LoongArch/ir-instruction/atomicrmw-fp.ll
  llvm/test/CodeGen/LoongArch/ir-instruction/br.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148622.514574.patch
Type: text/x-patch
Size: 11531 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230418/28f82ad5/attachment.bin>


More information about the llvm-commits mailing list