From: kugan <kugan.vivekanandarajah@linaro.org>
To: Richard Biener <richard.guenther@gmail.com>,
Jim Wilson <jim.wilson@linaro.org>
Cc: Jeff Law <law@redhat.com>, Michael Matz <matz@suse.de>,
"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [4/7] Use correct promoted mode sign for result of GIMPLE_CALL
Date: Wed, 07 Oct 2015 01:03:00 -0000 [thread overview]
Message-ID: <56146F6B.9050509@linaro.org> (raw)
In-Reply-To: <CAFiYyc1OeBCzs-x8HXYkO_Rq22WrWd2DW9+VcFAxgQ5wBpd+0A@mail.gmail.com>
On 15/09/15 22:47, Richard Biener wrote:
> On Tue, Sep 8, 2015 at 11:50 PM, Jim Wilson <jim.wilson@linaro.org> wrote:
>> On 09/08/2015 08:39 AM, Jeff Law wrote:
>>> Is this another instance of the PROMOTE_MODE issue that was raised by
>>> Jim Wilson a couple months ago?
>>
>> It looks like a closely related problem. The one I am looking at has
>> confusion with a function arg and a local variable as they have
>> different sign extension promotion rules. Kugan's is with a function
>> return value and a local variable as they have different sign extension
>> promotion rules.
>>
>> The bug report is
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65932
>>
>> The gcc-patches thread spans a month end boundary, so it has multiple heads
>> https://gcc.gnu.org/ml/gcc-patches/2015-06/msg02132.html
>> https://gcc.gnu.org/ml/gcc-patches/2015-07/msg00112.html
>> https://gcc.gnu.org/ml/gcc-patches/2015-07/msg00524.html
>>
>> Function args and function return values get the same sign extension
>> treatment when promoted, this is handled by
>> TARGET_PROMOTE_FUNCTION_MODE. Local variables are treated differently,
>> via PROMOTE_MODE. I think the function arg/return treatment is wrong,
>> but changing that is an ABI change which is undesirable. I suppose we
>> could change local variables to match function args and return values,
>> but I think that is moving in the wrong direction. Though Kugan's new
>> optimization pass will remove some of the extra unnecessary sign/zero
>> extensions added by the arm TARGET_PROMOTE_FUNCTION_MODE definition, so
>> maybe it won't matter enough to worry about any more.
>>
>> If we can't fix this in the arm backend, then we may need different
>> middle fixes for these two cases. I was looking at ways to fix this in
>> the tree-out-of-ssa pass. I don't know if this will work for Kugan's
>> testcase, I'd need time to look at it.
As you said, I dont think the fix in tree-out-of-ssa pass will not fix
this case. Kyrill also saw the same problem with the trunk as in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67714
>
> I think the function return value should have been "promoted" according to
> the ABI by the lowering pass. Thus the call stmt return type be changed,
> exposing the "mismatch" and compensating the IL with a sign-conversion.
>
Function return value is promoted as per ABI.
In the example from PR67714
....
_8 = fn1D.5055 ();
e_9 = (charD.4) _8;
f_13 = _8;
...
_8 is sign extended correctly. But in f_13 = _8, it is promoted to
unsigned and zero extended due to the backend PROMOTE_MODE. We thus have:
The zero-extension during expand:
;; f_13 = _8;
(insn 15 14 0 (set (reg/v:SI 110 [ f ])
(zero_extend:SI (subreg/u:QI (reg/v:SI 110 [ f ]) 0)))
arm-zext.c:18 -1
(nil))
This is wrong.
> As for your original issue with function arguments they should really
> get similar
> treatment, eventually in function arg gimplification already, by making
> the PARM_DECLs promoted and using a local variable for further uses
> with the "local" type. Eventually one can use DECL_VALUE_EXPR to fixup
> the IL, not sure. Or we can do this in the promotion pass as well.
>
I will try doing this see if I can do this.
Thanks,
Kugan
> Richard.
>
>> Jim
>>
next prev parent reply other threads:[~2015-10-07 1:03 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-07 2:55 [0/7] Type promotion pass and elimination of zext/sext Kugan
2015-09-07 2:57 ` [1/7] Add new tree code SEXT_EXPR Kugan
2015-09-15 13:20 ` Richard Biener
2015-10-11 10:35 ` Kugan
2015-10-12 12:22 ` Richard Biener
2015-10-15 5:49 ` Kugan
2015-10-21 10:49 ` Richard Biener
2015-09-07 2:58 ` [2/7] Add new type promotion pass Kugan
2015-10-15 5:52 ` Kugan
2015-10-15 22:47 ` Richard Henderson
2015-09-07 3:00 ` [3/7] Optimize ZEXT_EXPR with tree-vrp Kugan
2015-09-15 13:18 ` Richard Biener
2015-10-06 23:12 ` kugan
2015-10-07 8:20 ` Richard Biener
2015-10-07 23:40 ` Kugan
2015-10-09 10:29 ` Richard Biener
2015-10-11 2:56 ` Kugan
2015-10-12 12:13 ` Richard Biener
2015-09-07 3:01 ` [4/7] Use correct promoted mode sign for result of GIMPLE_CALL Kugan
2015-09-07 13:16 ` Michael Matz
2015-09-08 0:00 ` Kugan
2015-09-08 15:45 ` Jeff Law
2015-09-08 22:09 ` Jim Wilson
2015-09-15 12:51 ` Richard Biener
2015-10-07 1:03 ` kugan [this message]
2015-09-07 3:01 ` [5/7] Allow gimple debug stmt in widen mode Kugan
2015-09-07 13:46 ` Michael Matz
2015-09-08 0:01 ` Kugan
2015-09-15 13:02 ` Richard Biener
2015-10-15 5:45 ` Kugan
2015-10-16 9:27 ` Richard Biener
2015-10-18 20:51 ` Kugan
2015-09-07 3:03 ` [6/7] Temporary workaround to get aarch64 bootstrap Kugan
2015-09-07 3:03 ` [5/7] Allow gimple debug stmt in widen mode Kugan
2015-09-07 5:54 ` [7/7] Adjust-arm-test cases Kugan
2015-11-02 11:43 ` Richard Earnshaw
2015-10-20 20:13 ` [0/7] Type promotion pass and elimination of zext/sext Kugan
2015-10-21 12:56 ` Richard Biener
2015-10-21 13:57 ` Richard Biener
2015-10-21 17:17 ` Joseph Myers
2015-10-21 18:11 ` Richard Henderson
2015-10-22 12:48 ` Richard Biener
2015-10-22 11:01 ` Kugan
2015-10-22 14:24 ` Richard Biener
2015-10-27 1:48 ` kugan
2015-10-28 15:51 ` Richard Biener
2015-11-02 9:17 ` Kugan
2015-11-03 14:40 ` Richard Biener
2015-11-08 9:43 ` Kugan
2015-11-10 14:13 ` Richard Biener
2015-11-12 6:08 ` Kugan
2015-11-14 1:15 ` Kugan
2015-11-18 14:04 ` Richard Biener
2015-11-18 15:06 ` Richard Biener
2015-11-24 2:52 ` Kugan
2015-12-10 0:27 ` Kugan
2015-12-16 13:18 ` Richard Biener
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=56146F6B.9050509@linaro.org \
--to=kugan.vivekanandarajah@linaro.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=jim.wilson@linaro.org \
--cc=law@redhat.com \
--cc=matz@suse.de \
--cc=richard.guenther@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).