m68k.c fix

Stephen L Moshier moshier@mediaone.net
Mon Mar 5 16:34:00 GMT 2001


For an m68k default target (e.g. 68020) this test case

int f (unsigned int x)
{
  return x/10;
}

aborts here --

gdb cc1
run tst.c
Breakpoint 2, fancy_abort (file=0x8239a69 "insn-emit.c", line=3103,
    function=0x8239a54 "gen_umulsi3_highpart")
    at ../ccdir/gcc/diagnostic.c:1767
1767      internal_error ("Internal compiler error in %s, at %s:%d",


The reason is that const_uint32_operand incorrectly rejects the coefficient
0xcccccccd because it appears to be negative on a 32-bit host computer.
On a 32-bit host it should accept any 32-bit const int as a legitimate
unsigned quantity.

This patch fixes the above and probably also GNATS #1795 and #2058.

  * config/m68k.c (const_uint32_operand): Accept negative const int on
    32-bit host.

*** m68k.c      2000/06/06 16:21:41     1.1
--- m68k.c      2001/03/03 14:36:59
*************** const_uint32_operand (op, mode)
*** 3332,3338 ****
    return (GET_CODE (op) == CONST_INT
          && (INTVAL (op) >= 0 && INTVAL (op) <= 0xffffffffL));
  #else
!   return ((GET_CODE (op) == CONST_INT && INTVAL (op) >= 0)
          || (GET_CODE (op) == CONST_DOUBLE && CONST_DOUBLE_HIGH (op) == 0));
  #endif
  }
--- 3332,3338 ----
    return (GET_CODE (op) == CONST_INT
          && (INTVAL (op) >= 0 && INTVAL (op) <= 0xffffffffL));
  #else
!   return (GET_CODE (op) == CONST_INT
          || (GET_CODE (op) == CONST_DOUBLE && CONST_DOUBLE_HIGH (op) == 0));
  #endif
  }





More information about the Gcc-patches mailing list