Bug 36238 - [4.4 Regression] ICE in reg_or_subregno, at jump.c:1730
Summary: [4.4 Regression] ICE in reg_or_subregno, at jump.c:1730
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.4.0
: P2 normal
Target Milestone: 4.4.0
Assignee: Andrew Pinski
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: ice-on-valid-code
Depends on:
Reported: 2008-05-15 04:08 UTC by John Regehr
Modified: 2008-08-10 04:55 UTC (History)
4 users (show)

See Also:
Target: i?86-*-* x86_64-*-*
Known to work:
Known to fail:
Last reconfirmed: 2008-05-15 08:56:11


Note You need to log in before you can comment on or make changes to this bug.
Description John Regehr 2008-05-15 04:08:42 UTC
[regehr@babel tmp0]$ current-gcc -O small.c
small.c: In function 'func_5':
small.c:27: internal compiler error: in reg_or_subregno, at jump.c:1730
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

[regehr@babel tmp0]$ current-gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../configure --program-prefix=current- --enable-languages=c,c++ --prefix=/home/regehr
Thread model: posix
gcc version 4.4.0 20080514 (experimental) (GCC) 

[regehr@babel tmp0]$ cat small.c
typedef signed char int8_t;
typedef int int32_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
int32_t g_19 = 0x67F5AEE0L;
uint16_t g_169 = 0x89E3L;
const volatile uint32_t g_258 = 0x63AFEBCAL;
int32_t func_11;
int32_t func_29;
func_5 (int32_t p_6, int32_t p_8, uint16_t p_10)
  if (lshift_s_s (func_11, p_8))
      int8_t l_18 = 0x6FL;
      if (l_18)
	for (p_6 = -14;; g_19 += 6)
	    int32_t l_283 = -1L;
	    if (((0x45L / 1L) > 0x07414511L * 1L / 1L > func_29) / 1L)
	      for (p_8 = 6;; p_8 -= 5)
		l_283 = 0xC90541F7L;
    g_169 = g_258;
Comment 1 Richard Biener 2008-05-15 08:56:11 UTC

#1  0x00000000007607dd in reg_or_subregno (reg=0x2b3ca9894d80)
    at /space/rguenther/src/svn/trunk/gcc/jump.c:1730
1730      gcc_assert (REG_P (reg));
(gdb) call debug_rtx (reg)
(mem/v/u/c/i:SI (symbol_ref:DI ("g_258") [flags 0x2] <var_decl 0x2b3ca8fa81e0 g_258>) [0 g_258+0 S4 A32])

#0  fancy_abort (file=0xf2b220 "/space/rguenther/src/svn/trunk/gcc/jump.c", 
    line=1730, function=0xf2bba0 "reg_or_subregno")
    at /space/rguenther/src/svn/trunk/gcc/diagnostic.c:654
#1  0x00000000007607dd in reg_or_subregno (reg=0x2b3ca9894d80)
    at /space/rguenther/src/svn/trunk/gcc/jump.c:1730
#2  0x0000000000831713 in gen_reload (out=0x2b3ca9894da0, in=0x2b3ca9894580, 
    opnum=1, type=RELOAD_FOR_INPUT)
    at /space/rguenther/src/svn/trunk/gcc/reload1.c:8025
#3  0x000000000082e5ce in emit_input_reload_insns (chain=0x1432790, 
    rl=0x13ec0c8, old=0x2b3ca9894580, j=1)
    at /space/rguenther/src/svn/trunk/gcc/reload1.c:6975
#4  0x000000000082f251 in do_input_reload (chain=0x1432790, rl=0x13ec0c8, j=1)
    at /space/rguenther/src/svn/trunk/gcc/reload1.c:7269
#5  0x000000000082fad9 in emit_reload_insns (chain=0x1432790)
    at /space/rguenther/src/svn/trunk/gcc/reload1.c:7460
#6  0x00000000008271ad in reload_as_needed (live_known=1)
    at /space/rguenther/src/svn/trunk/gcc/reload1.c:4136
#7  0x000000000081f5e6 in reload (first=0x2b3ca9893040, global=1)
    at /space/rguenther/src/svn/trunk/gcc/reload1.c:1145
#8  0x0000000000e1ec90 in global_alloc ()
Comment 2 Andrew Pinski 2008-05-16 17:54:03 UTC
I just fixed this bug in reload1.c this week for the PS3 toolchain, I will forward port the patch.
This is related to PR 26826.

Index: ../../gcc/reload1.c
--- ../../gcc/reload1.c (revision 2480)
+++ ../../gcc/reload1.c (working copy)
@@ -7635,9 +7635,11 @@ gen_reload (rtx out, rtx in, int opnum,

   /* If we need a memory location to do the move, do it that way.  */
-  else if ((REG_P (in) || GET_CODE (in) == SUBREG)
+  else if ((REG_P (in)
+           || (GET_CODE (in) == SUBREG && REG_P (SUBREG_REG (in))))
           && reg_or_subregno (in) < FIRST_PSEUDO_REGISTER
-          && (REG_P (out) || GET_CODE (out) == SUBREG)
+          && (REG_P (out)
+               || (GET_CODE (out) == SUBREG && REG_P (SUBREG_REG (out))))
           && reg_or_subregno (out) < FIRST_PSEUDO_REGISTER
           && SECONDARY_MEMORY_NEEDED (REGNO_REG_CLASS (reg_or_subregno (in)),
                                       REGNO_REG_CLASS (reg_or_subregno (out)),

Comment 3 Andrew Pinski 2008-07-14 12:57:33 UTC
Testing this on x86-darwin right now.  though darwin's libfortran is broken so it might take a while.
Comment 4 Andrew Pinski 2008-08-10 04:55:29 UTC
Fixed, sorry this too so long to fix, there were other failures that were blocking me to commit this patch.
Comment 5 Andrew Pinski 2008-08-10 04:56:04 UTC
Subject: Bug 36238

Author: pinskia
Date: Sun Aug 10 04:54:37 2008
New Revision: 138924

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=138924
2008-08-09  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR middle-end/36238
        * reload1.c (gen_reload): Guard calls to get_secondary_mem
        for memory subregs.

2008-08-09  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR middle-end/36238
        * gcc.c-torture/compile/pr36238.c: New testcase.