public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Philipp Tomsich <ptomsich@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-1087] RISC-V: add consecutive_bits_operand predicate
Date: Tue, 14 Jun 2022 11:38:17 +0000 (GMT)	[thread overview]
Message-ID: <20220614113817.B2F063851A84@sourceware.org> (raw)

https://gcc.gnu.org/g:4bf0dcb0492c40be7e0603b13a8b5949609388dd

commit r13-1087-g4bf0dcb0492c40be7e0603b13a8b5949609388dd
Author: Philipp Tomsich <philipp.tomsich@vrull.eu>
Date:   Tue May 24 15:03:47 2022 +0200

    RISC-V: add consecutive_bits_operand predicate
    
    Provide an easy way to constrain for constants that are a a single,
    consecutive run of ones.
    
    gcc/ChangeLog:
    
            * config/riscv/predicates.md (consecutive_bits_operand):
            Implement new predicate.
    
    Signed-off-by: Philipp Tomsich <philipp.tomsich@vrull.eu>

Diff:
---
 gcc/config/riscv/predicates.md | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/gcc/config/riscv/predicates.md b/gcc/config/riscv/predicates.md
index c37caa2502b..90db5dfcdd5 100644
--- a/gcc/config/riscv/predicates.md
+++ b/gcc/config/riscv/predicates.md
@@ -243,3 +243,14 @@
 (define_predicate "imm5_operand"
   (and (match_code "const_int")
        (match_test "INTVAL (op) < 5")))
+
+;; A CONST_INT operand that consists of a single run of consecutive set bits.
+(define_predicate "consecutive_bits_operand"
+  (match_code "const_int")
+{
+	unsigned HOST_WIDE_INT val = UINTVAL (op);
+	if (exact_log2 ((val >> ctz_hwi (val)) + 1) < 0)
+	        return false;
+
+	return true;
+})


                 reply	other threads:[~2022-06-14 11:38 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=20220614113817.B2F063851A84@sourceware.org \
    --to=ptomsich@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: 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).