Inappropriate multiply-to-shift conversion in x86
Matt Hiller
hiller@redhat.com
Fri Apr 27 16:16:00 GMT 2001
This is very much a corner-case, of course, but it can't hurt to
mention it...
With a gcc checked out earlier this afternoon, the following testcase:
#include <limits.h>
long
multiply_me (long a)
{
return a * LONG_MIN;
}
compiles at -O0 to this (minus some impertinent detail):
multiply_me:
pushl %ebp
movl %esp, %ebp
movl 8(%ebp), %eax
sall $31, %eax <--------
popl %ebp
ret
I came up with a quick-hack of a patch to expmed.c (expand_mult)
that stops the shift from being created during rtl generation. Then I
reran at -O1 only to see that cse replaces the multiply with an
inappropriate shift too.
Matt
More information about the Gcc-bugs
mailing list