From: Richard Sandiford <richard.sandiford@arm.com>
To: Jeff Law via Gcc-patches <gcc-patches@gcc.gnu.org>
Cc: Jin Ma <jinma@linux.alibaba.com>,
Jeff Law <jeffreyalaw@gmail.com>,
jinma.contrib@gmail.com
Subject: Re: [PATCH] Fix type error of 'switch (SUBREG_BYTE (op)).'
Date: Tue, 23 May 2023 13:27:19 +0100 [thread overview]
Message-ID: <mptwn0zmdw8.fsf@arm.com> (raw)
In-Reply-To: <fe3755d0-2e9e-f891-3a3b-942da618364e@gmail.com> (Jeff Law via Gcc-patches's message of "Wed, 17 May 2023 15:49:31 -0600")
Jeff Law via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
> On 5/17/23 03:03, Jin Ma wrote:
>> For example:
>> (define_insn "mov_lowpart_sidi2"
>> [(set (match_operand:SI 0 "register_operand" "=r")
>> (subreg:SI (match_operand:DI 1 "register_operand" " r") 0))]
>> "TARGET_64BIT"
>> "mov\t%0,%1")
>>
>> (define_insn "mov_highpart_sidi2"
>> [(set (match_operand:SI 0 "register_operand" "=r")
>> (subreg:SI (match_operand:DI 1 "register_operand" " r") 1))]
>> "TARGET_64BIT"
>> "movh\t%0,%1")
>>
>> When defining the above patterns, the generated file insn-recog.cc will
>> appear 'switch (SUBREG_BYTE (op))', but since the return value of
>> SUBREG_BYTE is poly_uint16_pod, the following error will occur:
>> "error: switch quantity not an integer".
>>
>> gcc/ChangeLog:
>>
>> * genrecog.cc (print_nonbool_test): Fix type error of
>> 'switch (SUBREG_BYTE (op))'.
> Thanks. Installed.
We shouldn't add to_constant just because it's a convenient
way of getting rid of errors :) There has to be a good reason
in principle why the value is known at compile time.
So I think this should be reverted. Nothing guarantees that
SUBREG_BYTEs are constant on AArch64 and RISC-V. And for SVE
it's common for them not to be.
If we want to support the above, I think we need to make the
generator use known_eq instead.
The patterns don't look right though. An SI subreg of a DI
can't have a SUBREG_BYTE of 1. And the lowpart SUBREG_BYTE
depends on endianness. So I think a better way of writing
the lowpart pattern above is to use subreg_lowpart_operator
(which riscv already has).
The high part can't be done using subregs though.
Thanks,
Richard
next prev parent reply other threads:[~2023-05-23 12:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-17 9:03 Jin Ma
2023-05-17 21:49 ` Jeff Law
2023-05-23 12:27 ` Richard Sandiford [this message]
2023-05-25 8:27 ` Jin Ma
2023-05-25 9:19 ` Richard Sandiford
2023-05-30 14:16 ` Jeff Law
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=mptwn0zmdw8.fsf@arm.com \
--to=richard.sandiford@arm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jeffreyalaw@gmail.com \
--cc=jinma.contrib@gmail.com \
--cc=jinma@linux.alibaba.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).