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: PATCH RFC: Clean up TREE_THIS_NOTRAP, copy it to MEM_REF


> 2) When the gimplifier creates a MEM_REF for an INDIRECT_REF, it copies
>    over the TREE_THIS_NOTRAP flag.  This is the more important part of
>    the change, as it improves the generated code when using
>    -fnon-call-exceptions.

Thanks for caring about -fnon-call-exceptions. :-)

> This patch is entirely in the middle-end, so I do not need approval.
> However, I would like to know if there are any comments on this before I
> commit it.

The TREE_THIS_NOTRAP flag can get lost during inlining.  We have the attached 
hunks in our 4.5-based tree (to be adjusted to MEM_REF).  The sched-deps.c 
hunk is for the IA-64 because it abuses may_trap_p to detect non-speculative 
instructions; when the TREE_THIS_NOTRAP is set, may_trap_p returns false, 
although the instruction is still as speculative as without it.


	* sched-deps.c (sched_insn_is_legitimate_for_speculation): Invoke
	may_trap_or_fault_p instead of may_trap_p predicate.
	* tree.c (substitute_in_expr): Propagate the TREE_THIS_NOTRAP flag.
	(substitute_placeholder_in_expr): Likewise.
	* tree-inline.c (remap_gimple_op_r): Propagate the TREE_READONLY and
	TREE_THIS_NOTRAP flags on INDIRECT_REF nodes.
	(copy_tree_body_r): Likewise.



-- 
Eric Botcazou
*** gcc/sched-deps.c.0	2010-09-27 23:58:17.000000000 +0200
--- gcc/sched-deps.c	2010-09-28 00:03:05.000000000 +0200
*************** sched_insn_is_legitimate_for_speculation
*** 597,604 ****
      /* The following instructions, which depend on a speculatively scheduled
         instruction, cannot be speculatively scheduled along.  */
      {
!       if (may_trap_p (PATTERN (insn)))
! 	/* If instruction might trap, it cannot be speculatively scheduled.
  	   For control speculation it's obvious why and for data speculation
  	   it's because the insn might get wrong input if speculation
  	   wasn't successful.  */
--- 597,604 ----
      /* The following instructions, which depend on a speculatively scheduled
         instruction, cannot be speculatively scheduled along.  */
      {
!       if (may_trap_or_fault_p (PATTERN (insn)))
! 	/* If instruction might fault, it cannot be speculatively scheduled.
  	   For control speculation it's obvious why and for data speculation
  	   it's because the insn might get wrong input if speculation
  	   wasn't successful.  */
*** gcc/tree.c.0	2010-09-26 13:31:06.000000000 +0200
--- gcc/tree.c	2010-09-26 17:25:20.000000000 +0200
*************** substitute_in_expr (tree exp, tree f, tr
*** 3133,3138 ****
--- 3133,3142 ----
        }
  
    TREE_READONLY (new_tree) |= TREE_READONLY (exp);
+ 
+   if (code == INDIRECT_REF || code == ARRAY_REF || code == ARRAY_RANGE_REF)
+     TREE_THIS_NOTRAP (new_tree) |= TREE_THIS_NOTRAP (exp);
+ 
    return new_tree;
  }
  
*************** substitute_placeholder_in_expr (tree exp
*** 3300,3305 ****
--- 3304,3313 ----
        }
  
    TREE_READONLY (new_tree) |= TREE_READONLY (exp);
+ 
+   if (code == INDIRECT_REF || code == ARRAY_REF || code == ARRAY_RANGE_REF)
+     TREE_THIS_NOTRAP (new_tree) |= TREE_THIS_NOTRAP (exp);
+ 
    return new_tree;
  }
  
*** gcc/tree-inline.c.0	2010-09-26 13:30:54.000000000 +0200
--- gcc/tree-inline.c	2010-09-26 13:41:34.000000000 +0200
*************** remap_gimple_op_r (tree *tp, int *walk_s
*** 845,850 ****
--- 845,852 ----
  	              *tp = build1 (INDIRECT_REF, type, new_tree);
  		      TREE_THIS_VOLATILE (*tp) = TREE_THIS_VOLATILE (old);
  		      TREE_NO_WARNING (*tp) = TREE_NO_WARNING (old);
+ 		      TREE_READONLY (*tp) = TREE_READONLY (old);
+ 		      TREE_THIS_NOTRAP (*tp) = TREE_THIS_NOTRAP (old);
  		    }
  		}
  	      *walk_subtrees = 0;
*************** copy_tree_body_r (tree *tp, int *walk_su
*** 1080,1085 ****
--- 1082,1089 ----
  	              *tp = build1 (INDIRECT_REF, type, new_tree);
  		      TREE_THIS_VOLATILE (*tp) = TREE_THIS_VOLATILE (old);
  		      TREE_SIDE_EFFECTS (*tp) = TREE_SIDE_EFFECTS (old);
+ 		      TREE_READONLY (*tp) = TREE_READONLY (old);
+ 		      TREE_THIS_NOTRAP (*tp) = TREE_THIS_NOTRAP (old);
  		    }
  		}
  	      *walk_subtrees = 0;

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