From: "Richard Earnshaw (lists)" <Richard.Earnshaw@arm.com>
To: Matthieu Longo <matthieu.longo@arm.com>, gcc-patches@gcc.gnu.org
Cc: Kyrylo Tkachov <Kyrylo.Tkachov@arm.com>
Subject: Re: [PATCH][GCC][Arm] Add pattern for bswap + rotate -> rev16 [Bug 108933]
Date: Mon, 22 Jan 2024 16:25:25 +0000 [thread overview]
Message-ID: <c987c596-f0ec-4b32-b339-a79b3545a435@arm.com> (raw)
In-Reply-To: <6c8c1ae8-78b3-4310-8c75-f452e774eb3b@arm.com>
On 22/01/2024 12:18, Matthieu Longo wrote:
> rev16 pattern was not recognised anymore as a change in the bswap tree
> pass was introducing a new GIMPLE form, not recognized by the assembly
> final transformation pass.
>
> More details in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108933
>
> gcc/ChangeLog:
>
> PR target/108933
> * config/arm/arm.md (*arm_rev16si2_alt3): new pattern to convert
> a bswap + rotate by 16 bits into rev16
ChangeLog entries need to be written as sentences, so start with a capital letter and end with a full stop; continuation lines should start in column 8 (one hard tab, don't use spaces). But in this case, "New pattern." is sufficient.
>
> gcc/testsuite/ChangeLog:
>
> PR target/108933
> * gcc.target/arm/rev16.c: Moved to...
> * gcc.target/arm/rev16_1.c: ...here.
> * gcc.target/arm/rev16_2.c: New test to check that rev16 is
> emitted.
+;; Similar pattern to match (rotate (bswap) 16)
+(define_insn "*arm_rev16si2_alt3"
+ [(set (match_operand:SI 0 "register_operand" "=l,r")
+ (rotate:SI (bswap:SI (match_operand:SI 1 "register_operand" "l,r"))
+ (const_int 16)))]
+ "arm_arch6"
+ "rev16\\t%0, %1"
+ [(set_attr "arch" "t,32")
+ (set_attr "length" "2,4")
+ (set_attr "type" "rev")]
+)
+
Unfortunately, this is insufficient. When generating Arm or Thumb2 code (but not thumb1) we also have to handle conditional execution: we need to have '%?' in the output template at the point where a condition code might be needed. That means we need separate output templates for all three alternatives (as we need a 16-bit variant for thumb2 that's conditional and a 16-bit for thumb1 that isn't). See the output of arm_rev16 for a guide of what is really needed.
I note that the arm_rev16si2_alt1, and arm_rev16si2_alt2 patterns are incorrect in this regard as well; that will need fixing.
I also see that arm_rev16si2 currently expands to the alt1 variant above; given that the preferred canonical form would now appear to use bswap + rotate, we should change that as well. In fact, we can merge your new pattern with the expand entirely and eliminate the need to call gen_arm_rev16si2_alt1. Something like:
(define_insn "arm_rev16si2"
[(set (match_operand:SI 0 "s_register_operand")
(rotate:SI (bswap:SI (match_operand:SI 1 "s_register_operand")) (const_int 16))]
"arm_arch6"
"@
rev16...
...
R.
next prev parent reply other threads:[~2024-01-22 16:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-22 12:18 Matthieu Longo
2024-01-22 16:25 ` Richard Earnshaw (lists) [this message]
2024-01-29 14:14 ` Matthieu Longo
2024-01-29 16:03 ` Richard Earnshaw
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=c987c596-f0ec-4b32-b339-a79b3545a435@arm.com \
--to=richard.earnshaw@arm.com \
--cc=Kyrylo.Tkachov@arm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=matthieu.longo@arm.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).