[Bug middle-end/33714] New: ivopts miscompiles insn-output.c
matz at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Tue Oct 9 15:52:00 GMT 2007
This was noticed by building a cross compiler from i386 to x86_64. gcc 4.2.1
will miscompile insn-output.c, the prologue_save_insn emitter. Can be
extracted to the attached runtime testcase. The loop exit condition is
miscompiled by ivopts with simply -O2. Before ivopts we have:
i_28 = i_48 - 1;
D.1652_15 = (long long int) i_28;
D.1654_18 = *D.1653_45;
D.1655_19 = D.1654_18->u.hwint[0];
if (D.1652_15 >= D.1655_19) goto <L19>; else goto <L11>;
i.e. it compares with i_48-1, which is the loop iterator. ivopts transforms
this into:
i_28 = i_48 - 1;
D.1858_83 = i_4 - 1;
D.1859_84 = (long long unsigned int) D.1858_83;
D.1860_85 = ivtmp.163_71 * 16;
D.1861_86 = D.1859_84 + D.1860_85;
D.1652_87 = (long long int) D.1861_86;
D.1652_15 = D.1652_87;
D.1654_18 = *D.1653_45;
D.1655_19 = D.1654_18->u.hwint[0];
ivtmp.163_72 = ivtmp.163_71 - 16;
if (D.1652_15 >= D.1655_19) goto <L19>; else goto <L11>;
i_4-1 is the base variable for the loop iterator. ivopts tries to express
the D.1652_15 in terms of that base and the new ivtmp.163. Unfortunately
that ivtmp is multiplied by 16, and also has a stepsize of 16 (the
multiplication by 16 actually is wrong even if the stepsize would be 16 as
that then would multiply by 256 for the use in the D.1860_85 expression).
--
Summary: ivopts miscompiles insn-output.c
Product: gcc
Version: 4.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: matz at gcc dot gnu dot org
GCC host triplet: i686-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33714
More information about the Gcc-bugs
mailing list