[gnu.gcc.bug] GCC 1.31 - i386 optimization bug

kayvan@APPLE.COM (Kayvan Sylvan) (12/01/88)

I just brought up GNU Emacs 18.52 on my Altos 1000 386 System V.3
box using GCC 1.31. (Hooray!!!)

The only problem I had was in compiling search.c.

I was using the optimizer thus:

% gcc -O -Demacs -c search.c
Assembler: search.c
	aline 1358	: syntax error
	aline 1840	: syntax error

The same line without the -O flag works. (I ended up with un-optimized
search.o linked with the rest of the code optimized).

Here's the output from `gcc -v -S -Demacs search.c':

% gcc -v -S -O -Demacs search.c
gcc version 1.31
 /usr/local/lib/gcc-cpp -v -Demacs -undef -D__GNU__ -D__GNUC__ -Dunix -Di386 -D__OPTIMIZE__ search.c /tmp/cca03030.cpp
GNU CPP version 1.31
 /usr/local/lib/gcc-cc1 /tmp/cca03030.cpp -quiet -dumpbase search.c -O -version -o search.s
GNU C version 1.31 (80386, ATT syntax) compiled by GNU C version 1.31.

Looking in search.s I find the two offending lines are imull with
the wrong number of args:

------------------------ first mistake ---------------------------------
	negl %eax
	imull -8(%ebp),%eax,%eax  /* Line 1358 - imull with 3 args */
	jmp .L154
.L211:
	movl Qnil,%ecx
------------------------ second mistake ---------------------------------
	movl -8(%ebp),%eax
	negl %eax
	imull -76(%ebp),%eax,%eax /* Line 1840 - imull with 3 args */
.L154:
	leal -92(%ebp),%esp
	popl %edi
-------------------------- That's all folks -----------------------------

I can send the whole of search.s to whoever wants to investigate this
problem.

			---Kayvan

james@bigtex.cactus.org (James Van Artsdalen) (12/02/88)

In <8811301842.AA03049@satyr.UUCP>, satyr!kayvan@apple.com wrote:

> Looking in search.s I find the two offending lines are imull with
> the wrong number of args:

No, there is a three-operand version of imul.

> 	imull -8(%ebp),%eax,%eax  /* Line 1358 - imull with 3 args */

The first operand must be a constant, not some general addressing mode
as gcc feels.  A little experimentation shows that the third operand
must be a register.

A temporary fix is to simply delete the mulsi3 entry in i386.md
altogether.
-- 
James R. Van Artsdalen      james@bigtex.cactus.org      "Live Free or Die"
Home: 512-346-2444 Work: 338-8789       9505 Arboretum Blvd Austin TX 78759