[PATCH] match.pd: Add new abs pattern [PR94290]

2022-07-13 Thread Sam Feifer via Gcc-patches
This patch is intended to fix a missed optimization in match.pd. It optimizes (x >= 0 ? x : 0) + (x <= 0 ? -x : 0) to just abs(x). I had to write a second simplification in match.pd to handle the commutative property as the match was not ocurring otherwise. Additionally, the pattern (x <= 0 ? -x

Re: [PATCH] match.pd: Add new abs pattern [PR94290]

2022-07-13 Thread Andrew Pinski via Gcc-patches
On Wed, Jul 13, 2022 at 12:26 PM Sam Feifer via Gcc-patches wrote: > > This patch is intended to fix a missed optimization in match.pd. It optimizes > (x >= 0 ? x : 0) + (x <= 0 ? -x : 0) to just abs(x). I had to write a second > simplification in match.pd to handle the commutative property as t

Re: [PATCH] match.pd: Add new abs pattern [PR94290]

2022-07-13 Thread Richard Biener via Gcc-patches
On Wed, Jul 13, 2022 at 9:36 PM Andrew Pinski via Gcc-patches wrote: > > On Wed, Jul 13, 2022 at 12:26 PM Sam Feifer via Gcc-patches > wrote: > > > > This patch is intended to fix a missed optimization in match.pd. It > > optimizes (x >= 0 ? x : 0) + (x <= 0 ? -x : 0) to just abs(x). I had to >

Re: [PATCH] match.pd: Add new abs pattern [PR94290]

2022-07-14 Thread Sam Feifer via Gcc-patches
On Wed, Jul 13, 2022 at 3:36 PM Andrew Pinski wrote: > On Wed, Jul 13, 2022 at 12:26 PM Sam Feifer via Gcc-patches > wrote: > > > > This patch is intended to fix a missed optimization in match.pd. It > optimizes (x >= 0 ? x : 0) + (x <= 0 ? -x : 0) to just abs(x). I had to > write a second simpl

Re: [PATCH] match.pd: Add new abs pattern [PR94290]

2022-07-14 Thread Andrew Pinski via Gcc-patches
On Thu, Jul 14, 2022 at 7:09 AM Sam Feifer wrote: > > > On Wed, Jul 13, 2022 at 3:36 PM Andrew Pinski wrote: >> >> On Wed, Jul 13, 2022 at 12:26 PM Sam Feifer via Gcc-patches >> wrote: >> > >> > This patch is intended to fix a missed optimization in match.pd. It >> > optimizes (x >= 0 ? x : 0)

Re: [PATCH] match.pd: Add new abs pattern [PR94290]

2022-07-14 Thread Sam Feifer via Gcc-patches
On Thu, Jul 14, 2022 at 1:24 PM Andrew Pinski wrote: > On Thu, Jul 14, 2022 at 7:09 AM Sam Feifer wrote: > > > > > > On Wed, Jul 13, 2022 at 3:36 PM Andrew Pinski wrote: > >> > >> On Wed, Jul 13, 2022 at 12:26 PM Sam Feifer via Gcc-patches > >> wrote: > >> > > >> > This patch is intended to fi

Re: [PATCH] match.pd: Add new abs pattern [PR94290]

2022-07-14 Thread Andrew Pinski via Gcc-patches
On Thu, Jul 14, 2022 at 12:38 PM Sam Feifer wrote: > > > > On Thu, Jul 14, 2022 at 1:24 PM Andrew Pinski wrote: >> >> On Thu, Jul 14, 2022 at 7:09 AM Sam Feifer wrote: >> > >> > >> > On Wed, Jul 13, 2022 at 3:36 PM Andrew Pinski wrote: >> >> >> >> On Wed, Jul 13, 2022 at 12:26 PM Sam Feifer via

Re: [PATCH] match.pd: Add new abs pattern [PR94290]

2022-07-18 Thread Sam Feifer via Gcc-patches
; +__attribute__((noipa)) unsigned int foo(int x) { > >> >> > +return x <= 0 ? -x : 0; > >> >> > +} > >> >> > + > >> >> > +/* Changed order. */ > >> >> > +__attribute__((noipa)) unsigned int bar(int x) { &

Re: [PATCH] match.pd: Add new abs pattern [PR94290]

2022-07-18 Thread Sam Feifer via Gcc-patches
Just realized I had mixed up the 9 and the 2 when labelling the patch. This patch is referring to pr94920 not pr94290. Attached is a fixed patch file. Sorry for any confusion. On Mon, Jul 18, 2022 at 9:07 AM Sam Feifer wrote: > Here's an updated version of the patch. > > Thanks > -Sam > > On Thu

Re: [PATCH] match.pd: Add new abs pattern [PR94290]

2022-07-18 Thread Richard Biener via Gcc-patches
On Mon, Jul 18, 2022 at 7:31 PM Sam Feifer via Gcc-patches wrote: > > Just realized I had mixed up the 9 and the 2 when labelling the patch. This > patch is referring to pr94920 not pr94290. Attached is a fixed patch file. > Sorry for any confusion. Can you put the patterns somewhere related? Th

Re: [PATCH] match.pd: Add new abs pattern [PR94290]

2022-07-19 Thread Sam Feifer via Gcc-patches
Attached is a patch file with those changes. Thanks -Sam On Tue, Jul 19, 2022 at 2:36 AM Richard Biener wrote: > On Mon, Jul 18, 2022 at 7:31 PM Sam Feifer via Gcc-patches > wrote: > > > > Just realized I had mixed up the 9 and the 2 when labelling the patch. > This > > patch is referring to p