From: Vladimir Makarov <vmakarov@redhat.com>
To: Robert Suchanek <Robert.Suchanek@imgtec.com>,
"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
rdsandiford@googlemail.com
Subject: Re: [RFC][PATCH][MIPS] Patch to enable LRA for MIPS backend
Date: Wed, 23 Apr 2014 15:33:00 -0000 [thread overview]
Message-ID: <5357D588.6000202@redhat.com> (raw)
In-Reply-To: <87fvl6hnw2.fsf@talisman.default>
On 2014-04-21, 8:23 AM, Richard Sandiford wrote:
> Robert Suchanek <Robert.Suchanek@imgtec.com> writes:
>>>>> Did you see the failures even after your mips_regno_mode_ok_for_base_p
>>>>> change? LRA should know how to reload a "W" address.
>>>>
>>>> Yes but I realize there is more. It fails because $sp is now included
>>>> in BASE_REG_CLASS and "W" is based on it. However, I suppose that
>>>> it would be too eager to say it is wrong and likely there is
>>>> something missing
>>>> in LRA if we want to keep all alternatives. Currently there is no check
>>>> if a reloaded operand has a valid address, use of $sp in lbu/lhu cases.
>>>> Even if we added extra checks we are less likely to benefit as we need
>>>> to reload the base into register.
>>>
>>> Not sure what you mean, sorry. "W" exists specifically to exclude
>>> $sp-based and $pc-based addresses. LRA AFAIK should already be able
>>> to reload addresses that are valid in the TARGET_LEGITIMATE_ADDRESS_P
>>> sense but which do not match the constraints for a particular insn.
>>>
>>> Can you remember one of the tests that fails?
>>
>> I couldn't trigger the problem with the original testcase but found
>> another one that reveals it. The following needs to compiled with
>> -mips32r2 -mips16 -Os:
>>
>> struct { int addr; } c;
>> struct command { int args[1]; };
>> unsigned short a;
>>
>> fn1 (struct command *p1)
>> {
>> unsigned short d;
>> d = fn2 ();
>> a = p1->args[0];
>> fn3 (a);
>> if (c.addr)
>> {
>> fn4 (p1->args[0]);
>> return;
>> }
>> (&c)->addr = fn5 ();
>> fn6 (d);
>> }
>
> Thanks.
>
>> Not sure how the constraint would/should exclude $sp-based address in
>> LRA. In this particular case, a spilled pseudo is changed to memory
>> giving the following RTL form:
>>
>> (insn 30 29 31 4 (set (reg:SI 4 $4)
>> (and:SI (mem/c:SI (plus:SI (reg/f:SI 78 $frame)
>> (const_int 16 [0x10])) [7 %sfp+16 S4 A32])
>> (const_int 65535 [0xffff]))) shell.i:17 161 {*andsi3_mips16}
>> (expr_list:REG_DEAD (reg:SI 194 [ D.1469 ])
>> (nil)))
>>
>> The operand 1 during alternative selection is not marked as a bad
>> operand as it is a memory operand. $frame appears to be fine as it
>> could be eliminated later to hard register. No reloads are inserted
>> for the instructions concerned. Unless, $frame should be temporarily
>> eliminated and then a reload would be inserted?
>
> Yeah, I think the lack of elimination is the problem. process_address
> eliminates $frame temporarily before checking whether the address
> is valid, but the places that check EXTRA_CONSTRAINT_STR pass the
> original uneliminated address. So the legitimate_address_p hook sees
> the $sp-based address but the "W" constraint only sees the $frame-based
> address (which might or might not be valid, depending on whether $frame
> is eliminated to the stack or hard frame pointer). I think the constraints
> should see the eliminated address too.
>
> This patch seems to fix it for me. Tested on x86_64-linux-gnu.
> Vlad, is this OK for trunk?
>
> BTW, we might want to define something like:
>
> #define MODE_BASE_REG_CLASS(MODE) \
> (TARGET_MIPS16 \
> ? ((MODE) == SImode || (MODE) == DImode ? M16_SP_REGS : M16_REGS) \
> : GR_REGS)
>
> instead of BASE_REG_CLASS. It might lead to slightly better code
> (or not -- if it doesn't then don't bother :-)).
>
> If this patch is OK then I think the only thing blocking the switch
> to LRA is the asm-subreg-1.c failure. I think it'd be fine to XFAIL
> that test on MIPS for now, until there's a consensus about what "X" means
> for asms.
>
>
> gcc/
> * lra-constraints.c (valid_address_p): Move earlier in file.
> Add a constraint argument to the address_info version.
> (satisfies_memory_constraint_p): New function.
> (satisfies_address_constraint_p): Likewise.
> (process_alt_operands, curr_insn_transform): Use them.
> (process_address): Pass the constraint to valid_address_p when
> checking address operands.
>
>
Yes, it looks ok for me, Richard. Thanks on working on this.
I am on vacation till May 4th. If the patch results in problems on other
targets, I hope you revert it. But to be honest, I believe it is very
safe and don't expect any problems at all.
next prev parent reply other threads:[~2014-04-23 15:31 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-29 1:27 Robert Suchanek
2014-03-29 11:24 ` Richard Sandiford
2014-04-09 10:00 ` Robert Suchanek
2014-04-09 21:24 ` Richard Sandiford
2014-04-10 20:29 ` Richard Sandiford
2014-04-14 11:13 ` Robert Suchanek
2014-04-15 21:12 ` Richard Sandiford
2014-04-16 21:10 ` Robert Suchanek
2014-04-21 13:01 ` Richard Sandiford
2014-04-23 13:34 ` Robert Suchanek
2014-04-23 14:10 ` Richard Sandiford
2014-04-23 15:34 ` Robert Suchanek
2014-04-23 15:33 ` Vladimir Makarov [this message]
2014-05-03 19:21 ` Richard Sandiford
2014-05-06 14:06 ` Kyrill Tkachov
2014-05-06 19:22 ` Richard Sandiford
2014-05-09 22:58 ` Matthew Fortune
2014-05-10 18:44 ` Richard Sandiford
2014-05-14 13:24 ` Robert Suchanek
2014-05-15 21:05 ` Robert Suchanek
2014-05-15 21:34 ` Richard Sandiford
2014-05-16 21:05 ` Robert Suchanek
2014-05-18 19:38 ` Richard Sandiford
2014-06-02 19:37 ` RFA: Make LRA temporarily eliminate addresses before testing constraints Richard Sandiford
2014-06-03 20:50 ` Vladimir Makarov
2014-06-04 17:45 ` Richard Sandiford
2014-06-11 11:30 ` Robert Suchanek
2014-06-16 16:12 ` Robert Suchanek
2014-06-16 18:08 ` Vladimir Makarov
2014-06-18 20:52 ` Matthew Fortune
2014-03-29 14:08 ` [RFC][PATCH][MIPS] Patch to enable LRA for MIPS backend Jakub Jelinek
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=5357D588.6000202@redhat.com \
--to=vmakarov@redhat.com \
--cc=Robert.Suchanek@imgtec.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=rdsandiford@googlemail.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).