]> gcc.gnu.org Git - gcc.git/commit
cselib: add function to check if SET is redundant [PR106187]
authorRichard Earnshaw <rearnsha@arm.com>
Wed, 3 Aug 2022 09:01:51 +0000 (10:01 +0100)
committerRichard Earnshaw <rearnsha@arm.com>
Fri, 2 Sep 2022 11:25:03 +0000 (12:25 +0100)
commit3835765ae96d294bb71dd8cb05db543d89725f7b
tree81a227171e40a0d4fc41b082e11cfdf555f3e06f
parentde1ba234311b935b1a38d512e57329d4b6e8354d
cselib: add function to check if SET is redundant [PR106187]

A SET operation that writes memory may have the same value as an
earlier store but if the alias sets of the new and earlier store do
not conflict then the set is not truly redundant.  This can happen,
for example, if objects of different types share a stack slot.

To fix this we define a new function in cselib that first checks for
equality and if that is successful then finds the earlier store in the
value history and checks the alias sets.

The routine is used in two places elsewhere in the compiler:
cfgcleanup and postreload.

gcc/ChangeLog:

PR rtl-optimization/106187
* alias.h (mems_same_for_tbaa_p): Declare.
* alias.cc (mems_same_for_tbaa_p): New function.
* dse.cc (record_store): Use it instead of open-coding
alias check.
* cselib.h (cselib_redundant_set_p): Declare.
* cselib.cc: Include alias.h
(cselib_redundant_set_p): New function.
* cfgcleanup.cc: (mark_effect): Use cselib_redundant_set_p instead
of rtx_equal_for_cselib_p.
* postreload.cc (reload_cse_simplify): Use cselib_redundant_set_p.
(reload_cse_noop_set_p): Delete.

(cherry picked from commit 64ce76d940501cb04d14a0d36752b4f93473531c)
gcc/alias.cc
gcc/alias.h
gcc/cfgcleanup.cc
gcc/cselib.cc
gcc/cselib.h
gcc/dse.cc
gcc/postreload.cc
This page took 0.061945 seconds and 6 git commands to generate.