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]

[PATCH] Fix some more issues with the builtins PTA/oracle patch


Andrew noticed that I didn't properly handle errno being set by some
of the builtins.  Fixed with the following patch.  Also I forgot to
handle them in ref_maybe_used_by_call_p_1 which resulted in some
pessimization.  And for memset to zero we can use a constraint from NULL
(which should be most of the cases), instead of falling back to something
that will be anything.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2009-06-20  Richard Guenther  <rguenther@suse.de>

	* tree-ssa-structalias.c (find_func_aliases): For memset use
	a constraint from NULL if we memset to zero.
	* tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Add builtins
	we explicitly handle that do not read from memory.
	(call_may_clobber_ref_p_1): Properly handle builtins that may
	set errno.

Index: gcc/tree-ssa-alias.c
===================================================================
*** gcc/tree-ssa-alias.c	(revision 148741)
--- gcc/tree-ssa-alias.c	(working copy)
*************** ref_maybe_used_by_call_p_1 (gimple call,
*** 899,904 ****
--- 899,927 ----
  	    tree src = gimple_call_arg (call, 1);
  	    return ptr_deref_may_alias_ref_p (src, ref);
  	  }
+ 	/* The following builtins do not read from memory.  */
+ 	case BUILT_IN_FREE:
+ 	case BUILT_IN_MEMSET:
+ 	case BUILT_IN_FREXP:
+ 	case BUILT_IN_FREXPF:
+ 	case BUILT_IN_FREXPL:
+ 	case BUILT_IN_GAMMA_R:
+ 	case BUILT_IN_GAMMAF_R:
+ 	case BUILT_IN_GAMMAL_R:
+ 	case BUILT_IN_LGAMMA_R:
+ 	case BUILT_IN_LGAMMAF_R:
+ 	case BUILT_IN_LGAMMAL_R:
+ 	case BUILT_IN_MODF:
+ 	case BUILT_IN_MODFF:
+ 	case BUILT_IN_MODFL:
+ 	case BUILT_IN_REMQUO:
+ 	case BUILT_IN_REMQUOF:
+ 	case BUILT_IN_REMQUOL:
+ 	case BUILT_IN_SINCOS:
+ 	case BUILT_IN_SINCOSF:
+ 	case BUILT_IN_SINCOSL:
+ 	  return false;
+ 
  	default:
  	  /* Fallthru to general call handling.  */;
        }
*************** call_may_clobber_ref_p_1 (gimple call, a
*** 1060,1074 ****
  	    tree ptr = gimple_call_arg (call, 0);
  	    return ptr_deref_may_alias_ref_p_1 (ptr, ref);
  	  }
- 	case BUILT_IN_FREXP:
- 	case BUILT_IN_FREXPF:
- 	case BUILT_IN_FREXPL:
  	case BUILT_IN_GAMMA_R:
  	case BUILT_IN_GAMMAF_R:
  	case BUILT_IN_GAMMAL_R:
  	case BUILT_IN_LGAMMA_R:
  	case BUILT_IN_LGAMMAF_R:
  	case BUILT_IN_LGAMMAL_R:
  	case BUILT_IN_MODF:
  	case BUILT_IN_MODFF:
  	case BUILT_IN_MODFL:
--- 1083,1105 ----
  	    tree ptr = gimple_call_arg (call, 0);
  	    return ptr_deref_may_alias_ref_p_1 (ptr, ref);
  	  }
  	case BUILT_IN_GAMMA_R:
  	case BUILT_IN_GAMMAF_R:
  	case BUILT_IN_GAMMAL_R:
  	case BUILT_IN_LGAMMA_R:
  	case BUILT_IN_LGAMMAF_R:
  	case BUILT_IN_LGAMMAL_R:
+ 	  {
+ 	    tree out = gimple_call_arg (call, 1);
+ 	    if (ptr_deref_may_alias_ref_p_1 (out, ref))
+ 	      return true;
+ 	    if (flag_errno_math)
+ 	      break;
+ 	    return false;
+ 	  }
+ 	case BUILT_IN_FREXP:
+ 	case BUILT_IN_FREXPF:
+ 	case BUILT_IN_FREXPL:
  	case BUILT_IN_MODF:
  	case BUILT_IN_MODFF:
  	case BUILT_IN_MODFL:
*************** call_may_clobber_ref_p_1 (gimple call, a
*** 1081,1087 ****
  	case BUILT_IN_REMQUOL:
  	  {
  	    tree out = gimple_call_arg (call, 2);
! 	    return ptr_deref_may_alias_ref_p_1 (out, ref);
  	  }
  	case BUILT_IN_SINCOS:
  	case BUILT_IN_SINCOSF:
--- 1112,1122 ----
  	case BUILT_IN_REMQUOL:
  	  {
  	    tree out = gimple_call_arg (call, 2);
! 	    if (ptr_deref_may_alias_ref_p_1 (out, ref))
! 	      return true;
! 	    if (flag_errno_math)
! 	      break;
! 	    return false;
  	  }
  	case BUILT_IN_SINCOS:
  	case BUILT_IN_SINCOSF:
Index: gcc/tree-ssa-structalias.c
===================================================================
*** gcc/tree-ssa-structalias.c	(revision 148746)
--- gcc/tree-ssa-structalias.c	(working copy)
*************** find_func_aliases (gimple origt)
*** 3674,3681 ****
  		}
  	      get_constraint_for_ptr_offset (dest, NULL_TREE, &lhsc);
  	      do_deref (&lhsc);
! 	      ac.type = SCALAR;
! 	      ac.var = integer_id;
  	      ac.offset = 0;
  	      for (i = 0; VEC_iterate (ce_s, lhsc, i, lhsp); ++i)
  		process_constraint (new_constraint (*lhsp, ac));
--- 3674,3690 ----
  		}
  	      get_constraint_for_ptr_offset (dest, NULL_TREE, &lhsc);
  	      do_deref (&lhsc);
! 	      if (flag_delete_null_pointer_checks
! 		  && integer_zerop (gimple_call_arg (t, 1)))
! 		{
! 		  ac.type = ADDRESSOF;
! 		  ac.var = nothing_id;
! 		}
! 	      else
! 		{
! 		  ac.type = SCALAR;
! 		  ac.var = integer_id;
! 		}
  	      ac.offset = 0;
  	      for (i = 0; VEC_iterate (ce_s, lhsc, i, lhsp); ++i)
  		process_constraint (new_constraint (*lhsp, ac));


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