public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Max Filippov <jcmvbkbc@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-781] xtensa: Simplify EXTUI instruction maskimm validations Date: Thu, 26 May 2022 16:41:32 +0000 (GMT) [thread overview] Message-ID: <20220526164132.3DE32385782D@sourceware.org> (raw) https://gcc.gnu.org/g:b753405a5f0d45eea97f4cc7df2c2089401b08bf commit r13-781-gb753405a5f0d45eea97f4cc7df2c2089401b08bf Author: Takayuki 'January June' Suwa <jjsuwa_sys3175@yahoo.co.jp> Date: Fri May 13 22:26:30 2022 +0900 xtensa: Simplify EXTUI instruction maskimm validations No functional changes. gcc/ChangeLog: * config/xtensa/predicates.md (extui_fldsz_operand): Simplify. * config/xtensa/xtensa.cc (xtensa_mask_immediate, print_operand): Ditto. Diff: --- 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");
reply other threads:[~2022-05-26 16:41 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220526164132.3DE32385782D@sourceware.org \ --to=jcmvbkbc@gcc.gnu.org \ --cc=gcc-cvs@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: linkBe 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).