Fix PR tree-optimization/86990

Message ID 3060399.xauHP6aoJ4@polaris
State New
Headers show
Series
  • Fix PR tree-optimization/86990
Related show

Commit Message

Eric Botcazou Sept. 17, 2018, 7:10 a.m.
Hi,

this is a regression present on the mainline only: now that the GIMPLE store 
merging pass is able to mix constants and SSA_NAMEs on the RHS of stores to 
bit-fields, we need to check that the entire merged store group is made of 
constants only when encountering overlapping stores.

Tested on x86_64-suse-linux, OK for the mainline?


2018-09-17  Eric Botcazou  <ebotcazou@adacore.com>

	PR tree-optimization/86990
	* gimple-ssa-store-merging.c (imm_store_chain_info::coalesce_immediate):
	Check that the entire merged store group is made of constants only for
	overlapping stores.


2018-09-17  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc.c-torture/execute/20180917-1.c: New test.

-- 
Eric Botcazou

Comments

Richard Biener Sept. 20, 2018, 2:06 p.m. | #1
On Mon, Sep 17, 2018 at 9:12 AM Eric Botcazou <ebotcazou@adacore.com> wrote:
>

> Hi,

>

> this is a regression present on the mainline only: now that the GIMPLE store

> merging pass is able to mix constants and SSA_NAMEs on the RHS of stores to

> bit-fields, we need to check that the entire merged store group is made of

> constants only when encountering overlapping stores.

>

> Tested on x86_64-suse-linux, OK for the mainline?


OK.

Richard.

>

> 2018-09-17  Eric Botcazou  <ebotcazou@adacore.com>

>

>         PR tree-optimization/86990

>         * gimple-ssa-store-merging.c (imm_store_chain_info::coalesce_immediate):

>         Check that the entire merged store group is made of constants only for

>         overlapping stores.

>

>

> 2018-09-17  Eric Botcazou  <ebotcazou@adacore.com>

>

>         * gcc.c-torture/execute/20180917-1.c: New test.

>

> --

> Eric Botcazou

Patch

Index: gimple-ssa-store-merging.c
===================================================================
--- gimple-ssa-store-merging.c	(revision 264342)
+++ gimple-ssa-store-merging.c	(working copy)
@@ -2701,16 +2701,25 @@  imm_store_chain_info::coalesce_immediate
 		    merged_store->start + merged_store->width - 1))
 	{
 	  /* Only allow overlapping stores of constants.  */
-	  if (info->rhs_code == INTEGER_CST
-	      && merged_store->stores[0]->rhs_code == INTEGER_CST)
+	  if (info->rhs_code == INTEGER_CST)
 	    {
+	      bool only_constants = true;
+	      store_immediate_info *infoj;
+	      unsigned int j;
+	      FOR_EACH_VEC_ELT (merged_store->stores, j, infoj)
+		if (infoj->rhs_code != INTEGER_CST)
+		  {
+		    only_constants = false;
+		    break;
+		  }
 	      unsigned int last_order
 		= MAX (merged_store->last_order, info->order);
 	      unsigned HOST_WIDE_INT end
 		= MAX (merged_store->start + merged_store->width,
 		       info->bitpos + info->bitsize);
-	      if (check_no_overlap (m_store_info, i, INTEGER_CST,
-				    last_order, end))
+	      if (only_constants
+		  && check_no_overlap (m_store_info, i, INTEGER_CST,
+				       last_order, end))
 		{
 		  /* check_no_overlap call above made sure there are no
 		     overlapping stores with non-INTEGER_CST rhs_code