From: Bernd Schmidt <bernds@codesourcery.com>
To: Eric Botcazou <ebotcazou@adacore.com>
Cc: gcc-patches@gcc.gnu.org, Paolo Bonzini <bonzini@gnu.org>,
Andrew Pinski <pinskia@gmail.com>
Subject: Re: Patch: PR40900, extending call patterns
Date: Tue, 08 Jun 2010 21:56:00 -0000 [thread overview]
Message-ID: <4C0EB9A5.6080907@codesourcery.com> (raw)
In-Reply-To: <201005051458.39945.ebotcazou@adacore.com>
On 05/05/2010 02:58 PM, Eric Botcazou wrote:
>> Seems to be because it's a signed operation, and arm has
>>
>> #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
>> if (GET_MODE_CLASS (MODE) == MODE_INT \
>> && GET_MODE_SIZE (MODE) < 4) \
>> { \
>> if (MODE == QImode) \
>> UNSIGNEDP = 1; \
>> else if (MODE == HImode) \
>> UNSIGNEDP = 1; \
>> (MODE) = SImode; \
>> }
>>
>> while ppc doesn't modify UNSIGNEDP.
>
> Can't we be clever during RTL expansion and avoid blindly zero-extending the
> value when we known that
>
> D.2014_1 = shortv2 ();
>
> and promote_function_mode sign-extends? The kind of extension for a specific
> variable can be changed since the SUBREG_PROMOTED_* machinery records it. In
> other words, can't we just override promote_decl_mode in the SSA_NAME case of
> expand_expr_real_1?
I've looked into this now, and I don't really see a way to do better at
rtl expansion time.
In current sources, the function ends up as
D.2006_1 = shortv2 (); [tail call]
return D.2006_1;
PROMOTE_MODE ensures that D.2006_1 becomes
#0 store_expr (exp=0xf7cbb5e8, target=0xf7d2c5ac, call_param_p=0,
nontemporal=0 '\000') at ../../trunk/gcc/expr.c:4582
4582 rtx inner_target = 0;
(gdb) p target(gdb) p debug_rtx (target)
(subreg/s/u:HI (reg:SI 133 [ D.2006 ]) 0)
We create zero-extensions around the CALL_EXPR in store_expr and call
expand_expr. At some point, in expand_call, we create a signed target:
(subreg/s:HI (reg:SI 136) 0)
which is returned from expand_call. This value then gets zero extended
due to the NOP_EXPRs around the call which were previously created in
store_expr. The zero extension makes it into initial RTL but is quickly
deleted as useless.
The value returned by the call to expand_expr in store_expr is simply
(reg:SI 133), with no hint that there was a sign-extended promoted
subreg available anywhere.
Later, during expand_return, we create the superfluous sign extension.
This seems unavoidable since
a) what we return is D.2006_1, i.e. a subreg of reg 133, so we no
longer see the subreg created by expand_call, and
b) even if we did see it, it had its SUBREG_PROMOTED_VAR_P flag deleted
anyway by this code in expand_expr_real_2:
/* If the signedness of the conversion differs and OP0 is
a promoted SUBREG, clear that indication since we now
have to do the proper extension. */
if (TYPE_UNSIGNED (TREE_TYPE (treeop0)) != unsignedp
&& GET_CODE (op0) == SUBREG)
SUBREG_PROMOTED_VAR_P (op0) = 0;
I see no obvious place in this sequence of events where we could have
done anything better, and I'm doubtful that arbitrarily ignoring the
choice made by PROMOTE_MODE at any point would be a good idea. In light
of this, is my previous combiner patch OK?
Bernd
next prev parent reply other threads:[~2010-06-08 21:44 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-30 1:05 Bernd Schmidt
2010-04-30 3:33 ` Andrew Pinski
2010-04-30 9:23 ` Paolo Bonzini
2010-04-30 15:09 ` Bernd Schmidt
[not found] ` <201005010054.17350.ebotcazou@adacore.com>
2010-05-01 10:45 ` Paolo Bonzini
2010-05-03 9:39 ` Bernd Schmidt
2010-05-05 13:01 ` Eric Botcazou
2010-05-06 7:14 ` Paolo Bonzini
2010-05-06 7:36 ` Eric Botcazou
2010-06-08 21:56 ` Bernd Schmidt [this message]
2010-06-09 22:14 ` Eric Botcazou
2010-06-11 13:58 ` Bernd Schmidt
2010-06-16 21:23 ` Eric Botcazou
2010-06-18 7:31 ` Bernd Schmidt
2010-06-18 17:09 ` Eric Botcazou
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=4C0EB9A5.6080907@codesourcery.com \
--to=bernds@codesourcery.com \
--cc=bonzini@gnu.org \
--cc=ebotcazou@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=pinskia@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).