Re: [EXTERNAL] Re: [PATCH] tree-optimization: Optimize division followed by multiply [PR95176]

2021-08-22 Thread Victor Tong via Gcc-patches
rn will necessarily be partly redundant with the > > > >   (simplify > >    (minus (nop_convert1? (minus (nop_convert2? @0) @1)) @0) > >    (if (!ANY_INTEGRAL_TYPE_P (type) > > || TYPE_OVERFLOW_WRAPS (type)) > >    (negate (view_convert @1)) > >    (

Re: [EXTERNAL] Re: [PATCH] tree-optimization: Optimize division followed by multiply [PR95176]

2021-08-09 Thread Richard Biener via Gcc-patches
x27;s probably order forcing patterns inbetween so it could simply work. Otherwise whether it works or not (as expected) depends on placing positions of the patterns ... So no, it's not inherently "bad" but it's not designed to work. > > Is someone working on inlining

Re: [EXTERNAL] Re: [PATCH] tree-optimization: Optimize division followed by multiply [PR95176]

2021-08-06 Thread Marc Glisse
at's being worked on right now. I've also added some extra tests to cover this new pattern. I've attached a patch with my latest changes. From: Richard Biener Sent: Wednesday, July 28, 2021 2:59 AM To: Victor Tong Cc: Marc Glisse ; gcc-patches@gcc.gnu.org Subject: Re: [EXT

Re: [EXTERNAL] Re: [PATCH] tree-optimization: Optimize division followed by multiply [PR95176]

2021-08-06 Thread Victor Tong via Gcc-patches
that's being worked on right now. I've also added some extra tests to cover this new pattern. I've attached a patch with my latest changes. From: Richard Biener Sent: Wednesday, July 28, 2021 2:59 AM To: Victor Tong Cc: Marc Glisse ; gcc-patches@gcc.gnu.org Subject: Re: [EXTE

Re: [EXTERNAL] Re: [PATCH] tree-optimization: Optimize division followed by multiply [PR95176]

2021-07-28 Thread Richard Biener via Gcc-patches
legal. I've written some tests to verify that the pattern > is being applied in the right scenarios and not being applied in others, but > I think there are too many possibilities to manually write them all. Is there > anything in GCC that can be used to verify that match.pd tran

Re: [EXTERNAL] Re: [PATCH] tree-optimization: Optimize division followed by multiply [PR95176]

2021-07-19 Thread Victor Tong via Gcc-patches
Gentle ping. From: Gcc-patches on behalf of Victor Tong via Gcc-patches Sent: Monday, June 28, 2021 4:10 PM To: Richard Biener ; Marc Glisse Cc: gcc-patches@gcc.gnu.org Subject: Re: [EXTERNAL] Re: [PATCH] tree-optimization: Optimize division followed by

Re: [EXTERNAL] Re: [PATCH] tree-optimization: Optimize division followed by multiply [PR95176]

2021-06-28 Thread Victor Tong via Gcc-patches
re too many possibilities to manually write them all. Is there anything in GCC that can be used to verify that match.pd transformations are correct? I'm thinking of something like Alive https://github.com/AliveToolkit/alive2. Thanks, Victor From: Richard Biener Sent: Monday, June 21

Re: [EXTERNAL] Re: [PATCH] tree-optimization: Optimize division followed by multiply [PR95176]

2021-06-21 Thread Richard Biener via Gcc-patches
On Sat, Jun 19, 2021 at 7:05 PM Marc Glisse wrote: > > On Fri, 18 Jun 2021, Richard Biener wrote: > > >> Option 2: Add a new pattern to support scenarios that the existing > >> nop_convert pattern bails out on. > >> > >> Existing pattern: > >> > >> (simplify > >>(minus (nop_convert1? @0) (nop

Re: [EXTERNAL] Re: [PATCH] tree-optimization: Optimize division followed by multiply [PR95176]

2021-06-19 Thread Marc Glisse
On Fri, 18 Jun 2021, Richard Biener wrote: Option 2: Add a new pattern to support scenarios that the existing nop_convert pattern bails out on. Existing pattern: (simplify (minus (nop_convert1? @0) (nop_convert2? (minus (nop_convert3? @@0) @1))) (view_convert @1)) I tried to check wit

Re: [EXTERNAL] Re: [PATCH] tree-optimization: Optimize division followed by multiply [PR95176]

2021-06-18 Thread Richard Biener via Gcc-patches
is > by value, not by value + type). > > That said, your > > +/* X - (X - Y) --> Y */ > +(simplify > + (minus (convert1? @0) (convert2? (minus @@0 @1))) > + (if ((INTEGRAL_TYPE_P (type) || VECTOR_INTEGER_TYPE_P (type)) && > TYPE_OVERFLOW_UNDEFINED(type)) >

Re: [EXTERNAL] Re: [PATCH] tree-optimization: Optimize division followed by multiply [PR95176]

2021-06-16 Thread Victor Tong via Gcc-patches
m wrong with either one of these options, or if you can think of a better option to fix the regression. Thanks, Victor From: Richard Biener Sent: Monday, June 7, 2021 1:25 AM To: Victor Tong Cc: gcc-patches@gcc.gnu.org Subject: Re: [EXTERNAL] Re: [PATCH] tree-optimization: Optimize divisio

Re: [EXTERNAL] Re: [PATCH] tree-optimization: Optimize division followed by multiply [PR95176]

2021-06-07 Thread Richard Biener via Gcc-patches
Victor > > > From: Richard Biener > Sent: Tuesday, April 27, 2021 1:29 AM > To: Victor Tong > Cc: gcc-patches@gcc.gnu.org > Subject: [EXTERNAL] Re: [PATCH] tree-optimization: Optimize division followed > by multiply [PR95176] > > On Thu, Apr 1, 2021 at 1:03 AM Victor To

Re: [EXTERNAL] Re: [PATCH] tree-optimization: Optimize division followed by multiply [PR95176]

2021-06-02 Thread Victor Tong via Gcc-patches
nce TYPE_OVERFLOW_UNDEFINED is true, the second pattern that I added (X - (X - Y) --> Y) gets triggered. Thanks, Victor From: Richard Biener Sent: Tuesday, April 27, 2021 1:29 AM To: Victor Tong Cc: gcc-patches@gcc.gnu.org Subject: [EXTERNAL] Re: [PATCH] tree-optimization: Optimize divisio

Re: [PATCH] tree-optimization: Optimize division followed by multiply [PR95176]

2021-04-27 Thread Richard Biener via Gcc-patches
On Thu, Apr 1, 2021 at 1:03 AM Victor Tong via Gcc-patches wrote: > > Hello, > > This patch fixes PR tree-optimization/95176. A new pattern in match.pd was > added to transform "a * (b / a)" --> "b - (b % a)". A new test case was also > added to cover this scenario. > > The new pattern interfere

[PATCH] tree-optimization: Optimize division followed by multiply [PR95176]

2021-03-31 Thread Victor Tong via Gcc-patches
Hello, This patch fixes PR tree-optimization/95176. A new pattern in match.pd was added to transform "a * (b / a)" --> "b - (b % a)". A new test case was also added to cover this scenario. The new pattern interfered with the existing pattern of "X - (X / Y) * Y". In some cases (such as in fn4(