public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/47670] New: Gcc 4.5.1 inconsistent optimisation of loop with mixed 32bit and 64bit arithmetic
@ 2011-02-09 20:56 argondsgn at gmail dot com
  2011-02-09 21:14 ` [Bug c/47670] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: argondsgn at gmail dot com @ 2011-02-09 20:56 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47670

           Summary: Gcc 4.5.1 inconsistent optimisation of loop with mixed
                    32bit and 64bit arithmetic
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: argondsgn@gmail.com


Created attachment 23290
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23290
Output of gcc -v save-temps -O2 bug.c

int main(int argc, char *argv[]) 
{ 
    int i;
    long long count=0;
    int ret;
    for (i=0;i<9;i++)
    {
        count+=i*0x40000000;      
    }
    ret=count>>32;
    return ret;
}

produces different answers when compiled with 
gcc -O1 bug.c      (returns -1)
or
gcc -O2 bug.c      (returns 9)

Judging from the assembler output with -S, this loop is optimised to a
different constant expression in the two cases.

It works with gcc 3.4.4, but not with gcc 4.5.1 (I haven't tested any other
versions yet)

(First time I've attempted to submit a bug report to an open source project, so
many apologies if this is already fixed, an issue with my understanding of C,
or in the wrong category!)


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

end of thread, other threads:[~2011-02-09 21:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-09 20:56 [Bug c/47670] New: Gcc 4.5.1 inconsistent optimisation of loop with mixed 32bit and 64bit arithmetic argondsgn at gmail dot com
2011-02-09 21:14 ` [Bug c/47670] " rguenth at gcc dot gnu.org
2011-02-09 21:20 ` rguenth at gcc dot gnu.org
2011-02-09 21:54 ` jakub at gcc dot gnu.org
2011-02-09 22:00 ` argondsgn at gmail dot com

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).