Bug 24497 - [4.0 Regression] internal compiler error: in apply_opt_in_copies, at loop-unroll.c:2122
Summary: [4.0 Regression] internal compiler error: in apply_opt_in_copies, at loop-unr...
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.1.0
: P5 normal
Target Milestone: 4.1.0
Assignee: Zdenek Dvorak
Keywords: ice-checking, ice-on-valid-code
Depends on:
Reported: 2005-10-24 01:02 UTC by Paul Brook
Modified: 2007-02-03 15:47 UTC (History)
4 users (show)

See Also:
Target: m68k-elf
Known to work: 4.1.0 4.1.1 4.1.2 3.3.3 4.2.0
Known to fail: 4.0.2 3.4.0
Last reconfirmed: 2006-02-20 18:29:04


Note You need to log in before you can comment on or make changes to this bug.
Description Paul Brook 2005-10-24 01:02:54 UTC
long long foo(void)
  long long unsigned s=0;
  long long unsigned b;
  for (b = 0; b++, s == 0; )
      s = b;
  return s;

Compiled with -O2 -funroll-all-loops gives

internal compiler error: in apply_opt_in_copies, at loop-unroll.c:2122

The problematic line is:

gcc_assert (rtx_equal_p (PATTERN (insn), PATTERN (orig_insn)));

And PATTERN(insn) is

(parallel [
        (set (reg/v:DI 32 [ b ])
            (plus:DI (reg/v:DI 32 [ b ])
                (const_int 1 [0x1])))
        (clobber (scratch:SI))

This fails because rtx_equal_p thinks the two (scratch:SI) are different scratch registers, and returns 0.
Comment 1 Paul Brook 2005-10-24 01:33:02 UTC
Original testcase above is reduced from
Comment 2 Andrew Pinski 2005-10-24 01:35:07 UTC
I should mention why I marked this as a regression.  loop-unroll.c is new in 3.4.x.
Comment 3 Kazu Hirata 2005-11-06 04:25:25 UTC
Not reproducible using x86_64-pc-linux-gnu X m68k-none-elf.

Paul, is this still reproducible?

I also tried, gcc.c-torture/execute/920501-6.c, but I didn't get any ICE.
Comment 4 Paul Brook 2005-11-06 12:23:07 UTC
Both still fail for me

Target: m68k-elf
Configured with: ../gcc/configure --prefix=/home/paul/arm --target=m68k-elf --with-newlib --disable-shared --disable-threads --enable-languages=c,c++
Thread model: single
gcc version 4.1.0 20051106 (experimental)
Comment 5 Janis Johnson 2005-11-11 23:48:45 UTC
A regression hunt using an m68k-elf cross compiler on powerpc-linux shows
that the test failure begins with this patch:

r87487 | rakdver | 2004-09-14 08:05:46 +0000 (Tue, 14 Sep 2004) | 17 lines
        * Makefile.in (loop-unroll.o): Add HASHTAB_H and RECOG_H dependency.
        * basic-block.h (struct reorder_block_def): Add copy_number field.
        * cfgloop.h (biv_p): Declare.
        * cfgloopmanip.c (duplicate_loop_to_header_edge): Set copy_number.
        * common.opt (fsplit-ivs-in-unroller): New flag.
        * loop-iv.c (biv_p): New function.
        * loop-unroll.c: Include hashtab.h and recog.h.
        (struct iv_to_split, struct split_ivs_info): New types.
        (analyze_ivs_to_split, si_info_start_duplication, split_ivs_in_copies,
        free_si_info, si_info_hash, si_info_eq, analyze_iv_to_split_insn,
        determine_split_iv_delta, get_ivts_expr, allocate_basic_variable,
        insert_base_initialization, split_iv): New functions.
        (peel_loop_completely, unroll_loop_constant_iterations,
        unroll_loop_runtime_iterations, peel_loop_simple, unroll_loop_stupid):
        Use them.
        * doc/invoke.texi (-fsplit-ivs-in-unroller): Document.

Comment 6 Zdenek Dvorak 2005-11-18 10:31:49 UTC
Subject: Bug 24497

Author: rakdver
Date: Fri Nov 18 10:31:45 2005
New Revision: 107171

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=107171
	PR rtl-optimization/24497
	* loop-unroll.c (apply_opt_in_copies): Do not verify equality of
	the copied insn.


Comment 7 Steven Bosscher 2006-02-27 14:12:10 UTC
Was this fixed with the patch in comment #6?
Comment 8 Eric Botcazou 2006-08-11 07:33:55 UTC
Paul, could you update the status of this PR?  Thanks in advance.
Comment 9 Gabriel Dos Reis 2007-02-03 15:47:11 UTC
Fixed in GCC-4.1.0 and higher.