public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/33714]  New: ivopts miscompiles insn-output.c
@ 2007-10-09 15:52 matz at gcc dot gnu dot org
  2007-10-09 15:52 ` [Bug middle-end/33714] " matz at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: matz at gcc dot gnu dot org @ 2007-10-09 15:52 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-10-22  8:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-09 15:52 [Bug middle-end/33714] New: ivopts miscompiles insn-output.c matz at gcc dot gnu dot org
2007-10-09 15:52 ` [Bug middle-end/33714] " matz at gcc dot gnu dot org
2007-10-09 16:16 ` [Bug middle-end/33714] [4.2 Regression] " rguenth at gcc dot gnu dot org
2007-10-09 16:51 ` rakdver at gcc dot gnu dot org
2007-10-12  3:03 ` rakdver at gcc dot gnu dot org
2007-10-12 22:27 ` rakdver at gcc dot gnu dot org
2007-10-22  8:38 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).