[all-commits] [llvm/llvm-project] e40659: [SROA] Canonicalize homogeneous structs to fixed v...
Yaxun (Sam) Liu via All-commits
all-commits at lists.llvm.org
Mon Jun 1 09:37:47 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: e4065977f3de2b3518cad25a9ad07030610edd79
https://github.com/llvm/llvm-project/commit/e4065977f3de2b3518cad25a9ad07030610edd79
Author: Yaxun (Sam) Liu <yaxun.liu at amd.com>
Date: 2026-06-01 (Mon, 01 Jun 2026)
Changed paths:
M llvm/include/llvm/Transforms/Scalar.h
M llvm/include/llvm/Transforms/Scalar/SROA.h
M llvm/lib/Passes/PassBuilder.cpp
M llvm/lib/Passes/PassBuilderPipelines.cpp
M llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
M llvm/lib/Transforms/Scalar/SROA.cpp
M llvm/test/CodeGen/NVPTX/lower-byval-args.ll
A llvm/test/Transforms/PhaseOrdering/struct-to-vector-before-memcpyopt.ll
A llvm/test/Transforms/SROA/struct-to-vector-fp-store-only-tail.ll
A llvm/test/Transforms/SROA/struct-to-vector-subpartition.ll
A llvm/test/Transforms/SROA/struct-to-vector.ll
Log Message:
-----------
[SROA] Canonicalize homogeneous structs to fixed vectors (opt-in, after memcpyopt) (#165159)
SROA sometimes keeps temporary allocas around for homogeneous structs
like
`{ i32, i32, i32, i32 }` because the partition has only memcpy/memset
traffic
and no scalar typed users to drive vector promotion. On targets like
AMDGPU
these allocas turn into scratch memory and hurt performance. This PR
adds a
helper `tryCanonicalizeStructToVector` that converts such a partition to
a
fixed vector type when every non-debug, non-lifetime user is a memory
intrinsic, so the alloca can promote through normal vector load/store
paths.
The element-shape rule accepts any homogeneous element count, any
integer
width, any FP type, and integral pointer types, as long as the struct is
tightly packed.
Canonicalization is gated behind a new per-pass option
`canonicalize-struct-to-vector` on `SROAOptions`, off by default. Only
the
late SROA passes in `addVectorPasses` (new PM, non-LTO and FullLTO) and
the
two legacy-PM SROAs in NVPTX enable it, so it always runs after
`MemCpyOptPass`. Running it earlier can hide memcpy chains that
memcpyopt
would otherwise collapse, and can also emit wide stores whose suffix
lanes
are undef when only part of a struct was initialized. Both hazards are
covered by new tests `struct-to-vector-before-memcpyopt.ll` and
`struct-to-vector-fp-store-only-tail.ll`. The opt-in design and the
"after memcpyopt" placement come from @YonahGoldberg's refactor, which
removed every regression reported in earlier benchmark runs (see
dtcxzyw/llvm-opt-benchmark-nightly#306). AMDGPU inherits the new-PM
opt-ins
automatically; other targets keep upstream-main SROA behavior unless
they
opt in.
Co-authored-by: Yonah Goldberg <ygoldberg at nvidia.com>
---------
Co-authored-by: Yonah Goldberg <ygoldberg at nvidia.com>
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