This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Inappropriate multiply-to-shift conversion in x86


	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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]