On Thu, Jul 23, 2020 at 2:01 PM Roger Sayle <ro...@nextmovesoftware.com> wrote:
>
>
> On Thu, Jul 23, 2020 at 10:02 Richard Biener wrote:
> > Likewise for the existing
> >
> >+/* popcount(X) == 0 is X == 0, and related (in)equalities.  */ (for
> >+(for popcount (POPCOUNT)
> >   (for cmp (le eq ne gt)
> >       rep (eq eq ne ne)
> >   (simplify
> >       (cmp (popcount @0) integer_zerop)
> >       (rep @0 { build_zero_cst (TREE_TYPE (@0)); }))))
> >
> > you can elide the (for ...)
>
> Unfortunately, I tried that myself when preparing this patch:
>
> Attempt #1:
>
>    (for cmp (le eq ne gt)
>         rep (eq eq ne ne)
>      (simplify
>        (cmp (POPCOUNT @0) integer_zerop)
>        (rep @0 { build_zero_cst (TREE_TYPE (@0)); }))))
>
> results in:
> build/genmatch --gimple ../../patcha3/gcc/match.pd \
>     > tmp-gimple-match.c
> ../../patcha3/gcc/match.pd:5977:11 error: operator-list POPCOUNT cannot be 
> expanded inside 'for'
>     (cmp (POPCOUNT @0) integer_zerop)
>           ^
> Attempt #2:
>
> (for popcount (POPCOUNT)
>      cmp (le eq ne gt)
>      rep (eq eq ne ne)
>   (simplify
>     (cmp (popcount @0) integer_zerop)
>     (rep @0 { build_zero_cst (TREE_TYPE (@0)); })))
>
> results in:
>     > tmp-gimple-match.c
> ../../patcha3/gcc/match.pd:5975:22 error: All user-defined identifiers must 
> have a multiple number of operator substitutions of the smallest number of 
> substitutions
>      cmp (le eq ne gt)
>                      ^

Oh yeah - I failed to spot the outer (for ..), indeed it doesn't work
then.  We're not magically
creating a nest from the first vairant which we could make work - I
erred on the side of
"too much implicitness" caution here.

> I'll leave it the way it is with the nested FORs, and investigate your other 
> suggestions.

Yeah, fine.

> > OK with those changes.
> >
> > Richard.
>
>
> Roger
> --
>
>

Reply via email to