For the following code given in [1] GCC produces identical multiplication by
constant code [2]. I believe the fault is with the simplification of a 64bit
multiply by 0x1FFFFFFFF (ie low word == -1 and high word == 1) where the
effect will be a multiply by 0x0FFFFFFFF.

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

-- 
View this message in context: 
http://www.nabble.com/Simplification-of-64bit-multiply-by-constant-looks-wrong-on-IA32-tf3753278.html#a10606700
Sent from the gcc - bugs mailing list archive at Nabble.com.

Reply via email to