diff mbox

Remove TYPE_IS_SIZETYPE

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

Commit Message

Eric Botcazou May 13, 2012, 9:11 p.m. UTC
> I'd say simply test gimple_has_side_effects instead.

We could go one step farther then and do the replacement in

	  if (gimple_has_volatile_ops (stmt)
	      || stmt_could_throw_p (stmt))
	    continue;

I think that's equivalent.  Revised patch attached.


        * stor-layout.c (bit_from_pos): Distribute conversion to bitsizetype
        in a PLUS_EXPR byte offset.

        * tree-ssa-pre.c (can_value_number_call): Delete.
	(compute_avail): Skip all statements with side effects.
	<GIMPLE_CALL>: Skip calls to internal functions.

Comments

Richard Biener May 14, 2012, 8:05 a.m. UTC | #1
On Sun, May 13, 2012 at 11:11 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> I'd say simply test gimple_has_side_effects instead.
>
> We could go one step farther then and do the replacement in
>
>          if (gimple_has_volatile_ops (stmt)
>              || stmt_could_throw_p (stmt))
>            continue;
>
> I think that's equivalent.  Revised patch attached.

Indeed.

Ok.

Thanks,
Richard.

>
>        * stor-layout.c (bit_from_pos): Distribute conversion to bitsizetype
>        in a PLUS_EXPR byte offset.
>
>        * tree-ssa-pre.c (can_value_number_call): Delete.
>        (compute_avail): Skip all statements with side effects.
>        <GIMPLE_CALL>: Skip calls to internal functions.
>
>
> --
> Eric Botcazou
Eric Botcazou May 19, 2012, 11:15 p.m. UTC | #2
> > We could go one step farther then and do the replacement in
> >
> >          if (gimple_has_volatile_ops (stmt)
> >              || stmt_could_throw_p (stmt))
> >            continue;
> >
> > I think that's equivalent.  Revised patch attached.
>
> Indeed.
>
> Ok.

Thanks.  It turns out that the Ada compiler cannot be bootstrapped in LTO mode 
on the 4.7 branch without the tree-ssa-pre.c patch, which is a regression from 
4.6 so I've backported it after bootstrapping/regtesting on x86_64-suse-linux.
diff mbox

Patch

Index: stor-layout.c
===================================================================
--- stor-layout.c	(revision 187435)
+++ stor-layout.c	(working copy)
@@ -786,25 +786,29 @@  start_record_layout (tree t)
 }
 
 /* Return the combined bit position for the byte offset OFFSET and the
-   bit position BITPOS.  */
+   bit position BITPOS.
+
+   These functions operate on byte and bit positions present in FIELD_DECLs
+   and assume that these expressions result in no (intermediate) overflow.
+   This assumption is necessary to fold the expressions as much as possible,
+   so as to avoid creating artificially variable-sized types in languages
+   supporting variable-sized types like Ada.  */
 
 tree
 bit_from_pos (tree offset, tree bitpos)
 {
+  if (TREE_CODE (offset) == PLUS_EXPR)
+    offset = size_binop (PLUS_EXPR,
+			 fold_convert (bitsizetype, TREE_OPERAND (offset, 0)),
+			 fold_convert (bitsizetype, TREE_OPERAND (offset, 1)));
+  else
+    offset = fold_convert (bitsizetype, offset);
   return size_binop (PLUS_EXPR, bitpos,
-		     size_binop (MULT_EXPR,
-				 fold_convert (bitsizetype, offset),
-				 bitsize_unit_node));
+		     size_binop (MULT_EXPR, offset, bitsize_unit_node));
 }
 
 /* Return the combined truncated byte position for the byte offset OFFSET and
-   the bit position BITPOS.
-
-   These functions operate on byte and bit positions as present in FIELD_DECLs
-   and assume that these expressions result in no (intermediate) overflow.
-   This assumption is necessary to fold the expressions as much as possible,
-   so as to avoid creating artificially variable-sized types in languages
-   supporting variable-sized types like Ada.  */
+   the bit position BITPOS.  */
 
 tree
 byte_from_pos (tree offset, tree bitpos)
Index: tree-ssa-pre.c
===================================================================
--- tree-ssa-pre.c	(revision 187435)
+++ tree-ssa-pre.c	(working copy)
@@ -2586,19 +2586,6 @@  compute_antic (void)
   sbitmap_free (changed_blocks);
 }
 
-/* Return true if we can value number the call in STMT.  This is true
-   if we have a pure or constant call to a real function.  */
-
-static bool
-can_value_number_call (gimple stmt)
-{
-  if (gimple_call_internal_p (stmt))
-    return false;
-  if (gimple_call_flags (stmt) & (ECF_PURE | ECF_CONST))
-    return true;
-  return false;
-}
-
 /* Return true if OP is a tree which we can perform PRE on.
    This may not match the operations we can value number, but in
    a perfect world would.  */
@@ -3998,7 +3985,7 @@  compute_avail (void)
 	      bitmap_value_insert_into_set (AVAIL_OUT (block), e);
 	    }
 
-	  if (gimple_has_volatile_ops (stmt)
+	  if (gimple_has_side_effects (stmt)
 	      || stmt_could_throw_p (stmt))
 	    continue;
 
@@ -4017,7 +4004,8 @@  compute_avail (void)
 		pre_expr result = NULL;
 		VEC(vn_reference_op_s, heap) *ops = NULL;
 
-		if (!can_value_number_call (stmt))
+		/* We can value number only calls to real functions.  */
+		if (gimple_call_internal_p (stmt))
 		  continue;
 
 		copy_reference_ops_from_call (stmt, &ops);