This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: New flag: TREE_THIS_NOTRAP


Richard Henderson writes:
 > On Fri, Jun 11, 2004 at 08:44:22PM +0100, Andrew Haley wrote:
 > > It has to be doesn't it?  The trapping in
 > > 
 > >    *exp
 > > 
 > > is a property of exp, not a property of *.  If someone attaches
 > > another INDIRECT_REF to exp, it will not be marked as NOTRAP.
 > 
 > Yes, but if someone copies exp to a compiler temporary,
 > we'll also lose the NOTRAP.  Something that is exceedingly
 > likely to occur when we go into and out of SSA form.
 > 
 > The INDIRECT_REF is more stable than the pointer in this.

Right.

I've tested this a little bit, and in the cases I tried the NOTRAP is
propagated through the tree optimizers and all the way to assembly
code.

It might be worth doing this for ARRAY_REFs as well?

Andrew.


2004-06-16  Andrew Haley  <aph@redhat.com>

	* emit-rtl.c (set_mem_attributes_minus_bitpos): Check
	TREE_THIS_NOTRAP when setting MEM_NOTRAP_P.
	* tree-eh.c (tree_could_trap_p): Check TREE_THIS_NOTRAP.
	* tree.h (TREE_THIS_NOTRAP): New.

Index: emit-rtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/emit-rtl.c,v
retrieving revision 1.394
diff -c -2 -p -w -r1.394 emit-rtl.c
*** emit-rtl.c	15 Jun 2004 18:02:16 -0000	1.394
--- emit-rtl.c	16 Jun 2004 15:22:47 -0000
*************** set_mem_attributes_minus_bitpos (rtx ref
*** 1544,1547 ****
--- 1544,1548 ----
  	|| (! TYPE_P (t) && TREE_CONSTANT (t)));
    MEM_POINTER (ref) = POINTER_TYPE_P (type);
+   MEM_NOTRAP_P (ref) = TREE_THIS_NOTRAP (t);
  
    /* If we are making an object of this type, or if this is a DECL, we know
Index: tree-eh.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-eh.c,v
retrieving revision 2.4
diff -c -2 -p -w -r2.4 tree-eh.c
*** tree-eh.c	11 Jun 2004 18:41:41 -0000	2.4
--- tree-eh.c	16 Jun 2004 15:22:48 -0000
*************** tree_could_trap_p (tree expr)
*** 1688,1694 ****
      case BIT_FIELD_REF:
        t = get_base_address (expr);
!       return !t || TREE_CODE (t) == INDIRECT_REF;
  
      case INDIRECT_REF:
      case TRUNC_DIV_EXPR:
      case CEIL_DIV_EXPR:
--- 1688,1696 ----
      case BIT_FIELD_REF:
        t = get_base_address (expr);
!       return !t || tree_could_trap_p (t);
  
      case INDIRECT_REF:
+       return (TREE_THIS_NOTRAP (expr) == false);
+ 
      case TRUNC_DIV_EXPR:
      case CEIL_DIV_EXPR:
Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.515
diff -c -2 -p -w -r1.515 tree.h
*** tree.h	16 Jun 2004 05:09:40 -0000	1.515
--- tree.h	16 Jun 2004 15:22:50 -0000
*************** struct tree_common GTY(())
*** 306,309 ****
--- 306,312 ----
  	   ..._TYPE
  
+        TREE_THIS_NOTRAP in
+           INDIRECT_REF
+ 
     deprecated_flag:
  
*************** extern void tree_operand_check_failed (i
*** 762,765 ****
--- 765,774 ----
  #define TREE_THIS_VOLATILE(NODE) ((NODE)->common.volatile_flag)
  
+ /* Nonzero means this node will not trap.  In an operand of pointer
+    type, means accessing the memory pointed to won't generate a trap.
+    However, this only applies to an object when used appropriately: it
+    doesn't mean that writing a READONLY mem won't trap.  */
+ #define TREE_THIS_NOTRAP(NODE) ((NODE)->common.nothrow_flag)
+ 
  /* In a VAR_DECL, PARM_DECL or FIELD_DECL, or any kind of ..._REF node,
     nonzero means it may not be the lhs of an assignment.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]