Bug 22239 - [4.0 Regression] i-cobol.adb:482: error: unrecognizable insn
Summary: [4.0 Regression] i-cobol.adb:482: error: unrecognizable insn
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: 4.1.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
: 22384 (view as bug list)
Depends on: 20126
Blocks:
  Show dependency treegraph
 
Reported: 2005-06-29 23:36 UTC by John David Anglin
Modified: 2005-10-25 20:12 UTC (History)
3 users (show)

See Also:
Host: hppa-*-linux-gnu
Target: hppa-*-linux-gnu
Build: hppa-*-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Patch to loop.c (318 bytes, patch)
2005-06-29 23:39 UTC, John David Anglin
Details | Diff
file that now ICEs with latest patch. (19.07 KB, application/octet-stream)
2005-07-08 23:02 UTC, Richard Earnshaw
Details

Note You need to log in before you can comment on or make changes to this bug.
Description John David Anglin 2005-06-29 23:36:08 UTC
../../xgcc -B../../  -c -g -O2 -fPIC -DELF=1 -DLINUX=1      -W -Wall -gnatpg  i-
cobol.adb -o i-cobol.o
i-cobol.adb: In function 'Interfaces.Cobol.To_Display.Convert':
i-cobol.adb:482: error: unrecognizable insn:
(insn 213 77 83 5 i-cobol.adb:466 (set (reg/f:SI 112)
        (minus:SI (plus:SI (reg:SI 156)
                (reg/f:SI 151 [ <variable>.result___36 ]))
            (const_int -1 [0xffffffff]))) -1 (nil)
    (nil))
+===========================GNAT BUG DETECTED==============================+
| 4.1.0 20050629 (experimental) (hppa-unknown-linux-gnu) GCC error:        |
| in extract_insn, at recog.c:2082                                         |
| Error detected at i-cobol.adb:989:1                                      |
| Please submit a bug report; see http://gcc.gnu.org/bugs.html.            |
| Use a subject line meaningful to you and us to track the bug.            |
| Include the entire contents of this bug box in the report.               |
| Include the exact gcc or gnatmake command that you entered.              |
| Also include sources listed below in gnatchop format                     |
| (concatenated together with no headers between files).                   |
+==========================================================================+

Please include these source files with error report
Note that list may not be accurate in some cases,
so please double check that the problem can still
be reproduced with the set of files listed.



raised TYPES.UNRECOVERABLE_ERROR : comperr.adb:380

The instruction is generated in the loop pass here:

(insn 96 95 213 5 i-cobol.adb:466 (set (reg:SI 132)
        (plus:SI (subreg:SI (reg:QI 131) 0)
            (const_int 48 [0x30]))) -1 (nil)
    (nil))

(insn 213 96 97 5 i-cobol.adb:466 (set (reg/f:SI 112)
        (minus:SI (plus:SI (reg:SI 156)
                (reg/f:SI 151 [ <variable>.result___36 ]))
            (const_int -1 [0xffffffff]))) -1 (nil)
    (nil))

(insn 97 213 98 5 i-cobol.adb:466 (set (mem/s/j:QI (plus:SI (reg/f:SI 112)
                (const_int -1 [0xffffffff])) [14 S1 A8])
        (subreg:QI (reg:SI 132) 3)) -1 (nil)
    (nil))
Comment 1 John David Anglin 2005-06-29 23:39:05 UTC
Created attachment 9177 [details]
Patch to loop.c

Testing patch as possible fix.
Comment 2 John David Anglin 2005-06-29 23:52:52 UTC
Looks like the following change introduced the regression:

2005-04-16  Alexandre Oliva  <aoliva@redhat.com>

        PR target/20126
        * loop.c (loop_givs_rescan): Handle non-replaceable (plus (reg)
        (const)).
Comment 3 Andrew Pinski 2005-06-30 01:52:52 UTC
So this is a latent bug on the 4.0 branch too.

I just wish loop.c would go away.
Comment 4 GCC Commits 2005-07-07 22:53:46 UTC
Subject: Bug 22239

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	danglin@gcc.gnu.org	2005-07-07 22:53:31

Modified files:
	gcc            : ChangeLog loop.c 

Log message:
	PR middle-end/22239
	* loop.c (loop_givs_rescan): Check that v->new_reg is a REG.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9376&r2=2.9377
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/loop.c.diff?cvsroot=gcc&r1=1.534&r2=1.535

Comment 5 Richard Earnshaw 2005-07-08 23:00:27 UTC
The latest patch causes a bootstrap failure on arm-elf and arm-netbsdelf.  I'll
attach a file momentarily.
Comment 6 Richard Earnshaw 2005-07-08 23:02:42 UTC
Created attachment 9233 [details]
file that now ICEs with latest patch.

Compile the this file with -O2 -g on an arm-elf cross
Comment 7 dave 2005-07-09 00:41:37 UTC
Subject: Re:  [4.0/4.1 Regression] i-cobol.adb:482: error: unrecognizable insn

> Compile the this file with -O2 -g on an arm-elf cross

Looks like a target, or possibly a different loop bug to me:

(gdb) p debug_rtx (v->new_reg)
(plus:SI (reg:SI 993)
    (const_int -60 [0xffffffc4]))

(gdb) p debug_rtx (v->insn)
(insn 1785 3575 1792 (parallel [
            (set (mem/s:SI (reg/f:SI 624) [41 adpm S4 A32])
		(reg:SI 0 r0))
	    (set (mem/s:SI (plus:SI (reg/f:SI 624)
			(const_int 4 [0x4])) [41 adpm S4 A32])
		(reg:SI 1 r1))
	    (set (mem/s:SI (plus:SI (reg/f:SI 624)
			(const_int 8 [0x8])) [41 adpm S4 A32])
		(reg:SI 2 r2))
	    (set (mem/s:SI (plus:SI (reg/f:SI 624)
			(const_int 12 [0xc])) [41 adpm S4 A32])
		(reg:SI 3 r3))
	]) -1 (nil)
     (nil))

(gdb) p debug_rtx (*v->location)
(plus:SI (reg/f:SI 624)
    (const_int 12 [0xc]))

So, it's apparently not valid to substitute a reg into the fourth instruction
of the above parallel on arm-elf.

Dave
Comment 8 dave 2005-07-09 02:44:54 UTC
Subject: Re:  [4.0/4.1 Regression] i-cobol.adb:482: error: unrecognizable insn

>  --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=9233&action=view)
> file that now ICEs with latest patch.
> 
> Compile the this file with -O2 -g on an arm-elf cross

This is totally untested but possibly something like the change below
would resolve the problem for both ports.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

Index: loop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop.c,v
retrieving revision 1.535
diff -u -3 -p -r1.535 loop.c
--- loop.c	7 Jul 2005 22:53:28 -0000	1.535
+++ loop.c	9 Jul 2005 02:34:18 -0000
@@ -5496,14 +5496,21 @@ loop_givs_rescan (struct loop *loop, str
 						  v->new_reg));
 	  else if (GET_CODE (*v->location) == PLUS
 		   && REG_P (XEXP (*v->location, 0))
-		   && REG_P (v->new_reg)
 		   && CONSTANT_P (XEXP (*v->location, 1)))
-	    loop_insn_emit_before (loop, 0, v->insn,
-				   gen_move_insn (XEXP (*v->location, 0),
-						  gen_rtx_MINUS
-						  (GET_MODE (*v->location),
-						   v->new_reg,
-						   XEXP (*v->location, 1))));
+	    {
+	      rtx reg, seq;
+	      start_sequence ();
+	      if (REG_P (v->new_reg))
+		reg = v->new_reg;
+	      else
+		reg = force_reg (GET_MODE (*v->location), v->new_reg);
+	      emit_move_insn (XEXP (*v->location, 0),
+			      gen_rtx_MINUS (GET_MODE (*v->location), reg,
+					     XEXP (*v->location, 1)));
+	      seq = get_insns ();
+	      end_sequence ();
+	      loop_insn_emit_before (loop, 0, v->insn, seq);
+	    }
 	  else
 	    {
 	      /* If it wasn't a reg, create a pseudo and use that.  */
Comment 9 Alexandre Oliva 2005-07-09 17:08:24 UTC
Please see bug 20126, it contains a patch that will likely fix all of the
problems you've run into, and some discussion on why it's not in yet.  If you
find it to fix the problem you have, and it's unsolvable otherwise, feel free to
go ahead and check it in.
Comment 10 Andrew Pinski 2005-07-09 23:21:39 UTC
*** Bug 22384 has been marked as a duplicate of this bug. ***
Comment 11 GCC Commits 2005-07-11 03:56:20 UTC
Subject: Bug 22239

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	danglin@gcc.gnu.org	2005-07-11 03:56:14

Modified files:
	gcc            : ChangeLog loop.c 

Log message:
	PR middle-end/22239
	PR target/20126
	* loop.c (loop_givs_rescan): Use expand_simple_binop instead of
	gen_rtx_MINUS to handle non-replaceable (plus ((x) (const)).

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9401&r2=2.9402
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/loop.c.diff?cvsroot=gcc&r1=1.535&r2=1.536

Comment 12 Andrew Pinski 2005-10-25 20:12:44 UTC
Fixed so closing as such.