[PATCH][PR90106] Builtin call transformation changes in cdce pass
JunMa
JunMa@linux.alibaba.com
Fri May 10 01:05:00 GMT 2019
å¨ 2019/5/10 ä¸å4:00, Jeff Law åé:
> On 5/8/19 8:25 PM, JunMa wrote:
>> å¨ 2019/5/9 ä¸å9:20, Bin.Cheng åé:
>>> On Thu, May 9, 2019 at 5:31 AM Jeff Law <law@redhat.com> wrote:
>>>> On 5/8/19 6:28 AM, Richard Biener wrote:
>>>>> On Wed, May 8, 2019 at 12:09 PM JunMa <JunMa@linux.alibaba.com> wrote:
>>>>>> Hi
>>>>>>
>>>>>> As PR90106 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90106),
>>>>>> when gcc meets builtin function call like:
>>>>>>
>>>>>> Â Â Â y = sqrt (x);
>>>>>>
>>>>>> The cdce pass tries to transform the call into an internal function
>>>>>> call and conditionally executes call with a simple range check on the
>>>>>> arguments which can detect most cases and the errno does not need
>>>>>> to be set. It looks like:
>>>>>>
>>>>>> Â Â Â y = IFN_SQRT (x);
>>>>>> Â Â Â if (__builtin_isless (x, 0))
>>>>>> Â Â Â Â Â sqrt (x);
>>>>>>
>>>>>> However, If the call is in tail position, for example:
>>>>>>
>>>>>> Â Â Â y =Â sqrt (x);
>>>>>> Â Â Â return y;
>>>>>>
>>>>>> will become:
>>>>>>
>>>>>> Â Â Â y = IFN_SQRT (x);
>>>>>> Â Â Â if (__builtin_isless (x, 0))
>>>>>> Â Â Â Â Â sqrt (x);
>>>>>> Â Â Â return y;
>>>>>>
>>>>>> This transformation breaks tailcall pattern, and prevents
>>>>>> later tailcall optimizations.
>>>>>>
>>>>>> So This patch transform builtin call with return value into
>>>>>> if-then-else part, which looks like:
>>>>>>
>>>>>> Â Â Â y =Â sqrt (x);
>>>>>> Â Â Â Â ==>
>>>>>> Â Â Â if (__builtin_isless (x, 0))
>>>>>> Â Â Â Â Â y = sqrt (x);
>>>>>> Â Â Â else
>>>>>> Â Â Â Â Â y = IFN_SQRT (x);
>>>>>>
>>>>>> BTW, y = sqrt (x) can also transform like:
>>>>>>
>>>>>> Â Â Â y = IFN_SQRT (x);
>>>>>> Â Â Â if (__builtin_isless (x, 0))
>>>>>> Â Â Â Â Â y = sqrt (x);
>>>>>>
>>>>>> We donât choose this pattern because it emits worse assemble
>>>>>> code(more move instruction and use more registers) in x86_64.
>>>>>>
>>>>>> Bootstrapped/regtested on x86_64-linux, ok for trunk?
>>>>> OK.
>>>> JunMa -- do you have a copyright assignment on file and write access to
>>>> the repository? If not we should take care of that before proceeding
>>>> further.
>>> Hi Jeff,
>>> Thanks very much for helping.
>>> Yes, he is under Alibaba's copyright assignment. What else should we
>>> do other than noticing in this mailing list message?
>>> BTW, I think JunMa needs to apply write-access though.
>> Yes, I do not have write access, FYI.
> OK. So in my response to Bin I gave you a link to the form to fill out
> to get write access. List me as your sponsor. Once that's all taken
> care of and working, go ahead and commit this change to the trunk.
Thanks!
JunMa
> Jeff
More information about the Gcc-patches
mailing list