Re: [PATCH] MATCH: add abs support for half float

2024-09-25 Thread Richard Biener
On Wed, Sep 25, 2024 at 12:12 PM Kugan Vivekanandarajah wrote: > > Hi Richard, > > > On 24 Sep 2024, at 6:16 pm, Richard Biener > > wrote: > > > > External email: Use caution opening links or attachments > > > > > > On Mon, Sep 23, 2024 at 10:52 AM Kugan Vivekanandarajah > > wrote: > >> > >> Hi

Re: [PATCH] MATCH: add abs support for half float

2024-09-24 Thread Richard Biener
On Mon, Sep 23, 2024 at 10:52 AM Kugan Vivekanandarajah wrote: > > Hi Richard, > > > On 20 Sep 2024, at 8:11 pm, Richard Biener > > wrote: > > > > External email: Use caution opening links or attachments > > > > > > On Fri, Sep 20, 2024 at 10:23 AM Kugan Vivekanandarajah > > wrote: > >> > >> Hi

Re: [PATCH] MATCH: add abs support for half float

2024-09-20 Thread Richard Biener
On Fri, Sep 20, 2024 at 10:23 AM Kugan Vivekanandarajah wrote: > > Hi Richard, > > > On 17 Sep 2024, at 7:36 pm, Richard Biener > > wrote: > > > > External email: Use caution opening links or attachments > > > > > > On Tue, Sep 17, 2024 at 10:31 AM Kugan Vivekanandarajah > > wrote: > >> > >> Hi

Re: [PATCH] MATCH: add abs support for half float

2024-09-20 Thread Kugan Vivekanandarajah
Hi Richard, > On 17 Sep 2024, at 7:36 pm, Richard Biener wrote: > > External email: Use caution opening links or attachments > > > On Tue, Sep 17, 2024 at 10:31 AM Kugan Vivekanandarajah > wrote: >> >> Hi Richard, >> >>> On 10 Sep 2024, at 9:33 pm, Richard Biener >>> wrote: >>> >>> External em

Re: [PATCH] MATCH: add abs support for half float

2024-09-17 Thread Richard Biener
On Tue, Sep 17, 2024 at 10:31 AM Kugan Vivekanandarajah wrote: > > Hi Richard, > > > On 10 Sep 2024, at 9:33 pm, Richard Biener > > wrote: > > > > External email: Use caution opening links or attachments > > > > > > On Thu, Sep 5, 2024 at 3:19 AM Kugan Vivekanandarajah > > wrote: > >> > >> Than

Re: [PATCH] MATCH: add abs support for half float

2024-09-17 Thread Kugan Vivekanandarajah
Hi Richard, > On 10 Sep 2024, at 9:33 pm, Richard Biener wrote: > > External email: Use caution opening links or attachments > > > On Thu, Sep 5, 2024 at 3:19 AM Kugan Vivekanandarajah > wrote: >> >> Thanks for the explanation. >> >> >>> On 2 Sep 2024, at 9:47 am, Andrew Pinski wrote: >>>

Re: [PATCH] MATCH: add abs support for half float

2024-09-10 Thread Richard Biener
On Thu, Sep 5, 2024 at 3:19 AM Kugan Vivekanandarajah wrote: > > Thanks for the explanation. > > > > On 2 Sep 2024, at 9:47 am, Andrew Pinski wrote: > > > > External email: Use caution opening links or attachments > > > > > > On Sun, Sep 1, 2024 at 4:27 PM Kugan Vivekanandarajah > > wrote: > >>

Re: [PATCH] MATCH: add abs support for half float

2024-09-04 Thread Kugan Vivekanandarajah
Thanks for the explanation. > On 2 Sep 2024, at 9:47 am, Andrew Pinski wrote: > > External email: Use caution opening links or attachments > > > On Sun, Sep 1, 2024 at 4:27 PM Kugan Vivekanandarajah > wrote: >> >> Hi Andrew. >> >>> On 28 Aug 2024, at 2:23 pm, Andrew Pinski wrote: >>> >>> Exter

Re: [PATCH] MATCH: add abs support for half float

2024-09-01 Thread Andrew Pinski
On Sun, Sep 1, 2024 at 4:27 PM Kugan Vivekanandarajah wrote: > > Hi Andrew. > > > On 28 Aug 2024, at 2:23 pm, Andrew Pinski wrote: > > > > External email: Use caution opening links or attachments > > > > > > On Tue, Aug 27, 2024 at 8:54 PM Kugan Vivekanandarajah > > wrote: > >> > >> Hi Richard,

Re: [PATCH] MATCH: add abs support for half float

2024-09-01 Thread Kugan Vivekanandarajah
gt;>>>>> >>>>>>>>>> && !TYPE_UNSIGNED (TREE_TYPE (@2)) >>>>>>>>>> && ((element_precision (TREE_TYPE (@1)) >>>>>>>>>> < element_precision (TREE_TYPE (@0)) >

Re: [PATCH] MATCH: add abs support for half float

2024-08-27 Thread Andrew Pinski
seeing: Note that the @2 for these are > >>>>>>>> unsigned. > >>>>>>> > >>>>>>> I see, so we rely on @1 being the signed equivalent of @2 which might > >>>>>>> or > >>>>>>> might not be signed. I gues

Re: [PATCH] MATCH: add abs support for half float

2024-08-27 Thread Kugan Vivekanandarajah
t;>> >>>>>>>> However with this, I am seeing: Note that the @2 for these are >>>>>>>> unsigned. >>>>>>> >>>>>>> I see, so we rely on @1 being the signed equivalent of @2 which

Re: [PATCH] MATCH: add abs support for half float

2024-08-27 Thread Richard Biener
ter then. > >>>>> > >>>>> > >>>>>> && bitwise_equal_p (@1, @2)) > >>>>>> (if (TYPE_UNSIGNED (type)) > >>>>>>(absu:type @2) > >>>>>>(abs @2) > >>>>>

Re: [PATCH] MATCH: add abs support for half float

2024-08-26 Thread Kugan Vivekanandarajah
; (simplify >>>>>> (cnd (cmp (convert?@0 @1) zerop) @2 (negate @2)) >>>>>> (if (!HONOR_SIGNED_ZEROS (TREE_TYPE (@1)) >>>>>> && !TYPE_UNSIGNED (TREE_TYPE (@1)) >>>>> >>>>> Oh, I mis-read this as

Re: [PATCH] MATCH: add abs support for half float

2024-08-22 Thread Richard Biener
>>> || operand_equal_p (@1, @0))) > >>> > >>> which means <= might be better then. > >>> > >>> > >>>>&& bitwise_equal_p (@1, @2)) > >>>>(if (TYPE_UNSIGNED (type)) > >>

Re: [PATCH] MATCH: add abs support for half float

2024-08-21 Thread Kugan Vivekanandarajah
er then. >>> >>> >>>>&& bitwise_equal_p (@1, @2)) >>>>(if (TYPE_UNSIGNED (type)) >>>> (absu:type @2) >>>> (abs @2) >>>> >>>> However with this, I am seeing: Note that the @2 fo

Re: [PATCH] MATCH: add abs support for half float

2024-08-20 Thread Richard Biener
< element_precision (TREE_TYPE (@0)) > >> || operand_equal_p (@1, @0))) > > > > which means <= might be better then. > > > > > >> && bitwise_equal_p (@1, @2)) > >> (if (TYPE_UNSIGNED (type)) > >> (abs

Re: [PATCH] MATCH: add abs support for half float

2024-08-08 Thread Kugan Vivekanandarajah
IGNED (TREE_TYPE (@1)) > > Oh, I mis-read this as unsigned, so this makes the conversions > to always sign-extend which means it's important to ensure > the type of @0 is also signed. > >> && !TYPE_UNSIGNED (TREE_TYPE (@2)) >> &

Re: [PATCH] MATCH: add abs support for half float

2024-08-02 Thread Richard Biener
recision case should have been stripped anyway. > > > > You can use element_precision for both vector and non-vector so I think this > > should simplify to just checking element_precision. > > > > + (absu:type @1) > > + (abs @1) > > > > I still think this needs to be @2 for ty

Re: [PATCH] MATCH: add abs support for half float

2024-08-02 Thread Kugan Vivekanandarajah
nslate to: /* (type)A >=/> 0 ? A : -A same as abs (A) */ (for cmp (ge gt) (simplify (cnd (cmp (convert?@0 @1) zerop) @2 (negate @2)) (if (!HONOR_SIGNED_ZEROS (TREE_TYPE (@1)) && !TYPE_UNSIGNED (TREE_TYPE (@1)) && !TYPE_UNSIGNED (TREE_TYPE (@2))

Re: [PATCH] MATCH: add abs support for half float

2024-08-01 Thread Richard Biener
) + <= element_precision (TREE_TYPE (@0))) + || (!VECTOR_TYPE_P (TREE_TYPE (@0)) + && (TYPE_PRECISION (TREE_TYPE (@1)) + <= TYPE_PRECISION (TREE_TYPE (@0) ... you make the precision strictly larger. With both unsigned the same

Re: [PATCH] MATCH: add abs support for half float

2024-07-31 Thread Kugan Vivekanandarajah
- (absu:type @0) - (abs @0) + (absu:type @1) + (abs @1) Changing the @1 to @2 is resulting in failures. Existing tests like the following would be optimized away in this case. ``` unsigned abs_with_convert0 (int x) { unsigned int y = x; if (x < 0) y = -y; return y; } ``` This follows the same intent as the

Re: [PATCH] MATCH: add abs support for half float

2024-07-29 Thread Richard Biener
; > ``` > And forwprop using match is able to do: > ``` > Applying pattern match.pd:6306, gimple-match-10.cc:19843 > gimple_simplified to _4 = ABS_EXPR ; > Removing dead stmt:_1 = a_2(D) > { 0, 0 }; > Removing dead stmt:na_3 = -a_2(D); > ``` > (replace int with float and add -fno-si

Re: [PATCH] MATCH: add abs support for half float

2024-07-29 Thread Andrew Pinski
vector(2) intD.9 _4; na_3 = -a_2(D); _1 = a_2(D) > { 0, 0 }; _4 = VEC_COND_EXPR <_1, a_2(D), na_3>; ``` And forwprop using match is able to do: ``` Applying pattern match.pd:6306, gimple-match-10.cc:19843 gimple_simplified to _4 = ABS_EXPR ; Removing dead stmt:_1 = a_2(D) > { 0, 0 }; Removing dead stmt

Re: [PATCH] MATCH: add abs support for half float

2024-07-29 Thread Kugan Vivekanandarajah
. Also, we dont seem to generate (cmp @0 zerop). Am I missing it completely? Thanks, Kugan > > > > > > > > > + (absu:type @1) > > > + (abs @1) > > > > > > I think this should use @2 now. > > I will change this. > >

Re: [PATCH] MATCH: add abs support for half float

2024-07-25 Thread Richard Biener
@2 now. > I will change this. > > Thanks, > Kugan > > > > > > Thanks. > > > Kugan > > > > > > > > (like what is in gcc.dg/c11-floatn-3.c and others). > > > > > > > > Other than that it looks good but I can

Re: [PATCH] MATCH: add abs support for half float

2024-07-24 Thread Kugan Vivekanandarajah
t; > > > > Thanks, > > > Andrew Pinski > > > > > > > > > > > Signed-off-by: Kugan Vivekanandarajah > > > > > > > > Bootstrapped and regression test on aarch64-linux-gnu. Is this OK for > > > > trunk? > > > > Tha

Re: [PATCH] MATCH: add abs support for half float

2024-07-23 Thread Richard Biener
-3.c and others). > > > > Other than that it looks good but I can't approve it. > > > > Thanks, > > Andrew Pinski > > > > > > > > Signed-off-by: Kugan Vivekanandarajah > > > > > > Bootstrapped and regression test on aarch6

Re: [PATCH] MATCH: add abs support for half float

2024-07-23 Thread Kugan Vivekanandarajah
Pinski > > Sent: Monday, 15 July 2024 5:30 AM > > To: Kugan Vivekanandarajah > > Cc: gcc-patches@gcc.gnu.org ; > > richard.guent...@gmail.com > > Subject: Re: [PATCH] MATCH: add abs support for half float > > > > External email: Use caution opening links or

Re: [PATCH] MATCH: add abs support for half float

2024-07-22 Thread Andrew Pinski
t; From: Andrew Pinski > Sent: Monday, 15 July 2024 5:30 AM > To: Kugan Vivekanandarajah > Cc: gcc-patches@gcc.gnu.org ; > richard.guent...@gmail.com > Subject: Re: [PATCH] MATCH: add abs support for half float > > External email: Use caution opening links or attachments >

Re: [PATCH] MATCH: add abs support for half float

2024-07-22 Thread Kugan Vivekanandarajah
: [PATCH] MATCH: add abs support for half float External email: Use caution opening links or attachments On Sun, Jul 14, 2024 at 1:12 AM Kugan Vivekanandarajah wrote: > > This patch extends abs detection in matched for half float. > > Bootstrapped and regression test on aarch64-linux-gnu

Re: [PATCH] MATCH: add abs support for half float

2024-07-14 Thread Andrew Pinski
On Sun, Jul 14, 2024 at 1:12 AM Kugan Vivekanandarajah wrote: > > This patch extends abs detection in matched for half float. > > Bootstrapped and regression test on aarch64-linux-gnu. Is this OK for trunk? This is basically this pattern: ``` /* A >=/> 0 ? A : -Asame as abs (A) */ (for cmp