This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: RFC: Hack to make restrict more useful
On 9/1/07, Mark Mitchell <mark@codesourcery.com> wrote:
> Richard Guenther wrote:
>
> >> I fully concede that my trick isn't a general solution to making full
> >> use of restrict. But, given that I think it'll take about 20-50 lines
> >> of code, and that it will get a lot of the common cases, I think it's
> >> worth it. Do you agree?
> >
> > Yes, I agree. I just was curious on the status of Dannys work and if it
> > would obsolete what you propose.
>
> OK, great. Here's a draft patch for the trick; this works on the test
> case I had, and I'll be testing it now. If it passes testing, and I add
> testcases, does this look OK to you?
>
> --- tree-ssa-structalias.c (revision 127950)
> +++ tree-ssa-structalias.c (working copy)
> @@ -4544,7 +4544,12 @@ intra_create_variable_infos (void)
> {
> tree t;
> struct constraint_expr lhs, rhs;
> + bool noalias;
it's an int.
> + noalias = argument_noalias ();
> +
> + /* For each incoming pointer argument arg, ARG = ESCAPED_VARS or a
> + dummy variable if flag_argument_noalias > 2. */
What's this comment for?
> /* For each incoming pointer argument arg, create the constraint ARG
> = ANYTHING or a dummy variable if flag_argument_noalias is set. */
> for (t = DECL_ARGUMENTS (current_function_decl); t; t = TREE_CHAIN (t))
> @@ -4554,11 +4559,10 @@ intra_create_variable_infos (void)
> if (!could_have_pointers (t))
> continue;
>
> - /* If flag_argument_noalias is set, then function pointer
> - arguments are guaranteed not to point to each other. In that
> - case, create an artificial variable PARM_NOALIAS and the
> - constraint ARG = &PARM_NOALIAS. */
> - if (POINTER_TYPE_P (TREE_TYPE (t)) && flag_argument_noalias > 0)
> + /* If the arguments are guaranteed not to point to each other,
> + create an artificial variable PARM_NOALIAS and the constraint
> + ARG = &PARM_NOALIAS. */
> + if (POINTER_TYPE_P (TREE_TYPE (t)) && noalias)
noalias > 0 I suppose.
> {
> varinfo_t vi;
> tree heapvar = heapvar_lookup (t);
> @@ -4579,7 +4583,7 @@ intra_create_variable_infos (void)
> heapvar_insert (t, heapvar);
>
> ann = get_var_ann (heapvar);
> - if (flag_argument_noalias == 1)
> + if (flag_argument_noalias <= 1)
> ann->noalias_state = NO_ALIAS;
> else if (flag_argument_noalias == 2)
> ann->noalias_state = NO_ALIAS_GLOBAL;
That looks wrong. Shouldn't this just replace flag_argument_noalias
for noalias everywhere?
Otherwise it looks good, but let's wait for Danny to comment.
Richard.