public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-2031] tree-optimization/110332 - fix ICE with phiprop
@ 2023-06-22  8:14 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2023-06-22  8:14 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:2ac41866270e9fbab504bbda7a942a97abaa203a

commit r14-2031-g2ac41866270e9fbab504bbda7a942a97abaa203a
Author: Richard Biener <rguenther@suse.de>
Date:   Thu Jun 22 09:04:01 2023 +0200

    tree-optimization/110332 - fix ICE with phiprop
    
    The following fixes an ICE that occurs when we visit an edge
    inserted load from the code validating correctness for inserting
    an aggregate copy there.  We can simply skip those loads here.
    
            PR tree-optimization/110332
            * tree-ssa-phiprop.cc (propagate_with_phi): Always
            check aliasing with edge inserted loads.
    
            * g++.dg/torture/pr110332.C: New testcase.
            * gcc.dg/torture/pr110332-1.c: Likewise.
            * gcc.dg/torture/pr110332-2.c: Likewise.

Diff:
---
 gcc/testsuite/g++.dg/torture/pr110332.C   | 16 ++++++++++++++++
 gcc/testsuite/gcc.dg/torture/pr110332-1.c | 13 +++++++++++++
 gcc/testsuite/gcc.dg/torture/pr110332-2.c | 10 ++++++++++
 gcc/tree-ssa-phiprop.cc                   | 10 +++++++---
 4 files changed, 46 insertions(+), 3 deletions(-)

diff --git a/gcc/testsuite/g++.dg/torture/pr110332.C b/gcc/testsuite/g++.dg/torture/pr110332.C
new file mode 100644
index 00000000000..31dc93ecee4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr110332.C
@@ -0,0 +1,16 @@
+// { dg-do compile }
+
+struct SlotIndex { int lie; };
+SlotIndex si7, si8;
+
+unsigned u9, u6;
+bool b3, b4;
+unsigned &value() {
+  return b4 ? u6 : u9;
+}
+void transferValues() {
+  unsigned RegIdx;
+  SlotIndex End;
+  RegIdx = value();
+  End = b3 ? si7 : si8;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr110332-1.c b/gcc/testsuite/gcc.dg/torture/pr110332-1.c
new file mode 100644
index 00000000000..438993e8daf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr110332-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+struct s { int lie; };
+struct s si7, si8;
+unsigned u9, u6;
+_Bool b3, b4;
+unsigned transferValues(struct s *End) {
+  unsigned RegIdx;
+  unsigned *t = b4 ? &u6 : &u9;
+  RegIdx = *t;
+  *End = *(b3 ? &si7 : &si8);
+  return RegIdx;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr110332-2.c b/gcc/testsuite/gcc.dg/torture/pr110332-2.c
new file mode 100644
index 00000000000..18b656ffb2d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr110332-2.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+
+_Bool a;
+struct s { int t; } c, d;
+unsigned e, f;
+unsigned transferValues(struct s *End) {
+  unsigned RegIdx = *(a ? &e : &f);
+  *End = *(a ? &c : &d);
+  return RegIdx;
+}
diff --git a/gcc/tree-ssa-phiprop.cc b/gcc/tree-ssa-phiprop.cc
index 21a349a25e2..8c9ce903472 100644
--- a/gcc/tree-ssa-phiprop.cc
+++ b/gcc/tree-ssa-phiprop.cc
@@ -399,14 +399,18 @@ propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn,
 	     there are no statements that could read from memory
 	     aliasing the lhs in between the start of bb and use_stmt.
 	     As we require use_stmt to have a VDEF above, loads after
-	     use_stmt will use a different virtual SSA_NAME.  */
+	     use_stmt will use a different virtual SSA_NAME.  When
+	     we reach an edge inserted load the constraints we place
+	     on processing guarantees that program order is preserved
+	     so we can avoid checking those.  */
 	  FOR_EACH_IMM_USE_FAST (vuse_p, vui, vuse)
 	    {
 	      vuse_stmt = USE_STMT (vuse_p);
 	      if (vuse_stmt == use_stmt)
 		continue;
-	      if (!dominated_by_p (CDI_DOMINATORS,
-				   gimple_bb (vuse_stmt), bb))
+	      if (!gimple_bb (vuse_stmt)
+		  || !dominated_by_p (CDI_DOMINATORS,
+				      gimple_bb (vuse_stmt), bb))
 		continue;
 	      if (ref_maybe_used_by_stmt_p (vuse_stmt,
 					    gimple_assign_lhs (use_stmt)))

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

only message in thread, other threads:[~2023-06-22  8:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-22  8:14 [gcc r14-2031] tree-optimization/110332 - fix ICE with phiprop Richard Biener

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).