This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: An even smaller test case. Cast to int of char, and not...;
- From: Steven Bosscher <s dot bosscher at student dot tudelft dot nl>
- To: Diego Novillo <dnovillo at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: 11 Mar 2003 15:02:57 +0100
- Subject: Re: An even smaller test case. Cast to int of char, and not...;
- References: <1047329216.1099.190.camel@steven><1047333994.20913.3.camel@frodo> <1047338404.1098.207.camel@steven> <1047389529.969.10.camel@shadowfax>
Op di 11-03-2003, om 14:32 schreef Diego Novillo:
> On Mon, 2003-03-10 at 18:20, Steven Bosscher wrote:
>
> > This is a piece of libiberty/cplus-dem.c:demangle_prefix(). The inlined
> > strspn() causes an ICE, and hence a bootstrap failure, on at least
> > i[56]86, todays sources.
> >
> What are you bootstrapping with? While I can reproduce the failure with
> this testcase, I am yet to get a bootstrap failure on P3, P4, x86-64 and
> ppc.
>
> Thanks for the testcase. Diego.
I'm bootstrapping on and for i586-pc-linux-gnu.
system compiler is GCC 2.95.3.
glibc is 2.2.2.
The tree-ssa sources were up-to-date when I reported, and I updated last
night again to see if Jeff's changes made some differences, but the ICE
is still there. This was a C-only bootstrap.
The bootstrapped compiler is:
GNU C version 3.5-tree-ssa 20030302 (experimental) (i586-pc-linux-gnu)
compiled by GNU C version 3.5-tree-ssa 20030302 (experimental).
GGC heuristics: --param ggc-min-expand=42 --param ggc-min-heapsize=23891
The optimized tree is:
;; Function bar (bar)
bar ()
{
int T.3;
char ch;
T.3 = (int)ch;
{
const char accept;
(void)0;
{
char T.1;
char T.2;
const char * s;
while (1)
{
T.1 = *s;
T.2 = (const char)T.1;
if (T.2 != T.3)
{
goto <UL1070>;
}
};
<UL1070>:;
}
}
}
In the test case, the ICE happens on the condition of the "while"
statement (pretty safe claim since there is no loop body in the test
case :-).
So in the optimized version, the ICE is somewhere in "if (T.2 != T.3)".
I sent you a trace already, here is what I see in gdb:
GNU gdb 5.2.1
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i586-pc-linux-gnu"...se
tBreakpoint 1 at 0x8118756: file ../../gcc-ssa/gcc/diagnostic.c, line 1372.
Breakpoint 2 at 0x8049778
Breakpoint 3 at 0x8049558
(gdb) set args -O bug.c
(gdb) run
Starting program: /home/steven/devel/gcc/build-ssa/gcc/cc1 -O bug.c
Breakpoint 2 at 0x40056745
Breakpoint 3 at 0x40055337
foo bar
Breakpoint 1, fancy_abort (file=0x83be833 "../../gcc-ssa/gcc/explow.c", line=731,
function=0x83be8f4 "copy_to_mode_reg") at ../../gcc-ssa/gcc/diagnostic.c:1372
1372 internal_error ("in %s, at %s:%d", function, trim_filename (file), line);
(gdb) up
#1 0x0813cbc6 in copy_to_mode_reg () at ../../gcc-ssa/gcc/explow.c:731
731 abort ();
(gdb) up
#2 0x0825ff32 in prepare_operand (icode=841, x=0x40146560, opnum=1, mode=QFmode, wider_mode=16820,
unsignedp=0) at ../../gcc-ssa/gcc/optabs.c:3732
3732 x = copy_to_mode_reg (insn_data[icode].operand[opnum].mode, x);
(gdb) down
#1 0x0813cbc6 in copy_to_mode_reg () at ../../gcc-ssa/gcc/explow.c:731
731 abort ();
(gdb) l
726 do the computation. */
727 if (! general_operand (x, VOIDmode))
728 x = force_operand (x, temp);
729
730 if (GET_MODE (x) != mode && GET_MODE (x) != VOIDmode)
731 abort ();
732 if (x != temp)
733 emit_move_insn (temp, x);
734 return temp;
735 }
(gdb) p debug_rtx (x)
(reg/v:SI 58 [ T.3 ])
$1 = void
(gdb) p x->mode
$2 = SImode
(gdb) p mode
$3 = QImode
(gdb)
I don't know what to make of this, but I'm a bit confused about the
types we use... If you cheat a bit and make the .t14.optimized dump
compilable:
void
bar (void)
{
int _T3_;
char ch;
_T3_ = (int)ch;
{
const char accept;
(void)0;
{
char _T1_;
char _T2_;
const char * s;
while (1)
{
_T1_ = *s;
_T2_ = (const char) _T1_;
if (_T2_ != _T3_)
{
goto end;
}
};
end:;
}
}
}
Gives you:
;; Function bar (bar)
bar ()
{
int T.1;
int _T3_;
char ch;
_T3_ = (int)ch;
{
const char accept;
{
char _T1_;
char _T2_;
const char * s;
while (1)
{
{
_T1_ = *s;
(void)0;
T.1 = (int) _T1_;
if (T.1 != _T3_)
{
{
goto end;
}
}
}
};
<ULdb60>:;;
end:;
}
}
}
_T1_ is a char, and we cast it to "T.1 = (int) _T1_". So in this case
we compare one int with another ("int T.1" with "int _T3_"). In the
snippet that ICEs, we compare a "const char" to an "int". Maybe that
causes the problem?
Greetz
Steven