Bug 24912 - [4.1/4.2 Regression] m68k build failure: ICE: in reload_cse_simplify_operands
Summary: [4.1/4.2 Regression] m68k build failure: ICE: in reload_cse_simplify_operands
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.1.0
: P3 normal
Target Milestone: 4.1.0
Assignee: Hans-Peter Nilsson
URL:
Keywords: ice-on-valid-code, patch
: 24850 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-11-17 15:28 UTC by Paul Brook
Modified: 2006-01-31 16:28 UTC (History)
5 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: m68k-elf
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2005-11-18 20:08:40


Attachments
Preprocessed file that produces ICE (16.86 KB, application/octet-stream)
2005-11-17 17:59 UTC, Joel Sherrill
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Brook 2005-11-17 15:28:39 UTC
m68k-elf build fails building libiberty/regex.c.

Reduced testcase below:

void foo(void);
void
bar (unsigned char *p)
{
  int j;
  j = *(p) ;
  j += ((signed char) (*p) ) << 8;
  if (j)
    foo();
}

Compiled with m68-elf-gcc -O2 gives

test.c:10: error: insn does not satisfy its constraints:
(insn 40 16 41 0 (set (reg:SI 2 %d2)
        (sign_extend:SI (reg:HI 0 %d0 [34]))) 65 {*68k_extendhisi2} (nil)
    (nil))
test.c:10: internal compiler error: in reload_cse_simplify_operands, at postreload.c:393

Appears to have been caused by r106804 (reverting this patch allows the build to succeed):

2005-11-12  Hans-Peter Nilsson  <hp@axis.com>

       PR middle-end/24750
       * reload.c (find_reloads_address_1) <case TRUNCATE, SIGN_EXTEND,
       ZERO_EXTEND>: New cases.
Comment 1 Joel Sherrill 2005-11-17 15:36:02 UTC
Also fails building m68k-rtems4.7.
Comment 2 Hans-Peter Nilsson 2005-11-17 16:26:25 UTC
Confirmed with r107118.
Comment 3 Joel Sherrill 2005-11-17 17:59:00 UTC
Created attachment 10265 [details]
Preprocessed file that produces ICE

This is the command line which produces the ICE.  I changed -c to -E to produce the attached file.

/home/joel/gcc-work/head/b-m68k-rtems4.7/./gcc/xgcc -B/home/joel/gcc-work/head/b-m68k-rtems4.7/./gcc/ -nostdinc -B/home/joel/gcc-work/head/b-m68k-rtems4.7/m68k-rtems4.7/newlib/ -isystem /home/joel/gcc-work/head/b-m68k-rtems4.7/m68k-rtems4.7/newlib/targ-include -isystem /home/joel/gcc-work/head/gcc-head-test/newlib/libc/include -B/home/joel/gcc-41-test//m68k-rtems4.7/bin/ -B/home/joel/gcc-41-test//m68k-rtems4.7/lib/ -isystem /home/joel/gcc-41-test//m68k-rtems4.7/include -isystem /home/joel/gcc-41-test//m68k-rtems4.7/sys-include -c -DHAVE_CONFIG_H -O2 -g -O2  -I. -I../../../gcc-head-test/libiberty/../include  -W -Wall -pedantic -Wwrite-strings -Wstrict-prototypes ../../../gcc-head-test/libiberty/regex.c -c
Comment 4 Hans-Peter Nilsson 2005-11-17 22:59:29 UTC
Reload is middle-end, not rtl-optimization.
Comment 5 Hans-Peter Nilsson 2005-11-18 02:03:05 UTC
I have a patch under test.  However, with and without that patch, *and* with
and without r106804 (only with-with and without-without combinations tested),
I still get with r107118 when building libgfortran:

/home/hp/combined/m68k-elf/./gcc/xgcc -B/home/hp/combined/m68k-elf/./gcc/ -nostdinc -B/home/hp/combined/m68k-elf/m68k-elf/newlib/\
 -isystem /home/hp/combined/m68k-elf/m68k-elf/newlib/targ-include -isystem /home/hp/combined/combined/newlib/libc/include -B/usr/\
local/m68k-elf/bin/ -B/usr/local/m68k-elf/lib/ -isystem /usr/local/m68k-elf/include -isystem /usr/local/m68k-elf/sys-include -L/h\
ome/hp/combined/m68k-elf/./ld -DHAVE_CONFIG_H -I. -I/home/hp/combined/combined/libgfortran -I. -iquote/home/hp/combined/combined/\
libgfortran/io -std=gnu99 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wextra -Wwrite-strings -O2 -g -O\
2 -c /home/hp/combined/combined/libgfortran/intrinsics/stat.c -o stat.o
/home/hp/combined/combined/libgfortran/intrinsics/stat.c: In function 'fstat_i8_sub':
/home/hp/combined/combined/libgfortran/intrinsics/stat.c:448: error: unrecognizable insn:
(insn 83 82 84 10 /home/hp/combined/combined/libgfortran/intrinsics/stat.c:401 (set (mem:DI (plus:SI (reg:SI 46)
                (reg:SI 34 [ D.3918 ])) [2 S8 A16])
        (zero_extend:DI (mem/s/c:SI (plus:SI (reg/f:SI 26 virtual-stack-vars)
                    (const_int -56 [0xffffffc8])) [3 sb.st_mode+0 S4 A16]))) -1 (nil)
    (nil))
/home/hp/combined/combined/libgfortran/intrinsics/stat.c:448: internal compiler error: in extract_insn, at recog.c:2084

I'm restarting a build without libgfortran.
Comment 6 Hans-Peter Nilsson 2005-11-18 20:08:40 UTC
Patch at <URL:http://gcc.gnu.org/ml/gcc-patches/2005-11/msg01373.html>.
Comment 7 Kazu Hirata 2005-11-19 20:48:04 UTC
*** Bug 24850 has been marked as a duplicate of this bug. ***
Comment 8 Hans-Peter Nilsson 2005-11-19 21:54:29 UTC
Subject: Bug 24912

Author: hp
Date: Sat Nov 19 21:54:26 2005
New Revision: 107230

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=107230
Log:
	PR middle-end/24912
	* gcc.dg/torture/pr24912-1.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr24912-1.c
Modified:
    trunk/gcc/testsuite/ChangeLog

Comment 9 Hans-Peter Nilsson 2005-11-19 21:56:22 UTC
Subject: Bug 24912

Author: hp
Date: Sat Nov 19 21:56:17 2005
New Revision: 107231

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=107231
Log:
	PR middle-end/24912
	PR middle-end/24750
	* reload.c (find_reloads_address_1): Mention dependency on
	gen_reload.
	* reload1.c (gen_reload): For IN with an unary operation, try
	moving inner expression to OUT if trivial SET is not valid.
	Confirm that the result is valid.  Move common code block into...
	(emit_insn_if_valid_for_reload): New function.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/reload.c
    trunk/gcc/reload1.c

Comment 10 Hans-Peter Nilsson 2005-11-19 21:58:27 UTC
Subject: Bug 24912

Author: hp
Date: Sat Nov 19 21:58:23 2005
New Revision: 107232

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=107232
Log:
	PR middle-end/24912
	* gcc.dg/torture/pr24912-1.c: New test.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/gcc.dg/torture/pr24912-1.c
Modified:
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog

Comment 11 Hans-Peter Nilsson 2005-11-19 21:59:52 UTC
Subject: Bug 24912

Author: hp
Date: Sat Nov 19 21:59:48 2005
New Revision: 107233

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=107233
Log:
	PR middle-end/24912
	PR middle-end/24750
	* reload.c (find_reloads_address_1): Mention dependency on
	gen_reload.
	* reload1.c (gen_reload): For IN with an unary operation, try
	moving inner expression to OUT if trivial SET is not valid.
	Confirm that the result is valid.  Move common code block into...
	(emit_insn_if_valid_for_reload): New function.

Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/reload.c
    branches/gcc-4_1-branch/gcc/reload1.c

Comment 12 Hans-Peter Nilsson 2005-11-21 03:44:02 UTC
Non-empty comment to appease bugzilla.
Comment 13 Jorn Wolfgang Rennecke 2006-01-31 16:28:54 UTC
(In reply to comment #9)
> Subject: Bug 24912
> 
> Author: hp
> Date: Sat Nov 19 21:56:17 2005
> New Revision: 107231
> 
> URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=107231
> Log:
>         PR middle-end/24912
>         PR middle-end/24750
>         * reload.c (find_reloads_address_1): Mention dependency on
>         gen_reload.
>         * reload1.c (gen_reload): For IN with an unary operation, try
>         moving inner expression to OUT if trivial SET is not valid.
>         Confirm that the result is valid.  Move common code block into...
>         (emit_insn_if_valid_for_reload): New function.
> 
> Modified:
>     trunk/gcc/ChangeLog
>     trunk/gcc/reload.c
>     trunk/gcc/reload1.c
> 

This patch is incorrect, and has caused PR middle-end/25335:

> +  insn = emit_insn (insn);
> +  code = recog_memoized (insn);

This test is not valid because subst_reload is called only after emit_reload_insns.

> +      /* If that failed, move the inner operand to the reload
> +	 register, and try the same unop with the inner expression
> +	 replaced with the reload register.  */
> +      op1 = XEXP (in, 0);

This ignores any replacements scheduled for &XEXP (in, 0) .
As a result, addressing modes with side effects can be duplicated.

In the test case for middle-end/25335, the patch for middle-end/24750
has registered such a replacement.

A possible solution would be calling subst_reloads before emit_reload_insns,
although it will require careful checking if this will work properly for all
the things that subst_reload does.