[all-commits] [llvm/llvm-project] ddb46a: [LSR] Don't consider users of constant outside loop
Nikita Popov via All-commits
all-commits at lists.llvm.org
Thu Jul 13 03:22:55 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: ddb46abd3c8b33d7213dd96ec70e1f92336f467e
https://github.com/llvm/llvm-project/commit/ddb46abd3c8b33d7213dd96ec70e1f92336f467e
Author: Nikita Popov <npopov at redhat.com>
Date: 2023-07-13 (Thu, 13 Jul 2023)
Changed paths:
M llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
M llvm/test/Transforms/LoopStrengthReduce/AArch64/lsr-memcpy.ll
Log Message:
-----------
[LSR] Don't consider users of constant outside loop
In CollectLoopInvariantFixupsAndFormulae(), LSR looks at users
outside the loop. E.g. if we have an addrec based on %base, and
%base is also used outside the loop, then we have to keep it in a
register anyway, which may make it more profitable to use
%base + %idx style addressing.
This reasoning doesn't hold up when the base is a constant, because
the constant can be rematerialized. The lsr-memcpy.ll test regressed
when enabling opaque pointers, because inttoptr (i64 6442450944 to ptr)
now also has a use outside the loop (previously it didn't due to a
pointer type difference), and that extra "use" results in worse use
of addressing modes in the loop. However, the use outside the loop
actually gets rematerialized, so the alleged register saving does
not occur.
The same reasoning also applies to other types of constants, such
as global variable references.
Differential Revision: https://reviews.llvm.org/D155073
More information about the All-commits
mailing list