From: Martin Jambor <mjambor@suse.cz>
To: Richard Sandiford <richard.sandiford@arm.com>
Cc: Segher Boessenkool <segher@kernel.crashing.org>,
Tejas Joshi <tejasjoshi9673@gmail.com>,
gcc@gcc.gnu.org, hubicka@ucw.cz, joseph@codesourcery.com
Subject: Re: Expansion of narrowing math built-ins into power instructions
Date: Mon, 26 Aug 2019 13:23:00 -0000 [thread overview]
Message-ID: <ri6ef18cb6m.fsf@suse.cz> (raw)
In-Reply-To: <mptimqmvqit.fsf@arm.com>
Hi,
On Sat, Aug 24 2019, Richard Sandiford wrote:
> Martin Jambor <mjambor@suse.cz> writes:
...
>>
>> 2. direct_internal_fn_supported_p on which replacement_internal_fn
>> depends to expand built-ins as internal functions cannot handle
>> conversion optabs... and narrowing is a kind of conversion and the
>> optab is added as such with OPTAB_CD.
>>
>> Actually, the second statement is not entirely true because somehow it
>> can handle optab while_ult which is a conversion optab but a) the way it
>> is handled, if I can understand it at all, seems to be a big hack and
>> would be even worse if we decided to copy that for all narrowing math
>> functions
>
> Think "big hack" is a bit unfair. The way that the internal function
> maps argument types to the optab modes, and the way it expands calls
> into rtl, depends on the "optab type" argument (the final argument to
> DEF_INTERNAL_OPTAB_FN). This is relatively flexible in that it can use
> a single-mode "direct" optab or a dual-mode "conversion" optab, with the
> modes coming from whichever arguments are appropriate. New optab types
> can be added as needed.
My apologies. I guess I should have been more careful with my choice of
words when perhaps I did not understand all aspects but when I saw:
#define direct_while_optab_supported_p convert_optab_supported_p
(and when I saw expand_while_optab_fn defined normally while all(?)
other were constructed in an elaborate macro), I thought that I did not
want to replicate the mechanism, not for a number of functions.
>
> FWIW, several other DEF_INTERNAL_OPTAB_FNs are conversion optabs too
> (e.g. IFN_LOAD_LANES, IFN_STORE_LANES, IFN_MASK_LOAD, etc.).
>
> But...
>
>> and b) it gets both modes from argument types whereas we need one from
>> the result type and so we would have to rewrite
>> replacement_internal_fn anyway.
>
> ...yeah, I agree this breaks the current model. The reason IFN_WHILE_ULT
> doesn't rely on the return type is that if you have:
>
> _2 = .WHILE_ULT (_0, _1) // returning a vector of 4 booleans
> _3 = .WHILE_ULT (_0, _1) // returning a vector of 8 booleans
>
> then the calls look equivalent. So instead we pass an extra argument
> indicating the required boolean vector "shape".
>
> The same "problem" could in principle apply to FADD if we ever needed
> to support double+double->_Float16 for example.
Right. I hope not going through an internal function is acceptable. If
not, we'll have to teach this builtin->internal_funcxtion->optab
mechanism about conversions.
Thanks,
Martin
>
>> Therefore, at least for now (GSoC deadline is kind of looming), I
>> decided that the best way forward would be to not rely on internal
>> functions but plug into expand_builtin() and I wrote the following,
>> lightly tested patch - which of course misses testcases and stuff - but
>> I'd be curious about any feedback now anyway. When I proposed a very
>> similar approach for the roundeven x86_64 expansion, Uros actually then
>> opted for a solution based on internal functions, so I am curious
>> whether there are simple alternatives I do not see.
>>
>> Tejas, of course cases for other fadd variants should at least be added
>> to expand_builtin.
>>
>> Thanks,
>>
>> Martin
>>
>>
>> 2019-08-23 Tejas Joshi <tejasjoshi9673@gmail.com>
>> Martin Jambor <mjambor@suse.cz>
>>
>> * builtins.c (expand_builtin_binary_conversion): New function.
>> (expand_builtin): Call it.
>> * config/rs6000/rs6000.md (unspec): Add UNSPEC_ADD_NARROWING.
>> (add_truncdfsf3): New define_insn.
>> * optabs.def (fadd_optab): New.
>>
next prev parent reply other threads:[~2019-08-26 13:23 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-29 17:37 Martin Jambor
2019-07-29 18:40 ` Segher Boessenkool
2019-07-30 19:47 ` Joseph Myers
2019-07-30 9:20 ` Florian Weimer
2019-07-30 19:49 ` Joseph Myers
2019-07-31 6:47 ` Tejas Joshi
2019-07-31 14:47 ` Segher Boessenkool
2019-08-08 18:39 ` Tejas Joshi
2019-08-08 20:05 ` Segher Boessenkool
2019-08-08 23:09 ` Joseph Myers
2019-08-10 10:24 ` Tejas Joshi
2019-08-10 16:46 ` Segher Boessenkool
2019-08-11 4:58 ` Tejas Joshi
2019-08-11 7:20 ` Segher Boessenkool
2019-08-11 12:46 ` Tejas Joshi
2019-08-11 16:59 ` Segher Boessenkool
2019-08-12 17:25 ` Tejas Joshi
2019-08-12 17:55 ` Segher Boessenkool
2019-08-12 21:20 ` Joseph Myers
2019-08-12 21:52 ` Segher Boessenkool
2019-08-14 6:15 ` Tejas Joshi
2019-08-14 7:21 ` Segher Boessenkool
2019-08-14 16:11 ` Joseph Myers
2019-08-14 20:21 ` Segher Boessenkool
2019-08-14 20:23 ` Joseph Myers
2019-08-14 21:00 ` Segher Boessenkool
2019-08-15 9:52 ` Tejas Joshi
2019-08-15 12:47 ` Richard Sandiford
2019-08-15 13:55 ` Tejas Joshi
2019-08-15 18:45 ` Segher Boessenkool
2019-08-16 10:23 ` Richard Sandiford
2019-08-17 5:40 ` Tejas Joshi
2019-08-17 8:21 ` Richard Sandiford
2019-08-19 10:46 ` Tejas Joshi
2019-08-19 13:07 ` Segher Boessenkool
2019-08-20 7:41 ` Richard Sandiford
2019-08-20 12:11 ` Segher Boessenkool
2019-08-20 12:59 ` Richard Sandiford
2019-08-20 13:46 ` Segher Boessenkool
2019-08-20 14:43 ` Richard Sandiford
2019-08-20 15:12 ` Richard Sandiford
2019-08-20 19:42 ` Segher Boessenkool
2019-08-21 17:20 ` Tejas Joshi
2019-08-21 18:28 ` Segher Boessenkool
2019-08-21 19:17 ` Segher Boessenkool
2019-08-22 3:33 ` Tejas Joshi
2019-08-22 6:25 ` Segher Boessenkool
2019-08-22 7:57 ` Tejas Joshi
2019-08-22 9:56 ` Segher Boessenkool
2019-08-23 17:17 ` Martin Jambor
2019-08-23 19:13 ` Segher Boessenkool
2019-08-24 9:53 ` Richard Sandiford
2019-08-25 13:55 ` Tejas Joshi
2019-08-25 16:47 ` Segher Boessenkool
2019-08-26 7:07 ` Tejas Joshi
2019-08-26 7:42 ` Segher Boessenkool
2019-08-30 19:12 ` Tejas Joshi
2019-08-30 20:35 ` Segher Boessenkool
2019-09-02 3:19 ` Tejas Joshi
2019-09-02 11:30 ` Segher Boessenkool
2019-08-26 13:23 ` Martin Jambor [this message]
2019-08-20 16:04 ` Joseph Myers
2019-08-15 18:54 ` Segher Boessenkool
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ri6ef18cb6m.fsf@suse.cz \
--to=mjambor@suse.cz \
--cc=gcc@gcc.gnu.org \
--cc=hubicka@ucw.cz \
--cc=joseph@codesourcery.com \
--cc=richard.sandiford@arm.com \
--cc=segher@kernel.crashing.org \
--cc=tejasjoshi9673@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).