diff options
author | Florian Hahn <flo@fhahn.com> | 2024-04-12 22:07:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-12 22:07:29 +0100 |
commit | 0f82469314f34a086669dfcd190a9f89260fbee5 (patch) | |
tree | 9e705e4477681396a91b9f16a74a2c27b4e2402d /llvm/lib/Support/APInt.cpp | |
parent | 8a4b7de91dc334c828674aa2cad927c6ffb9cf37 (diff) | |
download | llvm-0f82469314f34a086669dfcd190a9f89260fbee5.zip llvm-0f82469314f34a086669dfcd190a9f89260fbee5.tar.gz llvm-0f82469314f34a086669dfcd190a9f89260fbee5.tar.bz2 |
[Passes] Run SimpleLoopUnswitch after introducing invariant branches. (#81271)
IndVars may be able to replace a loop dependent condition with a loop
invariant one, but loop-unswitch runs before IndVars, so the invariant
check remains in the loop.
For an example, consider a read-only loop with a bounds check:
https://godbolt.org/z/8cdj4qhbG
This patch uses a approach similar to the way extra cleanup passes are
run on demand after vectorization (added in acea6e9cfa4c4a0e8678c7).
It introduces a new ShouldRunExtraSimpleLoopUnswitch analysis marker,
which IndVars can use to indicate that extra unswitching is beneficial.
ExtraSimpleLoopUnswitchPassManager uses this analysis to determine
whether to run its passes on a loop.
Compile-time impact (geomean) ranges from +0.0% to 0.02%
https://llvm-compile-time-tracker.com/compare.php?from=138c0beb109ffe47f75a0fe8c4dc2cdabe8a6532&to=19e6e99eeb280d426907ea73a21b139ba7225627&stat=instructions%3Au
Compile-time impact (geomean) of unconditionally running
SimpleLoopUnswitch ranges from +0.05% - +0.16%
https://llvm-compile-time-tracker.com/compare.php?from=138c0beb109ffe47f75a0fe8c4dc2cdabe8a6532&to=2930dfd5accdce2e6f8d5146ae4d626add2065a2&stat=instructions:u
Unconditionally running SimpleLoopUnswitch seems to indicate that there
are multiple other scenarios where we fail to run unswitching when
opportunities remain.
Fixes https://github.com/llvm/llvm-project/issues/85551.
PR: https://github.com/llvm/llvm-project/pull/81271
Diffstat (limited to 'llvm/lib/Support/APInt.cpp')
0 files changed, 0 insertions, 0 deletions