ip2k.c issues

Zack Weinberg zack@codesourcery.com
Thu Jul 25 18:33:00 GMT 2002


The ip2k target is currently unbuildable due to one function in
ip2k.c, ip2k_set_compare.  It contains this code:

 /* If we're doing a DImode compare then force any CONST_INT second
    operand to be CONST_DOUBLE.  */
 if (GET_MODE (x) == DImode && GET_CODE (y) == CONST_INT)
   {
     rtx value;
     
     value = rtx_alloc (CONST_DOUBLE);
     PUT_MODE (value, VOIDmode);

     CONST_DOUBLE_LOW (value) = INTVAL (y);
     CONST_DOUBLE_HIGH (value) = INTVAL (y) > 0 ? 0 : -1;

     for (i = 2; i < (sizeof CONST_DOUBLE_FORMAT - 1); i++)
	XWINT (value, i) = 0;
     
     y = lookup_const_double (value);
   }

This does not work for two reasons: (1) the variable i is not declared
anywhere; (b) lookup_const_double is private to emit-rtl.c.  The
latter is deliberate - CONST_DOUBLE is to be treated as an opaque
quantity.

The obvious change - replace the conditional block with

 if (GET_MODE (x) == DImode && GET_CODE (y) == CONST_INT)
   y = immed_double_const (VOIDmode, INTVAL (y),
                           INTVAL (y) > 0 ? 0 : -1);

does not work, because immed_double_const refuses to generate a
CONST_DOUBLE for any value that fits in a CONST_INT; it will be an
expensive no-op.  There is, in fact, no way at all to generate an
integer CONST_DOUBLE for values in the range of a signed SImode
quantity.  I assume this is why the ip2k maintainer tried to use
private emit-rtl.c routines.  (Why code that does not even compile got
checked in, is another question.)

I suspect that the appended patch needs to be applied, and that then
ip2k.* must be corrected to cope with a DImode compare with a
CONST_INT second operand.

zw

	* ip2k.c (ip2k_set_compare): Do not attempt to create
	CONST_DOUBLEs.

===================================================================
Index: ip2k.c
--- ip2k.c	30 Jun 2002 19:27:48 -0000	1.1
+++ ip2k.c	26 Jul 2002 00:27:37 -0000
@@ -1085,24 +1085,6 @@ ip2k_set_compare (x, y)
      rtx x;
      rtx y;
 {
-  /* If we're doing a DImode compare then force any CONST_INT second
-     operand to be CONST_DOUBLE.  */
-  if (GET_MODE (x) == DImode && GET_CODE (y) == CONST_INT)
-    {
-      rtx value;
-      
-      value = rtx_alloc (CONST_DOUBLE);
-      PUT_MODE (value, VOIDmode);
-
-      CONST_DOUBLE_LOW (value) = INTVAL (y);
-      CONST_DOUBLE_HIGH (value) = INTVAL (y) > 0 ? 0 : -1;
-
-      for (i = 2; i < (sizeof CONST_DOUBLE_FORMAT - 1); i++)
-	XWINT (value, i) = 0;
-      
-      y = lookup_const_double (value);
-    }
-  
   ip2k_compare_operands[0] = x;
   ip2k_compare_operands[1] = y;
   return "";



More information about the Gcc-bugs mailing list