Bug 38991 - [4.3/4.4 Regression] SH: ICE in extract_insn at recog.c:1990
Summary: [4.3/4.4 Regression] SH: ICE in extract_insn at recog.c:1990
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.3.2
: P4 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2009-01-27 20:25 UTC by Ryan Mansfield
Modified: 2009-04-29 16:14 UTC (History)
3 users (show)

See Also:
Host: i486-build_pc-linux-gnu
Target: sh4-unknown-linux-gnu
Build: i486-build_pc-linux-gnu
Known to work: 4.2.4
Known to fail: 4.3.3 4.4.0
Last reconfirmed: 2009-02-03 13:31:38


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan Mansfield 2009-01-27 20:25:06 UTC
$ cat /home/ryan/reduced.i
     typedef unsigned int  _Uint16t __attribute__((__aligned__(2))) __attribute__((__mode__(__HI__)));
     struct timeval { unsigned tv_sec; };
     extern volatile struct timeval mono_time;
     struct a { unsigned int time1;   };
     void sppp_input() {
        struct a *ch;
        unsigned t;
        t = mono_time.tv_sec * 1000;
        ch->time1 = (__builtin_constant_p((((unsigned short) t))) ? (((((((unsigned short) t))) >> 8) & 0xFF) | ((((((unsigned short) t))) & 0xFF) << 8)) : ({  _Uint16t __reg;  __asm__( "swap.b %0, %0;" : "=r" (__reg) : "0" ((((unsigned short) t))) );  __reg;  }          ));
     }
$ ./sh4-unknown-linux-gnu-gcc-4.3.2 -O1 ~/reduced.i -c -v
Using built-in specs.
Target: sh4-unknown-linux-gnu
Configured with: /home/ryan/crosstool-ng-1.3.1/targets/src/gcc-4.3.2/configure --build=i486-build_pc-linux-gnu --host=i486-build_pc-linux-gnu --target=sh4-unknown-linux-gnu --prefix=/home/ryan/crosstool-ng-1.3.1/targets/sh4-unknown-linux-gnu/build/gcc-core-static --with-local-prefix=/home/ryan/x-tools/sh4-unknown-linux-gnu/sh4-unknown-linux-gnu/sys-root --disable-multilib --with-sysroot=/home/ryan/x-tools/sh4-unknown-linux-gnu/sh4-unknown-linux-gnu/sys-root --with-newlib --enable-threads=no --disable-shared --enable-__cxa_atexit --disable-nls --enable-symvers=gnu --enable-languages=c --enable-target-optspace
Thread model: single
gcc version 4.3.2 (GCC)
COLLECT_GCC_OPTIONS='-O1' '-c' '-v'
 /home/ryan/crosstool-ng-1.3.1/targets/sh4-unknown-linux-gnu/build/gcc-core-static/libexec/gcc/sh4-unknown-linux-gnu/4.3.2/cc1 -fpreprocessed /home/ryan/reduced.i -quiet -dumpbase reduced.i -auxbase reduced -O1 -version -o /tmp/cc8aeDRs.s
GNU C (GCC) version 4.3.2 (sh4-unknown-linux-gnu)
        compiled by GNU C version 4.3.1, GMP version 4.2.1, MPFR version 2.2.1.
GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=129356
Compiler executable checksum: ee076cb4ac207bb74a2571e911139f3f
/home/ryan/reduced.i: In function 'sppp_input':
/home/ryan/reduced.i:10: error: unrecognizable insn:
(insn 23 8 10 3 /home/ryan/reduced.i:9 (set (reg:HI 163)
        (subreg:HI (reg:SI 149 macl) 0)) -1 (expr_list:REG_DEAD (reg:SI 149 macl)
        (nil)))
/home/ryan/reduced.i:10: internal compiler error: in extract_insn, at recog.c:1990
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Reproducible with gcc 4.3.3 as well.
Comment 1 Ryan Mansfield 2009-01-27 21:36:14 UTC
Also reproducible with gcc version 4.4.0 20090127 (experimental) [trunk revision 143711] (GCC)
Comment 2 Kazumoto Kojima 2009-02-03 13:31:38 UTC
It seems that the move insn in problem is generated when reloading
but has no insn definition matched.

The patch

--- ORIG/trunk/gcc/config/sh/predicates.md	2008-04-05 09:19:14.000000000 +0900
+++ INTEST/trunk/gcc/config/sh/predicates.md	2009-02-03 14:40:07.000000000 +0900
@@ -392,12 +392,6 @@
 	return 0;
     }
 
-  if ((mode == QImode || mode == HImode)
-      && (GET_CODE (op) == SUBREG
-	  && GET_CODE (XEXP (op, 0)) == REG
-	  && system_reg_operand (XEXP (op, 0), mode)))
-    return 0;
-
   if (TARGET_SHMEDIA
       && (GET_CODE (op) == PARALLEL || GET_CODE (op) == CONST_VECTOR)
       && sh_rep_vec (op, mode))

will workaround this issue, though it may be slightly invasive
and a thorough test will be needed.

BTW, the asm statement in the test case looks a bit worse than

__asm__( "swap.b %1, %0;" : "=r" (__reg) : "r" ((unsigned short) t));

which give a chance for compiler to allocate better registers
in general.  The above asm can avoid this PR too.
Comment 3 Kazumoto Kojima 2009-02-06 00:29:14 UTC
Subject: Bug 38991

Author: kkojima
Date: Fri Feb  6 00:29:03 2009
New Revision: 143978

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143978
Log:
	PR target/38991
	* config/sh/predicates.md (general_movsrc_operand): Don't check
	the subreg of system registers here.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/sh/predicates.md

Comment 4 Kazumoto Kojima 2009-02-08 00:53:42 UTC
Subject: Bug 38991

Author: kkojima
Date: Sun Feb  8 00:53:30 2009
New Revision: 144013

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=144013
Log:
	Backport from mainline:
	2009-02-05  Kaz Kojima  <kkojima@gcc.gnu.org>

	PR target/38991
	* config/sh/predicates.md (general_movsrc_operand): Don't check
	the subreg of system registers here.


Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/config/sh/predicates.md

Comment 5 Kazumoto Kojima 2009-02-08 00:55:12 UTC
Fixed.