public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-3260] [Committed] Fix subreg_promoted_mode breakage on various platforms.
@ 2021-08-31 16:33 Roger Sayle
  0 siblings, 0 replies; only message in thread
From: Roger Sayle @ 2021-08-31 16:33 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:863d6524f320abe14d6993fec188e787470e69b6

commit r12-3260-g863d6524f320abe14d6993fec188e787470e69b6
Author: Roger Sayle <roger@nextmovesoftware.com>
Date:   Tue Aug 31 17:25:58 2021 +0100

    [Committed] Fix subreg_promoted_mode breakage on various platforms.
    
    My apologies for the inconvenience.  My recent patch to preserve
    SUBREG_PROMOTED_VAR_P on (extend:HI (subreg/s:QI (reg:SI))), and other
    places in the middle-end, has broken the build on several targets.
    
    The change to convert_modes inadvertently used the same
    subreg_promoted_mode idiom for retrieving the mode of a SUBREG_REG
    as the existing code just a few lines earlier.  Alas in the meantime,
    the original SUBREG gets replaced by one without SUBREG_PROMOTED_VAR_P,
    the whole raison-d'etre for my patch, and I'd not realized/noticed
    that subreg_promoted_mode asserts for this.  Alas neither the bootstrap
    and regression test on x86_64-pc-linux-gnu nor my testing on nvptx-none
    must have hit this particular case.  The logic of this transformation
    is sound, it's the implementation that's bitten me.
    
    This patch has been committed, after another "make bootstrap" on
    x86_64-pc-linux-gnu (just in case), and confirmation/pre-approval
    from Jeff Law that this indeed fixes the build failures seen on
    several platforms.
    
    My humble apologies again.
    
    2021-08-31  Roger Sayle  <roger@nextmovesoftware.com>
    
    gcc/ChangeLog
            * expr.c (convert_modes): Don't use subreg_promoted_mode on a
            SUBREG if it can't be guaranteed to a SUBREG_PROMOTED_VAR_P set.
            Instead use the standard (safer) is_a <scalar_int_mode> idiom.

Diff:
---
 gcc/expr.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/gcc/expr.c b/gcc/expr.c
index 5dd98a9bccc..17f2c2f3b8b 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -690,17 +690,20 @@ convert_modes (machine_mode mode, machine_mode oldmode, rtx x, int unsignedp)
       && SUBREG_CHECK_PROMOTED_SIGN (x, unsignedp))
     {
       scalar_int_mode int_orig_mode;
+      scalar_int_mode int_inner_mode;
       machine_mode orig_mode = GET_MODE (x);
       x = gen_lowpart (int_mode, SUBREG_REG (x));
 
       /* Preserve SUBREG_PROMOTED_VAR_P if the new mode is wider than
 	 the original mode, but narrower than the inner mode.  */
       if (GET_CODE (x) == SUBREG
-	  && GET_MODE_PRECISION (subreg_promoted_mode (x))
-	     > GET_MODE_PRECISION (int_mode)
 	  && is_a <scalar_int_mode> (orig_mode, &int_orig_mode)
 	  && GET_MODE_PRECISION (int_mode)
-	     > GET_MODE_PRECISION (int_orig_mode))
+	     > GET_MODE_PRECISION (int_orig_mode)
+	  && is_a <scalar_int_mode> (GET_MODE (SUBREG_REG (x)),
+				     &int_inner_mode)
+	  && GET_MODE_PRECISION (int_inner_mode)
+	     > GET_MODE_PRECISION (int_mode))
 	{
 	  SUBREG_PROMOTED_VAR_P (x) = 1;
 	  SUBREG_PROMOTED_SET (x, unsignedp);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-31 16:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-31 16:33 [gcc r12-3260] [Committed] Fix subreg_promoted_mode breakage on various platforms Roger Sayle

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