Re: [PATCH] match.pd: Add new division pattern [PR104992]

2022-08-01 Thread Sam Feifer via Gcc-patches
992.c > >> > > b/gcc/testsuite/gcc.dg/pr104992.c > >> > > >> > new file mode 100644 > >> > > >> > index 000..b4b0ca53118 > >> > > >> > --- /dev/null > >> > > >> > +++ b/gcc/testsuite/gcc.dg/pr104992

Re: [PATCH] match.pd: Add new division pattern [PR104992]

2022-07-28 Thread Richard Biener via Gcc-patches
On Wed, Jul 27, 2022 at 9:57 PM Sam Feifer wrote: > > >> _Complex int are strange beasts, I'd simply avoid the transform for them. >> > > I added to the match.pd rule to not simplify if the operands are complex. > There is now a test case for complex types to make sure they do not simplify. > I

Re: [PATCH] match.pd: Add new division pattern [PR104992]

2022-07-27 Thread Sam Feifer via Gcc-patches
mp-tree-optimized" } */ > > > >> > + > > > >> > +/* Form from PR. */ > > > >> > +__attribute__((noipa)) unsigned foo(unsigned x, unsigned y) > > > >> > +{ > > > >> > + return x / y * y == x; > > > &

Re: [PATCH] match.pd: Add new division pattern [PR104992]

2022-07-27 Thread Richard Biener via Gcc-patches
On Tue, Jul 26, 2022 at 4:32 PM Sam Feifer via Gcc-patches wrote: > > > > > int f(_Complex int x, _Complex int y) > > { > > return x == x / y * y; > > } > > > > After some research about mod with complex types, I found that the binary > mod operation does not work with complex types. If so, the

Re: [PATCH] match.pd: Add new division pattern [PR104992]

2022-07-26 Thread Sam Feifer via Gcc-patches
> > int f(_Complex int x, _Complex int y) > { > return x == x / y * y; > } > After some research about mod with complex types, I found that the binary mod operation does not work with complex types. If so, the complex test case should not be simplified. Is this correct? I should also note that

Re: [PATCH] match.pd: Add new division pattern [PR104992]

2022-07-25 Thread Andrew Pinski via Gcc-patches
On Mon, Jul 25, 2022 at 1:59 PM Sam Feifer wrote: > > >> I suspect for eq and mult you might want to add :c to them even though >> in your testcase you don't need them, you might be able to get it via >> using different statements and looking at the forwprop gimple dump. >> Also, did you send the

Re: [PATCH] match.pd: Add new division pattern [PR104992]

2022-07-25 Thread Sam Feifer via Gcc-patches
> I suspect for eq and mult you might want to add :c to them even though > in your testcase you don't need them, you might be able to get it via > using different statements and looking at the forwprop gimple dump. > Also, did you send the wrong patch as it looks like the function call > to build_z

Re: [PATCH] match.pd: Add new division pattern [PR104992]

2022-07-25 Thread Andrew Pinski via Gcc-patches
On Mon, Jul 25, 2022 at 12:37 PM Sam Feifer via Gcc-patches wrote: > > This patch fixes a missed optimization in match.pd. It takes the pattern, x / > y * y == x, and optimizes it to x % y == 0. This produces fewer instructions. > > There are also tests for the optimizations to be added to the te

[PATCH] match.pd: Add new division pattern [PR104992]

2022-07-25 Thread Sam Feifer via Gcc-patches
This patch fixes a missed optimization in match.pd. It takes the pattern, x / y * y == x, and optimizes it to x % y == 0. This produces fewer instructions. There are also tests for the optimizations to be added to the test suite. Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?