From: Takayuki 'January June' Suwa <jjsuwa_sys3175@yahoo.co.jp>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Subject: [PATCH 1/2 v2] xtensa: Recover constant synthesis for HImode after LRA transition
Date: Sun, 4 Feb 2024 19:20:16 +0900 [thread overview]
Message-ID: <2c6cd2b5-e436-4608-a0b7-ad8a57bc186b@yahoo.co.jp> (raw)
In-Reply-To: <2c6cd2b5-e436-4608-a0b7-ad8a57bc186b.ref@yahoo.co.jp>
After LRA transition, HImode constants that don't fit into signed 12 bits
are no longer subject to constant synthesis:
/* example */
void test(void) {
short foo = 32767;
__asm__ ("" :: "r"(foo));
}
;; before
.literal_position
.literal .LC0, 32767
test:
l32r a9, .LC0
ret.n
This patch fixes that:
;; after
test:
movi.n a9, -1
extui a9, a9, 17, 15
ret.n
gcc/ChangeLog:
* config/xtensa/xtensa.md (SHI): New mode iterator.
(2 split patterns related to constsynth):
Change to also accept HImode operands.
---
gcc/config/xtensa/xtensa.md | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md
index 13b8b57f1fc..1a2249b059a 100644
--- a/gcc/config/xtensa/xtensa.md
+++ b/gcc/config/xtensa/xtensa.md
@@ -87,6 +87,10 @@
;; the same template.
(define_mode_iterator HQI [HI QI])
+;; This mode iterator allows the SI and HI patterns to be defined from
+;; the same template.
+(define_mode_iterator SHI [SI HI])
+
\f
;; Attributes.
@@ -1291,28 +1295,30 @@
(set_attr "length" "2,2,2,2,2,2,3,3,3,3,6,3,3,3,3,3")])
(define_split
- [(set (match_operand:SI 0 "register_operand")
- (match_operand:SI 1 "const_int_operand"))]
+ [(set (match_operand:SHI 0 "register_operand")
+ (match_operand:SHI 1 "const_int_operand"))]
"!TARGET_CONST16 && !TARGET_AUTO_LITPOOLS
&& ! xtensa_split1_finished_p ()
&& ! xtensa_simm12b (INTVAL (operands[1]))"
[(set (match_dup 0)
(match_dup 1))]
{
- operands[1] = force_const_mem (SImode, operands[1]);
+ operands[1] = force_const_mem (<MODE>mode, operands[1]);
})
(define_split
- [(set (match_operand:SI 0 "register_operand")
- (match_operand:SI 1 "constantpool_operand"))]
+ [(set (match_operand:SHI 0 "register_operand")
+ (match_operand:SHI 1 "constantpool_operand"))]
"! optimize_debug && reload_completed"
[(const_int 0)]
{
- rtx x = avoid_constant_pool_reference (operands[1]);
+ rtx x = avoid_constant_pool_reference (operands[1]), dst = operands[0];
if (! CONST_INT_P (x))
FAIL;
- if (! xtensa_constantsynth (operands[0], INTVAL (x)))
- emit_move_insn (operands[0], x);
+ if (<MODE>mode == HImode)
+ dst = gen_rtx_REG (SImode, REGNO (dst));
+ if (! xtensa_constantsynth (dst, INTVAL (x)))
+ emit_move_insn (dst, x);
DONE;
})
--
2.30.2
next parent reply other threads:[~2024-02-04 10:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <2c6cd2b5-e436-4608-a0b7-ad8a57bc186b.ref@yahoo.co.jp>
2024-02-04 10:20 ` Takayuki 'January June' Suwa [this message]
2024-02-04 21:28 ` Max Filippov
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=2c6cd2b5-e436-4608-a0b7-ad8a57bc186b@yahoo.co.jp \
--to=jjsuwa_sys3175@yahoo.co.jp \
--cc=gcc-patches@gcc.gnu.org \
--cc=jcmvbkbc@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).