Simple reassoc transforms in match.pd

Richard Biener richard.guenther@gmail.com
Mon Jun 26 10:16:00 GMT 2017


On Fri, Jun 23, 2017 at 3:12 PM, Marc Glisse <marc.glisse@inria.fr> wrote:
> Hello,
>
> here are a few simple transformations, mostly useful for types with
> undefined overflow where we do not have reassoc.
>
> I did not name the testcase reassoc-* to leave that namespace to the realloc
> pass, and -fno-tree-reassoc is just in case someone ever enhances that
> pass...

You probably saw

  /* (T)(P + A) - (T)(P + B) -> (T)A - (T)B */
  (for add (plus pointer_plus)
   (simplify
    (minus (convert (add @@0 @1))
     (convert (add @0 @2)))

as you didn't duplicate its functionality.  It misses a :c in one of
the adds for the
PLUS_EXPR case though so it might be worth splitting that out near to your
added cases?  Which then raises the question of handling conversions around
the inner ops in your patterns?

I think the patch is ok as-is but we could improve this as a followup maybe?

Thanks,
Richard.

> Bootstrap + testsuite on powerpc64le-unknown-linux-gnu.
>
> 2017-06-23  Marc Glisse  <marc.glisse@inria.fr>
>
> gcc/
>         * match.pd ((A+-B)+(C-A), (A+B)-(A-C)): New transformations.
>
> gcc/testsuite/
>         * gcc.dg/tree-ssa/assoc-1.c: New file.
>
> --
> Marc Glisse



More information about the Gcc-patches mailing list