This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/31679] Incorrect result of multiplication long long by 0xFFFFFFFFLL constant.
- From: "ian dot rogers at manchester dot ac dot uk" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 16 May 2007 13:01:57 -0000
- Subject: [Bug target/31679] Incorrect result of multiplication long long by 0xFFFFFFFFLL constant.
- References: <bug-31679-14450@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #5 from ian dot rogers at manchester dot ac dot uk 2007-05-16 14:01 -------
For the following code given in [1] GCC produces identical multiplication by
constant code [2]. I think as 0x0FFFFFFFF is one of the parameters in this bug
the fact we generate identical multiplication code for 0x1FFFFFFFF means this
is another example of this error.
Thanks,
Ian Rogers
[1]
test.c:
extern long long x;
long long foo() {
return x * ((((long long)0) << 32) + -1);
}
long long foo2() {
return x * ((((long long)1) << 32) + -1);
}
[2]
test.s:
.file "test.c"
.text
.p2align 4,,15
.globl foo
.type foo, @function
foo:
movl x, %eax
movl x+4, %edx
pushl %ebp
movl %esp, %ebp
negl %eax
popl %ebp
adcl $0, %edx
negl %edx
ret
.size foo, .-foo
.p2align 4,,15
.globl foo2
.type foo2, @function
foo2:
movl x, %eax
movl x+4, %edx
pushl %ebp
movl %esp, %ebp
negl %eax
popl %ebp
adcl $0, %edx
negl %edx
ret
.size foo2, .-foo2
.ident "GCC: (GNU) 4.1.2 20061115 (prerelease) (SUSE Linux)"
.section .note.GNU-stack,"",@progbits
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31679