Simplify 'gcc/tree.c:walk_tree_1' handling of 'OMP_CLAUSE' (was: Fix PR 25886. Convert OMP_CLAUSE_* into sub-codes.)

Thomas Schwinge thomas@codesourcery.com
Tue Aug 31 18:51:16 GMT 2021


Hi!

On 2006-01-25T12:41:14-0500, Diego Novillo <dnovillo@redhat.com> wrote:
> This patch replaces all the OMP_CLAUSE_* tree codes with a single
> OMP_CLAUSE tree with sub-codes.

So, originally all OMP clauses were represented by their own tree codes,
which all had to be enumerated/handled individually.  But, with all these
having been unified into 'OMP_CLAUSE'...

> --- tree.c    (revision 110178)
> +++ tree.c    (working copy)

..., and given this:

> +/* Number of operands for each OpenMP clause.  */
> +unsigned char omp_clause_num_ops[] =
> +{
> +  0, /* OMP_CLAUSE_ERROR  */
> +  1, /* OMP_CLAUSE_PRIVATE  */
> +  1, /* OMP_CLAUSE_SHARED  */
> +  1, /* OMP_CLAUSE_FIRSTPRIVATE  */
> +  1, /* OMP_CLAUSE_LASTPRIVATE  */
> +  4, /* OMP_CLAUSE_REDUCTION  */
> +  1, /* OMP_CLAUSE_COPYIN  */
> +  1, /* OMP_CLAUSE_COPYPRIVATE  */
> +  1, /* OMP_CLAUSE_IF  */
> +  1, /* OMP_CLAUSE_NUM_THREADS  */
> +  1, /* OMP_CLAUSE_SCHEDULE  */
> +  0, /* OMP_CLAUSE_NOWAIT  */
> +  0, /* OMP_CLAUSE_ORDERED  */
> +  0  /* OMP_CLAUSE_DEFAULT  */
> +};

..., we may simplify this:

> @@ -7303,30 +7433,38 @@ walk_tree (tree *tp, walk_tree_fn func,
>        }
>        break;
>
> -    case OMP_CLAUSE_PRIVATE:
> -[...]
> -    case OMP_CLAUSE_SCHEDULE:
> -      WALK_SUBTREE (TREE_OPERAND (*tp, 0));
> -      /* FALLTHRU */
> +    case OMP_CLAUSE:
> +      switch (OMP_CLAUSE_CODE (*tp))
> +     {
> +     case OMP_CLAUSE_PRIVATE:
> +[...]
> +     case OMP_CLAUSE_SCHEDULE:
> +       WALK_SUBTREE (OMP_CLAUSE_OPERAND (*tp, 0));
> +       /* FALLTHRU */
>
> -    case OMP_CLAUSE_NOWAIT:
> -    case OMP_CLAUSE_ORDERED:
> -    case OMP_CLAUSE_DEFAULT:
> -      WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (*tp));
> +     case OMP_CLAUSE_NOWAIT:
> +     case OMP_CLAUSE_ORDERED:
> +     case OMP_CLAUSE_DEFAULT:
> +       WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (*tp));
>
> -    case OMP_CLAUSE_REDUCTION:
> -      {
> -     int i;
> -     for (i = 0; i < 4; i++)
> -       WALK_SUBTREE (TREE_OPERAND (*tp, i));
> -     WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (*tp));
> -      }
> +     case OMP_CLAUSE_REDUCTION:
> +       {
> +         int i;
> +         for (i = 0; i < 4; i++)
> +           WALK_SUBTREE (OMP_CLAUSE_OPERAND (*tp, i));
> +         WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (*tp));
> +       }
> +
> +     default:
> +       gcc_unreachable ();
> +     }
> +      break;

... considerably?  OK to push to master branch the attached
"Simplify 'gcc/tree.c:walk_tree_1' handling of 'OMP_CLAUSE'"?


Grüße
 Thomas


-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Simplify-gcc-tree.c-walk_tree_1-handling-of-OMP_CLAU.patch
Type: text/x-diff
Size: 5179 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20210831/85b326fc/attachment-0001.bin>


More information about the Gcc-patches mailing list