public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] [RISC-V] fix PR 111259 invalid zcmp mov predicate.
@ 2023-09-15  1:20 Fei Gao
  2023-09-15  8:49 ` Kito Cheng
  0 siblings, 1 reply; 5+ messages in thread
From: Fei Gao @ 2023-09-15  1:20 UTC (permalink / raw)
  To: gcc-patches; +Cc: kito.cheng, palmer, jeffreyalaw, dimitar, Fei Gao

The code changes are from Palmer.

root cause:
In a gcc build with --enable-checking=yes, REGNO (op) checks
rtx code and expected code 'reg'. so a rtx with 'subreg' causes
an internal compiler error.

solution:
Restrict predicate to allow 'reg' only.

gcc/ChangeLog:

        * config/riscv/predicates.md: Restrict predicate
            to allow 'reg' only.
---
 gcc/config/riscv/predicates.md | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/config/riscv/predicates.md b/gcc/config/riscv/predicates.md
index 53e7c1d03aa..4bc7ff2c9d8 100644
--- a/gcc/config/riscv/predicates.md
+++ b/gcc/config/riscv/predicates.md
@@ -74,6 +74,7 @@
   (ior (match_operand 0 "const_0_operand")
        (match_operand 0 "register_operand")))
 
+;; ZCMP predicates
 (define_predicate "stack_push_up_to_ra_operand"
   (and (match_code "const_int")
        (match_test "riscv_zcmp_valid_stack_adj_bytes_p (INTVAL (op) * -1, 1)")))
@@ -170,13 +171,12 @@
   (and (match_code "const_int")
        (match_test "riscv_zcmp_valid_stack_adj_bytes_p (INTVAL (op), 13)")))
 
-;; ZCMP predicates
 (define_predicate "a0a1_reg_operand"
-  (and (match_operand 0 "register_operand")
+  (and (match_code "reg")
        (match_test "IN_RANGE (REGNO (op), A0_REGNUM, A1_REGNUM)")))
 
 (define_predicate "zcmp_mv_sreg_operand"
-  (and (match_operand 0 "register_operand")
+  (and (match_code "reg")
        (match_test "TARGET_RVE ? IN_RANGE (REGNO (op), S0_REGNUM, S1_REGNUM)
                     : IN_RANGE (REGNO (op), S0_REGNUM, S1_REGNUM)
                     || IN_RANGE (REGNO (op), S2_REGNUM, S7_REGNUM)")))
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] [RISC-V] fix PR 111259 invalid zcmp mov predicate.
  2023-09-15  1:20 [PATCH] [RISC-V] fix PR 111259 invalid zcmp mov predicate Fei Gao
@ 2023-09-15  8:49 ` Kito Cheng
  2023-09-15 16:37   ` Patrick O'Neill
  0 siblings, 1 reply; 5+ messages in thread
From: Kito Cheng @ 2023-09-15  8:49 UTC (permalink / raw)
  To: Fei Gao; +Cc: gcc-patches, palmer, jeffreyalaw, dimitar

[-- Attachment #1: Type: text/plain, Size: 161 bytes --]

I guess another solution is using reg_or_subregno instead of REGNO, but
that should not catch more cases, and just more run-time check, so this
version is LGTM.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] [RISC-V] fix PR 111259 invalid zcmp mov predicate.
  2023-09-15  8:49 ` Kito Cheng
@ 2023-09-15 16:37   ` Patrick O'Neill
  2023-09-15 20:06     ` Palmer Dabbelt
  0 siblings, 1 reply; 5+ messages in thread
From: Patrick O'Neill @ 2023-09-15 16:37 UTC (permalink / raw)
  To: Kito Cheng, Fei Gao; +Cc: gcc-patches, palmer, jeffreyalaw, dimitar

On 9/15/23 01:49, Kito Cheng via Gcc-patches wrote:

> I guess another solution is using reg_or_subregno instead of REGNO, but
> that should not catch more cases, and just more run-time check, so this
> version is LGTM.
I tested an equivalent patch (without the comment changes).
This patch resolves the build errors on glibc rv64gc with
--enable-checking=rtl.
Tested for regressions (without --enable-checking=rtl) using rv64gc &
rv32gc glibc.

This patch does not cause any regressions on those targets.

Patrick

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] [RISC-V] fix PR 111259 invalid zcmp mov predicate.
  2023-09-15 16:37   ` Patrick O'Neill
@ 2023-09-15 20:06     ` Palmer Dabbelt
  2023-09-15 20:45       ` [Committed] " Patrick O'Neill
  0 siblings, 1 reply; 5+ messages in thread
From: Palmer Dabbelt @ 2023-09-15 20:06 UTC (permalink / raw)
  To: Patrick O'Neill; +Cc: Kito Cheng, gaofei, gcc-patches, jeffreyalaw, dimitar

On Fri, 15 Sep 2023 09:37:48 PDT (-0700), Patrick O'Neill wrote:
> On 9/15/23 01:49, Kito Cheng via Gcc-patches wrote:
>
>> I guess another solution is using reg_or_subregno instead of REGNO, but
>> that should not catch more cases, and just more run-time check, so this
>> version is LGTM.
> I tested an equivalent patch (without the comment changes).
> This patch resolves the build errors on glibc rv64gc with
> --enable-checking=rtl.
> Tested for regressions (without --enable-checking=rtl) using rv64gc &
> rv32gc glibc.
>
> This patch does not cause any regressions on those targets.

Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>T
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>

Thanks!

>
> Patrick

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Committed] [RISC-V] fix PR 111259 invalid zcmp mov predicate.
  2023-09-15 20:06     ` Palmer Dabbelt
@ 2023-09-15 20:45       ` Patrick O'Neill
  0 siblings, 0 replies; 5+ messages in thread
From: Patrick O'Neill @ 2023-09-15 20:45 UTC (permalink / raw)
  To: Fei Gao
  Cc: Kito Cheng, gaofei, gcc-patches, jeffreyalaw, dimitar, Palmer Dabbelt

Committed - Thanks!

Patrick

On 9/15/23 13:06, Palmer Dabbelt wrote:
> On Fri, 15 Sep 2023 09:37:48 PDT (-0700), Patrick O'Neill wrote:
>> On 9/15/23 01:49, Kito Cheng via Gcc-patches wrote:
>>
>>> I guess another solution is using reg_or_subregno instead of REGNO, but
>>> that should not catch more cases, and just more run-time check, so this
>>> version is LGTM.
>> I tested an equivalent patch (without the comment changes).
>> This patch resolves the build errors on glibc rv64gc with
>> --enable-checking=rtl.
>> Tested for regressions (without --enable-checking=rtl) using rv64gc &
>> rv32gc glibc.
>>
>> This patch does not cause any regressions on those targets.
>
> Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>T
> Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
>
> Thanks!
>
>>
>> Patrick

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-09-15 20:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-15  1:20 [PATCH] [RISC-V] fix PR 111259 invalid zcmp mov predicate Fei Gao
2023-09-15  8:49 ` Kito Cheng
2023-09-15 16:37   ` Patrick O'Neill
2023-09-15 20:06     ` Palmer Dabbelt
2023-09-15 20:45       ` [Committed] " Patrick O'Neill

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).