[Bug other/31363] New: long long optimization problem

2007-03-26 Thread gr at collax dot com
gcc version 4.0.4
Target: i686-pc-linux-gnu
Configured with: ../configure --prefix=/var/tmp

compiling with "-O" on input:

void
foo(unsigned long long c)
{
if (c & 0x8000)
puts("bug");
}

int
main(void)
{
foo(0x1ULL);
return 0;
}

produces "bug". Without "-O", it does not.


-- 
   Summary: long long optimization problem
   Product: gcc
   Version: 4.0.4
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: other
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gr at collax dot com


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



[Bug target/31363] long long optimization problem

2007-03-26 Thread gr at collax dot com


--- Comment #2 from gr at collax dot com  2007-03-26 19:03 ---
(In reply to comment #1)
> Works for me.

Hm. Just to be completely sure, my source archive gcc-4.0.4.tar.bz2 has md5sum
8970debbc55bea85ee80961d733080f0, as two other copies fetched from different
mirrors. I compiled it on two different i386 Linux distributions, getting the
same result in both cases.

The generated assembler code in question is

foo:
pushl   %ebp
movl%esp, %ebp
subl$8, %esp
movl8(%ebp), %eax
movl12(%ebp), %edx
andl$-2147483648, %eax
movl%edx, %ecx
orl %eax, %ecx
je  .L4
movl$.LC0, (%esp)
callputs
.L4:
leave
ret

If I understand this correctly, the upper half of the long long, in %edx,
remains unaltered but is ORed into the value that is finally tested.

What conditions could have lead to different results here?


-- 


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