diff mbox series

store-merging: Fix up -fnon-call-exceptions handling [PR94224]

Message ID 20200320082653.GT2156@tucnak
State New
Headers show
Series store-merging: Fix up -fnon-call-exceptions handling [PR94224] | expand

Commit Message

Li, Pan2 via Gcc-patches March 20, 2020, 8:26 a.m. UTC
Hi!

When we are adding a single store into a store group, we are already
checking that store->lp_nr matches, but we have also code to add further
INTEGER_CST stores into the group right away if the ordering requires that
either we put there all or none from a certain set of stores.  And in those
cases we weren't doing these lp_nr checks, which means we could end up with
stores with different lp_nr in the same group, which then ICEs during
output_merged_store.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2020-03-20  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/94224
	* gimple-ssa-store-merging.c
	(imm_store_chain_info::coalesce_immediate): Don't consider overlapping
	or adjacent INTEGER_CST rhs_code stores as mergeable if they have
	different lp_nr.

	* g++.dg/tree-ssa/pr94224.C: New test.


	Jakub

Comments

Richard Biener March 20, 2020, 8:32 a.m. UTC | #1
On Fri, 20 Mar 2020, Jakub Jelinek wrote:

> Hi!
> 
> When we are adding a single store into a store group, we are already
> checking that store->lp_nr matches, but we have also code to add further
> INTEGER_CST stores into the group right away if the ordering requires that
> either we put there all or none from a certain set of stores.  And in those
> cases we weren't doing these lp_nr checks, which means we could end up with
> stores with different lp_nr in the same group, which then ICEs during
> output_merged_store.
> 
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?

OK.

> 2020-03-20  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR tree-optimization/94224
> 	* gimple-ssa-store-merging.c
> 	(imm_store_chain_info::coalesce_immediate): Don't consider overlapping
> 	or adjacent INTEGER_CST rhs_code stores as mergeable if they have
> 	different lp_nr.
> 
> 	* g++.dg/tree-ssa/pr94224.C: New test.
> 
> --- gcc/gimple-ssa-store-merging.c.jj	2020-03-17 13:50:52.711936792 +0100
> +++ gcc/gimple-ssa-store-merging.c	2020-03-19 17:37:06.218620323 +0100
> @@ -2773,7 +2773,8 @@ imm_store_chain_info::coalesce_immediate
>  			    break;
>  			  if (info2->order < try_order)
>  			    {
> -			      if (info2->rhs_code != INTEGER_CST)
> +			      if (info2->rhs_code != INTEGER_CST
> +				  || info2->lp_nr != merged_store->lp_nr)
>  				{
>  				  /* Normally check_no_overlap makes sure this
>  				     doesn't happen, but if end grows below,
> @@ -2791,6 +2792,7 @@ imm_store_chain_info::coalesce_immediate
>  					      info2->bitpos + info2->bitsize);
>  			    }
>  			  else if (info2->rhs_code == INTEGER_CST
> +				   && info2->lp_nr == merged_store->lp_nr
>  				   && !last_iter)
>  			    {
>  			      max_order = MAX (max_order, info2->order + 1);
> --- gcc/testsuite/g++.dg/tree-ssa/pr94224.C.jj	2020-03-19 17:45:38.306123576 +0100
> +++ gcc/testsuite/g++.dg/tree-ssa/pr94224.C	2020-03-19 17:44:53.872774065 +0100
> @@ -0,0 +1,34 @@
> +// PR tree-optimization/94224
> +// { dg-do compile }
> +// { dg-options "-O2 -fnon-call-exceptions -Wno-return-type" }
> +
> +void foo (int, int, long);
> +
> +static inline int
> +bar (int &x)
> +{
> +  x = 0;
> +}
> +
> +struct U
> +{
> +  int n, p;
> +  long q;
> +  bool *z;
> +  int a;
> +  U () : n (), z (), a (1) {}
> +  ~U () { if (n) foo (p, n, q); }
> +  void baz () { bar (a); }
> +};
> +
> +struct W
> +{
> +  U w[2];
> +  W () { w[0].baz (); }
> +};
> +
> +void
> +qux ()
> +{
> +  new W;
> +}
> 
> 	Jakub
> 
>
diff mbox series

Patch

--- gcc/gimple-ssa-store-merging.c.jj	2020-03-17 13:50:52.711936792 +0100
+++ gcc/gimple-ssa-store-merging.c	2020-03-19 17:37:06.218620323 +0100
@@ -2773,7 +2773,8 @@  imm_store_chain_info::coalesce_immediate
 			    break;
 			  if (info2->order < try_order)
 			    {
-			      if (info2->rhs_code != INTEGER_CST)
+			      if (info2->rhs_code != INTEGER_CST
+				  || info2->lp_nr != merged_store->lp_nr)
 				{
 				  /* Normally check_no_overlap makes sure this
 				     doesn't happen, but if end grows below,
@@ -2791,6 +2792,7 @@  imm_store_chain_info::coalesce_immediate
 					      info2->bitpos + info2->bitsize);
 			    }
 			  else if (info2->rhs_code == INTEGER_CST
+				   && info2->lp_nr == merged_store->lp_nr
 				   && !last_iter)
 			    {
 			      max_order = MAX (max_order, info2->order + 1);
--- gcc/testsuite/g++.dg/tree-ssa/pr94224.C.jj	2020-03-19 17:45:38.306123576 +0100
+++ gcc/testsuite/g++.dg/tree-ssa/pr94224.C	2020-03-19 17:44:53.872774065 +0100
@@ -0,0 +1,34 @@ 
+// PR tree-optimization/94224
+// { dg-do compile }
+// { dg-options "-O2 -fnon-call-exceptions -Wno-return-type" }
+
+void foo (int, int, long);
+
+static inline int
+bar (int &x)
+{
+  x = 0;
+}
+
+struct U
+{
+  int n, p;
+  long q;
+  bool *z;
+  int a;
+  U () : n (), z (), a (1) {}
+  ~U () { if (n) foo (p, n, q); }
+  void baz () { bar (a); }
+};
+
+struct W
+{
+  U w[2];
+  W () { w[0].baz (); }
+};
+
+void
+qux ()
+{
+  new W;
+}