This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Inappropriate multiply-to-shift conversion in x86
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Inappropriate multiply-to-shift conversion in x86
- From: Matt Hiller <hiller at redhat dot com>
- Date: Fri, 27 Apr 2001 16:16:19 -0700 (PDT)
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