From: Richard Sandiford <rdsandiford@googlemail.com>
To: Eric Botcazou <ebotcazou@adacore.com>
Cc: Segher Boessenkool <segher@kernel.crashing.org>,
gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] rtlanal: Fix nonzero_bits for non-load paradoxical subregs (PR85925)
Date: Mon, 04 Jun 2018 22:12:00 -0000 [thread overview]
Message-ID: <87muwayzf4.fsf@googlemail.com> (raw)
In-Reply-To: <305632139.bEVa8srL7U@polaris> (Eric Botcazou's message of "Mon, 04 Jun 2018 22:57:05 +0200")
Eric Botcazou <ebotcazou@adacore.com> writes:
>> In the PR we have insns:
>>
>> Trying 23 -> 24:
>> 23: r123:SI=zero_extend(r122:HI)
>> REG_DEAD r122:HI
>> 24: [r115:SI]=r123:SI
>> REG_DEAD r123:SI
>>
>> which should be combined to
>>
>> (set (mem:SI (reg/f:SI 115 [ pretmp_19 ]) [1 *pretmp_19+0 S4 A32])
>> (and:SI (subreg:SI (reg:HI 122) 0)
>> (const_int 32767 [0x7fff])))
>>
>> But nonzero_bits of reg:HI 122 is 0x7fff, and nonzero_bits1 thinks it
>> then also has that same nonzero_bits for the subreg. This is not
>> correct: the bit outside of HImode are undefined. load_extend_op
>> applies to loads from memory only, not anything else. Which means the
>> whole AND is optimised away.
>
> No, this is done on purpose for WORD_REGISTER_OPERATIONS targets and your
> patch will pessimize them. I'm going to have a look at the PR then.
I can see why WORD_REGISTER_OPERATIONS allows some REG cases,
but why does LOAD_EXTEND_OP have an effect on them? The doc says:
@defmac WORD_REGISTER_OPERATIONS
Define this macro to 1 if operations between registers with integral mode
smaller than a word are always performed on the entire register. To be
more explicit, if you start with a pair of @code{word_mode} registers with
known values and you do a subword, for example @code{QImode}, addition on
the low part of the registers, then the compiler may consider that the
result has a known value in @code{word_mode} too if the macro is defined
to 1. Most RISC machines have this property and most CISC machines do not.
@end defmac
which doesn't make it sound like LOAD_EXTEND_OP has a direct effect
on the (cached) lhs of an arithmetic operation.
Ah well. I guess I'm just glad that AArch64 doesn't define this :-)
Richard
next prev parent reply other threads:[~2018-06-04 22:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-04 12:58 Segher Boessenkool
2018-06-04 20:57 ` Eric Botcazou
2018-06-04 22:12 ` Richard Sandiford [this message]
2018-06-04 23:31 ` Eric Botcazou
2018-09-17 22:03 ` Segher Boessenkool
2018-09-18 8:28 ` 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=87muwayzf4.fsf@googlemail.com \
--to=rdsandiford@googlemail.com \
--cc=ebotcazou@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=segher@kernel.crashing.org \
/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).