From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1923) id B2F063851A84; Tue, 14 Jun 2022 11:38:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B2F063851A84 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Philipp Tomsich To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-1087] RISC-V: add consecutive_bits_operand predicate X-Act-Checkin: gcc X-Git-Author: Philipp Tomsich X-Git-Refname: refs/heads/master X-Git-Oldrev: e07a876c07601e1f3a27420f7d055d20193c362c X-Git-Newrev: 4bf0dcb0492c40be7e0603b13a8b5949609388dd Message-Id: <20220614113817.B2F063851A84@sourceware.org> Date: Tue, 14 Jun 2022 11:38:17 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jun 2022 11:38:17 -0000 https://gcc.gnu.org/g:4bf0dcb0492c40be7e0603b13a8b5949609388dd commit r13-1087-g4bf0dcb0492c40be7e0603b13a8b5949609388dd Author: Philipp Tomsich 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 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; +})