diff mbox series

combine: Check for paradoxical subreg

Message ID 23c7868a-6736-5c73-fa9a-05e3e5ef53d6@linux.ibm.com
State New
Headers show
Series combine: Check for paradoxical subreg | expand

Commit Message

Robin Dapp June 23, 2021, 11:33 a.m. UTC
Hi,

while evaluating another patch that introduces more lvalue paradoxical 
subregs I ran into an ICE in combine at

  	  wide_int o = wi::insert (rtx_mode_t (outer, temp_mode),
				   rtx_mode_t (inner, dest_mode),
				   offset, width);

because width (=GET_MODE_PRECISION (dest_mode)) > GET_MODE_PRECISION 
(temp_mode).

 From the comments and the code it looks like we do not want to handle a 
paradoxical subreg here so I quickly added a check for it which prevents 
the ICE.  The check could also be added to reg_subword_p () I guess.

Is this the right thing to do or am I missing something, i.e. my other 
patch might be doing something it should not?

Bootstrap on s390x was successful and testsuite is looking good so far.

Regards
  Robin

--

gcc/ChangeLog:

         * combine.c (try_combine): Check for paradoxical subreg.

Comments

Robin Dapp July 5, 2021, 10:28 a.m. UTC | #1
> gcc/ChangeLog:
> 
>           * combine.c (try_combine): Check for paradoxical subreg.

ping.
Robin Dapp Sept. 24, 2021, 10:17 a.m. UTC | #2
Hi,

pinging this patch:

https://gcc.gnu.org/pipermail/gcc-patches/2021-June/573509.html

It introduces a check for a paradoxical subreg in combine that would ICE 
otherwise.

Regards
  Robin
Richard Sandiford Oct. 14, 2021, 8:49 a.m. UTC | #3
Sorry for the slow review.

Robin Dapp via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
> Hi,
>
> while evaluating another patch that introduces more lvalue paradoxical 
> subregs I ran into an ICE in combine at
>
>   	  wide_int o = wi::insert (rtx_mode_t (outer, temp_mode),
> 				   rtx_mode_t (inner, dest_mode),
> 				   offset, width);
>
> because width (=GET_MODE_PRECISION (dest_mode)) > GET_MODE_PRECISION 
> (temp_mode).
>
>  From the comments and the code it looks like we do not want to handle a 
> paradoxical subreg here so I quickly added a check for it which prevents 
> the ICE.  The check could also be added to reg_subword_p () I guess.

Yeah, I think adding it to reg_subword_p would be better, immediately
after the GET_CODE (x) == SUBREG test.

OK with that change, thanks.

Richard

>
> Is this the right thing to do or am I missing something, i.e. my other 
> patch might be doing something it should not?
>
> Bootstrap on s390x was successful and testsuite is looking good so far.
>
> Regards
>   Robin
>
> --
>
> gcc/ChangeLog:
>
>          * combine.c (try_combine): Check for paradoxical subreg.
>
> From 2b74c66f8d97c30c45e99336c9871cccd8cf94e1 Mon Sep 17 00:00:00 2001
> From: Robin Dapp <rdapp@linux.ibm.com>
> Date: Tue, 22 Jun 2021 17:35:37 +0200
> Subject: [PATCH 11/11] combine paradoxical subreg fix.
>
> ---
>  gcc/combine.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/combine.c b/gcc/combine.c
> index 6476812a212..de04560db21 100644
> --- a/gcc/combine.c
> +++ b/gcc/combine.c
> @@ -2782,7 +2782,8 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0,
>        && CONST_SCALAR_INT_P (SET_SRC (temp_expr))
>        && GET_CODE (PATTERN (i3)) == SET
>        && CONST_SCALAR_INT_P (SET_SRC (PATTERN (i3)))
> -      && reg_subword_p (SET_DEST (PATTERN (i3)), SET_DEST (temp_expr)))
> +      && reg_subword_p (SET_DEST (PATTERN (i3)), SET_DEST (temp_expr))
> +      && !paradoxical_subreg_p (SET_DEST (PATTERN (i3))))
>      {
>        rtx dest = SET_DEST (PATTERN (i3));
>        rtx temp_dest = SET_DEST (temp_expr);
diff mbox series

Patch

From 2b74c66f8d97c30c45e99336c9871cccd8cf94e1 Mon Sep 17 00:00:00 2001
From: Robin Dapp <rdapp@linux.ibm.com>
Date: Tue, 22 Jun 2021 17:35:37 +0200
Subject: [PATCH 11/11] combine paradoxical subreg fix.

---
 gcc/combine.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/combine.c b/gcc/combine.c
index 6476812a212..de04560db21 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -2782,7 +2782,8 @@  try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0,
       && CONST_SCALAR_INT_P (SET_SRC (temp_expr))
       && GET_CODE (PATTERN (i3)) == SET
       && CONST_SCALAR_INT_P (SET_SRC (PATTERN (i3)))
-      && reg_subword_p (SET_DEST (PATTERN (i3)), SET_DEST (temp_expr)))
+      && reg_subword_p (SET_DEST (PATTERN (i3)), SET_DEST (temp_expr))
+      && !paradoxical_subreg_p (SET_DEST (PATTERN (i3))))
     {
       rtx dest = SET_DEST (PATTERN (i3));
       rtx temp_dest = SET_DEST (temp_expr);
-- 
2.31.1