From: Takayuki 'January June' Suwa <jjsuwa_sys3175@yahoo.co.jp>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH 1/5] xtensa: Simplify EXTUI instruction maskimm validations
Date: Fri, 13 May 2022 22:26:30 +0900 [thread overview]
Message-ID: <8bfdbf59-cde2-3f96-12b7-52a43a6911ee@yahoo.co.jp> (raw)
No functional changes.
gcc/ChangeLog:
* gcc/config/xtensa/predicates.md (extui_fldsz_operand): Simplify.
* gcc/config/xtensa/xtensa.cc (xtensa_mask_immediate, print_operand):
Ditto.
---
gcc/config/xtensa/predicates.md | 2 +-
gcc/config/xtensa/xtensa.cc | 24 +++---------------------
2 files changed, 4 insertions(+), 22 deletions(-)
diff --git a/gcc/config/xtensa/predicates.md
b/gcc/config/xtensa/predicates.md
index 01226a2b3c7..daea63b182c 100644
--- a/gcc/config/xtensa/predicates.md
+++ b/gcc/config/xtensa/predicates.md
@@ -55,7 +55,7 @@
(define_predicate "extui_fldsz_operand"
(and (match_code "const_int")
- (match_test "xtensa_mask_immediate ((1 << INTVAL (op)) - 1)")))
+ (match_test "IN_RANGE (INTVAL (op), 1, 16)")))
(define_predicate "sext_operand"
(if_then_else (match_test "TARGET_SEXT")
diff --git a/gcc/config/xtensa/xtensa.cc b/gcc/config/xtensa/xtensa.cc
index 7023badf0e2..a1f77b2bd35 100644
--- a/gcc/config/xtensa/xtensa.cc
+++ b/gcc/config/xtensa/xtensa.cc
@@ -456,19 +456,7 @@ xtensa_b4constu (HOST_WIDE_INT v)
bool
xtensa_mask_immediate (HOST_WIDE_INT v)
{
-#define MAX_MASK_SIZE 16
- int mask_size;
-
- for (mask_size = 1; mask_size <= MAX_MASK_SIZE; mask_size++)
- {
- if ((v & 1) == 0)
- return false;
- v = v >> 1;
- if (v == 0)
- return true;
- }
-
- return false;
+ return IN_RANGE (exact_log2 (v + 1), 1, 16);
}
@@ -2430,17 +2418,11 @@ print_operand (FILE *file, rtx x, int letter)
case 'K':
if (GET_CODE (x) == CONST_INT)
{
- int num_bits = 0;
unsigned val = INTVAL (x);
- while (val & 1)
- {
- num_bits += 1;
- val = val >> 1;
- }
- if ((val != 0) || (num_bits == 0) || (num_bits > 16))
+ if (!xtensa_mask_immediate (val))
fatal_insn ("invalid mask", x);
- fprintf (file, "%d", num_bits);
+ fprintf (file, "%d", floor_log2 (val + 1));
}
else
output_operand_lossage ("invalid %%K value");
--
2.20.1
next reply other threads:[~2022-05-13 13:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-13 13:26 Takayuki 'January June' Suwa [this message]
2022-05-26 16:42 ` 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=8bfdbf59-cde2-3f96-12b7-52a43a6911ee@yahoo.co.jp \
--to=jjsuwa_sys3175@yahoo.co.jp \
--cc=gcc-patches@gcc.gnu.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).