public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Fwd: How to gimplify_build a  FMA_EXPR since it was removed?
@ 2019-02-04 12:46 Laurent Thévenoux
  2019-02-04 22:38 ` Andrew Pinski
  0 siblings, 1 reply; 5+ messages in thread
From: Laurent Thévenoux @ 2019-02-04 12:46 UTC (permalink / raw)
  To: gcc

Sorry for duplicate, gcc-help was not the right mailing list for this one.


-------- Original Message --------
Subject: How to gimplify_build a FMA_EXPR since it was removed?
Date: Monday, February 04, 2019 13:28 CET
From: Laurent Thévenoux <lrnt@thvnx.com>
To: gcc-help@gcc.gnu.org
CC: richard.sandiford@linaro.org



Hi,

I've developed some code in gcc/tree-complex.c. I was using the
FMA_EXPR to generate fma operations such as in:

```
rr  = gimplify_build3 (gsi, FMA_EXPR, inner_type, ai, ai, p1r);```

FMA_EXPR was removed in https://gcc.gnu.org/ml/gcc-patches/2018-05/msg00570.html.

Is there an easy way to gimplify FMAs with the new functions
introduced in the patch below?

Thanks,
Laurent

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to gimplify_build a FMA_EXPR since it was removed?
  2019-02-04 12:46 Fwd: How to gimplify_build a FMA_EXPR since it was removed? Laurent Thévenoux
@ 2019-02-04 22:38 ` Andrew Pinski
  2019-02-04 23:13   ` Laurent Thévenoux
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Pinski @ 2019-02-04 22:38 UTC (permalink / raw)
  To: Laurent Thévenoux; +Cc: GCC Mailing List

On Mon, Feb 4, 2019 at 4:47 AM Laurent Thévenoux <lrnt@thvnx.com> wrote:
>
> Sorry for duplicate, gcc-help was not the right mailing list for this one.
>
>
> -------- Original Message --------
> Subject: How to gimplify_build a FMA_EXPR since it was removed?
> Date: Monday, February 04, 2019 13:28 CET
> From: Laurent Thévenoux <lrnt@thvnx.com>
> To: gcc-help@gcc.gnu.org
> CC: richard.sandiford@linaro.org
>
>
>
> Hi,
>
> I've developed some code in gcc/tree-complex.c. I was using the
> FMA_EXPR to generate fma operations such as in:
>
> ```
> rr  = gimplify_build3 (gsi, FMA_EXPR, inner_type, ai, ai, p1r);```
>
> FMA_EXPR was removed in https://gcc.gnu.org/ml/gcc-patches/2018-05/msg00570.html.
>
> Is there an easy way to gimplify FMAs with the new functions
> introduced in the patch below?

From that patch (e.g. rs6000_gimple_fold_builtin):

- gimple *g = gimple_build_assign (lhs, FMA_EXPR, arg0, arg1, arg2);
+ gcall *g = gimple_build_call_internal (IFN_FMA, 3, arg0, arg1, arg2);
+ gimple_call_set_lhs (g, lhs);
+ gimple_call_set_nothrow (g, true);


Thanks,
Andrew Pinski


>
> Thanks,
> Laurent
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to gimplify_build a FMA_EXPR since it was removed?
  2019-02-04 22:38 ` Andrew Pinski
@ 2019-02-04 23:13   ` Laurent Thévenoux
  2019-02-04 23:34     ` Andrew Pinski
  0 siblings, 1 reply; 5+ messages in thread
From: Laurent Thévenoux @ 2019-02-04 23:13 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: GCC Mailing List

Hi,

Thanks for pointing this me out. Nevertheless, I’m not sure this can apply in my case since gimple_build_call_internal() returns a gimple data type while gimplify_build3() returns a tree data type. I’ll try to figure how faisable is to use it in my case. For more context, see the code snippet below.

```
static void
some_fn (gimple_stmt_iterator *gsi, tree inner_type, tree ar, tree ai, tree br, tree bi)
{
  tree rr, ri, pr1;

  p1r = gimplify_build2 (gsi, MULT_EXPR, inner_type, ar, ar);
  rr  = gimplify_build3 (gsi, FMA_EXPR, inner_type, ai, ai, p1r);
  ri  = build_real (inner_type, dconst0);
  update_complex_assignment (gsi, rr, ri);
}

```

> Le 4 févr. 2019 à 23:38, Andrew Pinski <pinskia@gmail.com> a écrit :
> 
> On Mon, Feb 4, 2019 at 4:47 AM Laurent Thévenoux <lrnt@thvnx.com> wrote:
>> 
>> Sorry for duplicate, gcc-help was not the right mailing list for this one.
>> 
>> 
>> -------- Original Message --------
>> Subject: How to gimplify_build a FMA_EXPR since it was removed?
>> Date: Monday, February 04, 2019 13:28 CET
>> From: Laurent Thévenoux <lrnt@thvnx.com>
>> To: gcc-help@gcc.gnu.org
>> CC: richard.sandiford@linaro.org
>> 
>> 
>> 
>> Hi,
>> 
>> I've developed some code in gcc/tree-complex.c. I was using the
>> FMA_EXPR to generate fma operations such as in:
>> 
>> ```
>> rr  = gimplify_build3 (gsi, FMA_EXPR, inner_type, ai, ai, p1r);```
>> 
>> FMA_EXPR was removed in https://gcc.gnu.org/ml/gcc-patches/2018-05/msg00570.html.
>> 
>> Is there an easy way to gimplify FMAs with the new functions
>> introduced in the patch below?
> 
> From that patch (e.g. rs6000_gimple_fold_builtin):
> 
> - gimple *g = gimple_build_assign (lhs, FMA_EXPR, arg0, arg1, arg2);
> + gcall *g = gimple_build_call_internal (IFN_FMA, 3, arg0, arg1, arg2);
> + gimple_call_set_lhs (g, lhs);
> + gimple_call_set_nothrow (g, true);
> 
> 
> Thanks,
> Andrew Pinski
> 
> 
>> 
>> Thanks,
>> Laurent

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to gimplify_build a FMA_EXPR since it was removed?
  2019-02-04 23:13   ` Laurent Thévenoux
@ 2019-02-04 23:34     ` Andrew Pinski
  2019-02-06 18:21       ` Laurent Thévenoux
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Pinski @ 2019-02-04 23:34 UTC (permalink / raw)
  To: Laurent Thévenoux; +Cc: GCC Mailing List

On Mon, Feb 4, 2019 at 3:13 PM Laurent Thévenoux <lrnt@thvnx.com> wrote:
>
> Hi,
>
> Thanks for pointing this me out. Nevertheless, I’m not sure this can apply in my case since gimple_build_call_internal() returns a gimple data type while gimplify_build3() returns a tree data type. I’ll try to figure how faisable is to use it in my case. For more context, see the code snippet below.

You need to create a new temp ssa name to hold the FMA results.  There
are few examples in the tree-ssa-phi-opt.c code for on how to use this
way instead of using gimplify_build3.

Thanks,
Andrew Pinski

>
> ```
> static void
> some_fn (gimple_stmt_iterator *gsi, tree inner_type, tree ar, tree ai, tree br, tree bi)
> {
>   tree rr, ri, pr1;
>
>   p1r = gimplify_build2 (gsi, MULT_EXPR, inner_type, ar, ar);
>   rr  = gimplify_build3 (gsi, FMA_EXPR, inner_type, ai, ai, p1r);
>   ri  = build_real (inner_type, dconst0);
>   update_complex_assignment (gsi, rr, ri);
> }
>
> ```
>
> > Le 4 févr. 2019 à 23:38, Andrew Pinski <pinskia@gmail.com> a écrit :
> >
> > On Mon, Feb 4, 2019 at 4:47 AM Laurent Thévenoux <lrnt@thvnx.com> wrote:
> >>
> >> Sorry for duplicate, gcc-help was not the right mailing list for this one.
> >>
> >>
> >> -------- Original Message --------
> >> Subject: How to gimplify_build a FMA_EXPR since it was removed?
> >> Date: Monday, February 04, 2019 13:28 CET
> >> From: Laurent Thévenoux <lrnt@thvnx.com>
> >> To: gcc-help@gcc.gnu.org
> >> CC: richard.sandiford@linaro.org
> >>
> >>
> >>
> >> Hi,
> >>
> >> I've developed some code in gcc/tree-complex.c. I was using the
> >> FMA_EXPR to generate fma operations such as in:
> >>
> >> ```
> >> rr  = gimplify_build3 (gsi, FMA_EXPR, inner_type, ai, ai, p1r);```
> >>
> >> FMA_EXPR was removed in https://gcc.gnu.org/ml/gcc-patches/2018-05/msg00570.html.
> >>
> >> Is there an easy way to gimplify FMAs with the new functions
> >> introduced in the patch below?
> >
> > From that patch (e.g. rs6000_gimple_fold_builtin):
> >
> > - gimple *g = gimple_build_assign (lhs, FMA_EXPR, arg0, arg1, arg2);
> > + gcall *g = gimple_build_call_internal (IFN_FMA, 3, arg0, arg1, arg2);
> > + gimple_call_set_lhs (g, lhs);
> > + gimple_call_set_nothrow (g, true);
> >
> >
> > Thanks,
> > Andrew Pinski
> >
> >
> >>
> >> Thanks,
> >> Laurent
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to gimplify_build a  FMA_EXPR since it was removed?
  2019-02-04 23:34     ` Andrew Pinski
@ 2019-02-06 18:21       ` Laurent Thévenoux
  0 siblings, 0 replies; 5+ messages in thread
From: Laurent Thévenoux @ 2019-02-06 18:21 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: GCC Mailing List

Hi Andrew,

Thanks again for your help! Unfortunately I didn't manage to replace gimplify_build3() yet. To give you a bit more of context, this is what I've tried so far:

I'm trying to implement something similar to gimplify_build3():
```
tree
gimplify_build3 (gimple_stmt_iterator *gsi, enum tree_code code,
		 tree type, tree a, tree b, tree c)
{
 tree ret;
 location_t loc = gimple_location (gsi_stmt (*gsi));

 ret = fold_build3_loc (loc, code, type, a, b, c);
 return force_gimple_operand_gsi (gsi, ret, true, NULL, true,
                                  GSI_SAME_STMT);
}
```
such as:
```
tree
gimplify_buildfma (gimple_stmt_iterator *gsi, internal_fn fn
		 tree type, tree a, tree b, tree c)
{
 tree ret;
 location_t loc = gimple_location (gsi_stmt (*gsi));

 // TODO: check that fn is in [IFN_FMA, IFN_FMS, IFN_FNMA, IFN_FNMS]

 gcall *g = gimple_build_call_internal (fn, 3, a, b, c);
 gimple_set_location (g, loc);

 ret = ???

 return force_gimple_operand_gsi (gsi, ret, true, NULL, true,
                                  GSI_SAME_STMT);
}
```
but I don't understand how to set `ret` from `g`. Do you have any idea?

If you need to understand why I’m trying to do this, please see:
  <https://github.com/thvnx/gcc/commit/47761af29f2bceb8e9404737bfb7d613a30eeebf <https://github.com/thvnx/gcc/commit/47761af29f2bceb8e9404737bfb7d613a30eeebf>>.

Thanks,
Laurent


On Tuesday, February 05, 2019 00:33 CET, Andrew Pinski <pinskia@gmail.com> wrote:

> On Mon, Feb 4, 2019 at 3:13 PM Laurent Thévenoux <lrnt@thvnx.com> wrote:
>> 
>> Hi,
>> 
>> Thanks for pointing this me out. Nevertheless, I’m not sure this can apply in my case since gimple_build_call_internal() returns a gimple data type while gimplify_build3() returns a tree data type. I’ll try to figure how faisable is to use it in my case. For more context, see the code snippet below.
> 
> You need to create a new temp ssa name to hold the FMA results.  There
> are few examples in the tree-ssa-phi-opt.c code for on how to use this
> way instead of using gimplify_build3.
> 
> Thanks,
> Andrew Pinski
> 
>> 
>> ```
>> static void
>> some_fn (gimple_stmt_iterator *gsi, tree inner_type, tree ar, tree ai, tree br, tree bi)
>> {
>>  tree rr, ri, pr1;
>> 
>>  p1r = gimplify_build2 (gsi, MULT_EXPR, inner_type, ar, ar);
>>  rr  = gimplify_build3 (gsi, FMA_EXPR, inner_type, ai, ai, p1r);
>>  ri  = build_real (inner_type, dconst0);
>>  update_complex_assignment (gsi, rr, ri);
>> }
>> 
>> ```
>> 
>>> Le 4 févr. 2019 à 23:38, Andrew Pinski <pinskia@gmail.com> a écrit :
>>> 
>>> On Mon, Feb 4, 2019 at 4:47 AM Laurent Thévenoux <lrnt@thvnx.com> wrote:
>>>> 
>>>> Sorry for duplicate, gcc-help was not the right mailing list for this one.
>>>> 
>>>> 
>>>> -------- Original Message --------
>>>> Subject: How to gimplify_build a FMA_EXPR since it was removed?
>>>> Date: Monday, February 04, 2019 13:28 CET
>>>> From: Laurent Thévenoux <lrnt@thvnx.com>
>>>> To: gcc-help@gcc.gnu.org
>>>> CC: richard.sandiford@linaro.org
>>>> 
>>>> 
>>>> 
>>>> Hi,
>>>> 
>>>> I've developed some code in gcc/tree-complex.c. I was using the
>>>> FMA_EXPR to generate fma operations such as in:
>>>> 
>>>> ```
>>>> rr  = gimplify_build3 (gsi, FMA_EXPR, inner_type, ai, ai, p1r);```
>>>> 
>>>> FMA_EXPR was removed in https://gcc.gnu.org/ml/gcc-patches/2018-05/msg00570.html.
>>>> 
>>>> Is there an easy way to gimplify FMAs with the new functions
>>>> introduced in the patch below?
>>> 
>>> From that patch (e.g. rs6000_gimple_fold_builtin):
>>> 
>>> - gimple *g = gimple_build_assign (lhs, FMA_EXPR, arg0, arg1, arg2);
>>> + gcall *g = gimple_build_call_internal (IFN_FMA, 3, arg0, arg1, arg2);
>>> + gimple_call_set_lhs (g, lhs);
>>> + gimple_call_set_nothrow (g, true);
>>> 
>>> 
>>> Thanks,
>>> Andrew Pinski
>>> 
>>> 
>>>> 
>>>> Thanks,
>>>> Laurent
>> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-02-06 18:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-04 12:46 Fwd: How to gimplify_build a FMA_EXPR since it was removed? Laurent Thévenoux
2019-02-04 22:38 ` Andrew Pinski
2019-02-04 23:13   ` Laurent Thévenoux
2019-02-04 23:34     ` Andrew Pinski
2019-02-06 18:21       ` Laurent Thévenoux

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).