]> git.ipfire.org Git - thirdparty/gcc.git/commit
DSE: Use the constant store source if possible
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 18 May 2022 20:00:47 +0000 (13:00 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 1 Jun 2022 21:23:26 +0000 (14:23 -0700)
commita743a72714fc4a9d7036d28d0cacdf2a3621f629
tree4a2da93e3ac20ae6f5be420e5792cc84a6f2f3ad
parente2e471d83d16449a325315c0f33dc52b90ce0fac
DSE: Use the constant store source if possible

RTL DSE tracks redundant constant stores within a basic block.  When RTL
loop invariant motion hoists a constant initialization out of the loop
into a separate basic block, the constant store value becomes unknown
within the original basic block.  When recording store for RTL DSE, check
if the source register is set only once to a constant by a non-partial
unconditional load.  If yes, record the constant as the constant store
source.  It eliminates unrolled zero stores after memset 0 in a loop
where a vector register is used as the zero store source.

gcc/

PR rtl-optimization/105638
* df-core.cc (df_find_single_def_src): Moved and renamed from
find_single_def_src in loop-iv.cc.  Change the argument to rtx
and use rtx_equal_p.  Return null for partial or conditional
defs.
* df.h (df_find_single_def_src): New prototype.
* dse.cc (record_store): Use the constant source if the source
register is set only once.
* loop-iv.cc (find_single_def_src): Moved to df-core.cc.
(replace_single_def_regs): Replace find_single_def_src with
df_find_single_def_src.

gcc/testsuite/

PR rtl-optimization/105638
* g++.target/i386/pr105638.C: New test.
gcc/df-core.cc
gcc/df.h
gcc/dse.cc
gcc/loop-iv.cc
gcc/testsuite/g++.target/i386/pr105638.C [new file with mode: 0644]