[gnu.gcc.bug] GCC 1.31 produces an illegal instruction on Sun386i

exodus@mfgfoc.uucp (Greg Onufer) (12/01/88)

When compiling X11R2 on a Sun 386i, I encountered this problem:
[[ Sun 386i, SunOS 4.0, Gcc 1.31, Used config.gcc to set up the
   links for a sun386i, Standard X11R2 core distributionm
   gcc flags: -traditional -O -g -c -I.... AsciiSink.c ]]

Compiling the file ./lib/Xaw/AsciiSink.c produces a line
	  imull  12(%ebp),%eax,%eax
which the Sun assembler aborts on.  This only occurs when
optimization is turned on.  The '-g' flag doesn't affect the
error, but it does, of course, change the line in the assembly
file on which the error occurs. 

-greg
-- 
Greg Onufer   //  Focus Semiconductor  //     University of the Pacific
  exodus@cheers.uucp (daver!cheers!exodus@Sun.COM) 	415-965-0604

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

In <491@mfgfoc.uucp>, exodus@mfgfoc.uucp (Greg Onufer) wrote:

> 	  imull  12(%ebp),%eax,%eax

This has come up many times.  I think the register constraints are OK,
but the C output part is not.  Basically, the 386 has a general two
operand multiply, or a three operand if the destination is a register
and one of the sources is an immediate value and the other either a
register or memory.

Struggling through the Internals document leads me to suspect that
perhaps using "which_alternative" is a better way for this insn to
work.  This change ought to make gcc use the simpler method of
determining which imul form to output instead of trying to figure it
out by looking at operand 2.

This change isn't really tested yet (lack of good test cases), and I
don't understand .md files yet, so reader beware.  Please send/post
corrections!

*** /tmp/,RCSt1a08236	Sun Dec  4 23:41:17 1988
--- i386.md	Sun Dec  4 23:31:58 1988
***************
*** 896,903 ****
  {
!   if (rtx_equal_p (operands[0], operands[1])
!       && (GET_CODE (operands[2]) == MEM
! 	  || GET_CODE (operands[2]) == REG))
!     /* Assembler has weird restrictions.  */
      return AS2 (imul%L,%2,%0);
!   return AS3 (imul%L,%2,%1,%0);
  }")
--- 896,901 ----
  {
!   if (which_alternative == 0)
      return AS2 (imul%L,%2,%0);
!   else
!     return AS3 (imul%L,%2,%1,%0);
  }")
-- 
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