public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/gccgo] rtl-optimization/93946 - fix TBAA for redundant store removal in CSE
@ 2020-04-10 18:29 Ian Lance Taylor
  0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2020-04-10 18:29 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:dd9ca9d770a18ce4b16d867f49fef3293b483ff5

commit dd9ca9d770a18ce4b16d867f49fef3293b483ff5
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Apr 8 14:04:35 2020 +0200

    rtl-optimization/93946 - fix TBAA for redundant store removal in CSE
    
    It turns out RTL CSE tries to remove redundant stores but fails to
    do the usual validity check what such a change is TBAA neutral to
    later loads.
    
    This now triggers with the PR93946 testcases on nios2.
    
    2020-04-08  Richard Biener  <rguenther@suse.de>
    
            PR rtl-optimization/93946
            * cse.c (cse_insn): Record the tabled expression in
            src_related.  Verify a redundant store removal is valid.

Diff:
---
 gcc/ChangeLog |  6 ++++++
 gcc/cse.c     | 13 +++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ffa8930556d..025a4a67937 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2020-04-08  Richard Biener  <rguenther@suse.de>
+
+	PR rtl-optimization/93946
+	* cse.c (cse_insn): Record the tabled expression in
+	src_related.  Verify a redundant store removal is valid.
+
 2020-04-08  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR target/94417
diff --git a/gcc/cse.c b/gcc/cse.c
index 3e8724b3fed..f07bbdbebad 100644
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -5074,7 +5074,7 @@ cse_insn (rtx_insn *insn)
 	     to prefer it.  Copy it to src_related.  The code below will
 	     then give it a negative cost.  */
 	  if (GET_CODE (dest) == code && rtx_equal_p (p->exp, dest))
-	    src_related = dest;
+	    src_related = p->exp;
 	}
 
       /* Find the cheapest valid equivalent, trying all the available
@@ -5332,7 +5332,16 @@ cse_insn (rtx_insn *insn)
 		   && rtx_equal_p (trial, dest)
 		   && !side_effects_p (dest)
 		   && (cfun->can_delete_dead_exceptions
-		       || insn_nothrow_p (insn)))
+		       || insn_nothrow_p (insn))
+		   /* We can only remove the later store if the earlier aliases
+		      at least all accesses the later one.  */
+		   && (!MEM_P (trial)
+		       || ((MEM_ALIAS_SET (dest) == MEM_ALIAS_SET (trial)
+			    || alias_set_subset_of (MEM_ALIAS_SET (dest),
+						    MEM_ALIAS_SET (trial)))
+			    && (!MEM_EXPR (trial)
+				|| refs_same_for_tbaa_p (MEM_EXPR (trial),
+							 MEM_EXPR (dest))))))
 	    {
 	      SET_SRC (sets[i].rtl) = trial;
 	      noop_insn = true;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-04-10 18:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-10 18:29 [gcc/devel/gccgo] rtl-optimization/93946 - fix TBAA for redundant store removal in CSE Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).