diff mbox

Fix failure of ACATS cc3601a

Message ID 201103311725.40432.ebotcazou@adacore.com
State New
Headers show

Commit Message

Eric Botcazou March 31, 2011, 3:25 p.m. UTC
Hi,

the ACATS test cc3601a started to fail recently at -O2 after the various tweaks 
to the optimizer.  This is an assertion failure in the gimplifier invoked from 
PRE because of a dangling PLACEHOLDER_EXPR in operand #2 of an ARRAY_REF.

CCP2 turns the ARRAY_REF:

  D.2774_394 = MEM[(boolean[(size_type) <PLACEHOLDER_EXPR struct 
opt16__ab___XUP>.P_BOUNDS->LB0:<PLACEHOLDER_EXPR struct 
opt16__ab___XUP>.P_BOUNDS->UB0 >= <PLACEHOLDER_EXPR struct 
opt16__ab___XUP>.P_BOUNDS->LB0 ? (size_type) <PLACEHOLDER_EXPR struct 
opt16__ab___XUP>.P_BOUNDS->UB0 : (size_type) <PLACEHOLDER_EXPR struct 
opt16__ab___XUP>.P_BOUNDS->LB0 + -1] *)&ab1][D.2776_392]{lb: D.2758_393 sz: 
1};

into:

  D.2774_394 = MEM[(boolean[(size_type) <PLACEHOLDER_EXPR struct 
opt16__ab___XUP>.P_BOUNDS->LB0:<PLACEHOLDER_EXPR struct 
opt16__ab___XUP>.P_BOUNDS->UB0 >= <PLACEHOLDER_EXPR struct 
opt16__ab___XUP>.P_BOUNDS->LB0 ? (size_type) <PLACEHOLDER_EXPR struct 
opt16__ab___XUP>.P_BOUNDS->UB0 : (size_type) <PLACEHOLDER_EXPR struct 
opt16__ab___XUP>.P_BOUNDS->LB0 + -1] *)&ab1][D.2776_392]{lb: 0 sz: 1};

i.e. it computes that operand #2 is 0.  Later PRE re-creates the reference "by 
pieces" and explicitly drops the 0:

	if (genop2)
	  {
	    /* Drop zero minimum index.  */
	    if (tree_int_cst_equal (genop2, integer_zero_node))
	      genop2 = NULL_TREE;

so the gimplifier re-populates it, bringing back the PLACEHOLDER_EXPR.

Fixed by not dropping the 0 in PRE.  Tested on i586-suse-linux, OK for the 
mainline?


2011-03-31  Eric Botcazou  <ebotcazou@adacore.com>

	* tree-ssa-pre.c (create_component_ref_by_pieces_1) <ARRAY_REF>:
	Drop a zero minimum index only if it is redundant.


2011-03-31  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/opt16.adb: New test.

Comments

Richard Biener March 31, 2011, 3:34 p.m. UTC | #1
On Thu, Mar 31, 2011 at 5:25 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> Hi,
>
> the ACATS test cc3601a started to fail recently at -O2 after the various tweaks
> to the optimizer.  This is an assertion failure in the gimplifier invoked from
> PRE because of a dangling PLACEHOLDER_EXPR in operand #2 of an ARRAY_REF.
>
> CCP2 turns the ARRAY_REF:
>
>  D.2774_394 = MEM[(boolean[(size_type) <PLACEHOLDER_EXPR struct
> opt16__ab___XUP>.P_BOUNDS->LB0:<PLACEHOLDER_EXPR struct
> opt16__ab___XUP>.P_BOUNDS->UB0 >= <PLACEHOLDER_EXPR struct
> opt16__ab___XUP>.P_BOUNDS->LB0 ? (size_type) <PLACEHOLDER_EXPR struct
> opt16__ab___XUP>.P_BOUNDS->UB0 : (size_type) <PLACEHOLDER_EXPR struct
> opt16__ab___XUP>.P_BOUNDS->LB0 + -1] *)&ab1][D.2776_392]{lb: D.2758_393 sz:
> 1};
>
> into:
>
>  D.2774_394 = MEM[(boolean[(size_type) <PLACEHOLDER_EXPR struct
> opt16__ab___XUP>.P_BOUNDS->LB0:<PLACEHOLDER_EXPR struct
> opt16__ab___XUP>.P_BOUNDS->UB0 >= <PLACEHOLDER_EXPR struct
> opt16__ab___XUP>.P_BOUNDS->LB0 ? (size_type) <PLACEHOLDER_EXPR struct
> opt16__ab___XUP>.P_BOUNDS->UB0 : (size_type) <PLACEHOLDER_EXPR struct
> opt16__ab___XUP>.P_BOUNDS->LB0 + -1] *)&ab1][D.2776_392]{lb: 0 sz: 1};
>
> i.e. it computes that operand #2 is 0.  Later PRE re-creates the reference "by
> pieces" and explicitly drops the 0:
>
>        if (genop2)
>          {
>            /* Drop zero minimum index.  */
>            if (tree_int_cst_equal (genop2, integer_zero_node))
>              genop2 = NULL_TREE;
>
> so the gimplifier re-populates it, bringing back the PLACEHOLDER_EXPR.
>
> Fixed by not dropping the 0 in PRE.  Tested on i586-suse-linux, OK for the
> mainline?

Ok.

Thanks,
Richard.

>
> 2011-03-31  Eric Botcazou  <ebotcazou@adacore.com>
>
>        * tree-ssa-pre.c (create_component_ref_by_pieces_1) <ARRAY_REF>:
>        Drop a zero minimum index only if it is redundant.
>
>
> 2011-03-31  Eric Botcazou  <ebotcazou@adacore.com>
>
>        * gnat.dg/opt16.adb: New test.
>
>
> --
> Eric Botcazou
>
diff mbox

Patch

Index: tree-ssa-pre.c
===================================================================
--- tree-ssa-pre.c	(revision 171716)
+++ tree-ssa-pre.c	(working copy)
@@ -2874,8 +2874,10 @@  create_component_ref_by_pieces_1 (basic_
 	  return NULL_TREE;
 	if (genop2)
 	  {
-	    /* Drop zero minimum index.  */
-	    if (tree_int_cst_equal (genop2, integer_zero_node))
+	    tree domain_type = TYPE_DOMAIN (TREE_TYPE (genop0));
+	    /* Drop zero minimum index if redundant.  */
+	    if (integer_zerop (genop2)
+		&& integer_zerop (TYPE_MIN_VALUE (domain_type)))
 	      genop2 = NULL_TREE;
 	    else
 	      {