This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

Re: [ip2k port] bugfix


Denis Chertykov <denisc@overta.ru> writes:

> Zack Weinberg <zack@codesourcery.com> writes:
> 
> > On Mon, Aug 26, 2002 at 10:07:39PM +0400, Denis Chertykov wrote:
> > > Zack Weinberg <zack@codesourcery.com> writes:
> > > > ip2k_set_compare is still constructing its own CONST_DOUBLEs, which is
> > > > verboten.  CONST_DOUBLEs are opaque entities and may be manipulated
> > > > *only* by the interfaces exposed in real.h and rtl.h.
> > > 
> > > Will be fixed.
> > 
> > Thanks.
> > 
> > I imagine it is as simple as changing the body of ip2k_set_compare to
> > 
> > {
> >   ip2k_compare_operands[0] = x;
> >   ip2k_compare_operands[1] = y;
> >   return "";
> > }
> > 
> > and then finding out what breaks, and fixing it.
> > 
> > > > Looking at the function, it appears to be forcing the creation of
> > > > non-canonical RTL, which is also a no-no.  What are you actually
> > > > trying to achieve here?
> > > 
> > > It was not me :-(
> > 
> > You will probably find it easier to locate the real problem and fix
> > it, though.  (It should be a case of some code somewhere expecting
> > DImode compares against an immediate value to come with a CONST_DOUBLE
> > second operand, even if the sign-extended quantity fits in a
> > CONST_INT.)
> 
> Thanks for suggestion. I just havn't time to fix this bug right now.

I found the time.

2002-08-30  Denis Chertykov  <denisc@overta.ru>

	* config/ip2k/ip2k.c (ip2k_set_compare): Remove all CONST_DOUBLE
	stuff.
	(ip2k_gen_unsigned_comp_branch): Handle CONST_INT and
	CONST_DOUBLE constants.
	
diff -c -3 -p -r1.5 ip2k.c
*** ip2k.c	13 Aug 2002 09:58:37 -0000	1.5
--- ip2k.c	30 Aug 2002 18:10:47 -0000
*************** ip2k_set_compare (x, y)
*** 1075,1099 ****
       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;
-       size_t i;
- 
-       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 = value;
-     }
-   
    ip2k_compare_operands[0] = x;
    ip2k_compare_operands[1] = y;
    return "";
--- 1075,1080 ----
*************** ip2k_gen_unsigned_comp_branch (insn, cod
*** 1675,1680 ****
--- 1656,1663 ----
    int imm_cmp = 0;
    int can_use_skip = 0;
    rtx ninsn;
+   HOST_WIDE_INT const_low;
+   HOST_WIDE_INT const_high;
  
    operands[2] = label;
  
*************** ip2k_gen_unsigned_comp_branch (insn, cod
*** 2332,2341 ****
  	    {
  	      if (INTVAL (operands[0]) == 0)
  		{
!                   OUT_AS2 (mov, w, %A0);
!                   OUT_AS2 (or, w, %B0);
!                   OUT_AS2 (or, w, %C0);
!                   OUT_AS2 (or, w, %D0);
  		  OUT_AS1 (snz,);
  	          OUT_AS1 (page, %2);
  	          OUT_AS1 (jmp, %2);
--- 2315,2324 ----
  	    {
  	      if (INTVAL (operands[0]) == 0)
  		{
!                   OUT_AS2 (mov, w, %A1);
!                   OUT_AS2 (or, w, %B1);
!                   OUT_AS2 (or, w, %C1);
!                   OUT_AS2 (or, w, %D1);
  		  OUT_AS1 (snz,);
  	          OUT_AS1 (page, %2);
  	          OUT_AS1 (jmp, %2);
*************** ip2k_gen_unsigned_comp_branch (insn, cod
*** 2377,2386 ****
  	    {
  	      if (INTVAL (operands[0]) == 0)
  	        {
!                   OUT_AS2 (mov, w, %A0);
!                   OUT_AS2 (or, w, %B0);
!                   OUT_AS2 (or, w, %C0);
!                   OUT_AS2 (or, w, %D0);
  		  OUT_AS1 (sz,);
  	          OUT_AS1 (page, %2);
  	          OUT_AS1 (jmp, %2);
--- 2360,2369 ----
  	    {
  	      if (INTVAL (operands[0]) == 0)
  	        {
!                   OUT_AS2 (mov, w, %A1);
!                   OUT_AS2 (or, w, %B1);
!                   OUT_AS2 (or, w, %C1);
!                   OUT_AS2 (or, w, %D1);
  		  OUT_AS1 (sz,);
  	          OUT_AS1 (page, %2);
  	          OUT_AS1 (jmp, %2);
*************** ip2k_gen_unsigned_comp_branch (insn, cod
*** 2465,2470 ****
--- 2448,2463 ----
        break;
  
      case DImode:
+       if (GET_CODE (operands[1]) == CONST_INT)
+ 	{
+ 	  const_low = INTVAL (operands[1]);
+ 	  const_high = (const_low >= 0) - 1;
+ 	}
+       else if (GET_CODE (operands[1]) == CONST_DOUBLE)
+ 	{
+ 	  const_low = CONST_DOUBLE_LOW (operands[1]);
+ 	  const_high = CONST_DOUBLE_HIGH (operands[1]);
+ 	}
        switch (code)
          {
  	case EQ:
*************** ip2k_gen_unsigned_comp_branch (insn, cod
*** 2519,2532 ****
  	      {
  		if (imm_cmp)
  		  {
! 		    s = (CONST_DOUBLE_HIGH (operands[1]) >> 24) & 0xff;
! 		    t = (CONST_DOUBLE_HIGH (operands[1]) >> 16) & 0xff;
! 		    u = (CONST_DOUBLE_HIGH (operands[1]) >> 8) & 0xff;
! 		    v = CONST_DOUBLE_HIGH (operands[1]) & 0xff;
! 		    w = (CONST_DOUBLE_LOW (operands[1]) >> 24) & 0xff;
! 		    x = (CONST_DOUBLE_LOW (operands[1]) >> 16) & 0xff;
! 		    y = (CONST_DOUBLE_LOW (operands[1]) >> 8) & 0xff;
! 		    z = CONST_DOUBLE_LOW (operands[1]) & 0xff;
  		  }
  
  		OUT_AS2 (mov, w, %S1);
--- 2512,2525 ----
  	      {
  		if (imm_cmp)
  		  {
! 		    s = (const_high >> 24) & 0xff;
! 		    t = (const_high >> 16) & 0xff;
! 		    u = (const_high >> 8) & 0xff;
! 		    v = const_high & 0xff;
! 		    w = (const_low >> 24) & 0xff;
! 		    x = (const_low >> 16) & 0xff;
! 		    y = (const_low >> 8) & 0xff;
! 		    z = const_low & 0xff;
  		  }
  
  		OUT_AS2 (mov, w, %S1);
*************** ip2k_gen_unsigned_comp_branch (insn, cod
*** 2648,2661 ****
  	      {
  		if (imm_cmp)
  		  {
! 		    s = (CONST_DOUBLE_HIGH (operands[1]) >> 24) & 0xff;
! 		    t = (CONST_DOUBLE_HIGH (operands[1]) >> 16) & 0xff;
! 		    u = (CONST_DOUBLE_HIGH (operands[1]) >> 8) & 0xff;
! 		    v = CONST_DOUBLE_HIGH (operands[1]) & 0xff;
! 		    w = (CONST_DOUBLE_LOW (operands[1]) >> 24) & 0xff;
! 		    x = (CONST_DOUBLE_LOW (operands[1]) >> 16) & 0xff;
! 		    y = (CONST_DOUBLE_LOW (operands[1]) >> 8) & 0xff;
! 		    z = CONST_DOUBLE_LOW (operands[1]) & 0xff;
  		  }
  
  		OUT_AS2 (mov, w, %S1);
--- 2641,2654 ----
  	      {
  		if (imm_cmp)
  		  {
! 		    s = (const_high >> 24) & 0xff;
! 		    t = (const_high >> 16) & 0xff;
! 		    u = (const_high >> 8) & 0xff;
! 		    v = const_high & 0xff;
! 		    w = (const_low >> 24) & 0xff;
! 		    x = (const_low >> 16) & 0xff;
! 		    y = (const_low >> 8) & 0xff;
! 		    z = const_low & 0xff;
  		  }
  
  		OUT_AS2 (mov, w, %S1);
*************** ip2k_gen_unsigned_comp_branch (insn, cod
*** 2734,2746 ****
  	  if (imm_sub)
  	    {
  	      /* > 0xffffffffffffffff never suceeds!  */
! 	      if (((CONST_DOUBLE_HIGH (operands[1]) & 0xffffffff)
! 		   != 0xffffffff)
! 		  || ((CONST_DOUBLE_LOW (operands[1]) & 0xffffffff)
! 		      != 0xffffffff))
  		{
! 	          operands[3] = GEN_INT (CONST_DOUBLE_LOW (operands[1]) + 1);
! 		  operands[4] = GEN_INT (CONST_DOUBLE_HIGH (operands[1])
  					 + (INTVAL (operands[3]) ? 0 : 1));
  	          OUT_AS2 (mov, w, %D3);
  	          OUT_AS2 (sub, w, %Z0);
--- 2727,2737 ----
  	  if (imm_sub)
  	    {
  	      /* > 0xffffffffffffffff never suceeds!  */
! 	      if (((const_high & 0xffffffff) != 0xffffffff)
! 		  || ((const_low & 0xffffffff) != 0xffffffff))
  		{
! 	          operands[3] = GEN_INT (const_low + 1);
! 		  operands[4] = GEN_INT (const_high
  					 + (INTVAL (operands[3]) ? 0 : 1));
  	          OUT_AS2 (mov, w, %D3);
  	          OUT_AS2 (sub, w, %Z0);
*************** ip2k_gen_unsigned_comp_branch (insn, cod
*** 2790,2816 ****
  	case GEU:
  	  if (imm_sub)
  	    {
! 	      if ((CONST_DOUBLE_HIGH (operands[0]) == 0)
! 		  && (CONST_DOUBLE_LOW (operands[0]) == 0))
  		{
!                   OUT_AS2 (mov, w, %S0);
!                   OUT_AS2 (or, w, %T0);
!                   OUT_AS2 (or, w, %U0);
!                   OUT_AS2 (or, w, %V0);
!                   OUT_AS2 (or, w, %W0);
!                   OUT_AS2 (or, w, %X0);
!                   OUT_AS2 (or, w, %Y0);
!                   OUT_AS2 (or, w, %Z0);
  		  OUT_AS1 (snz,);
  	          OUT_AS1 (page, %2);
  	          OUT_AS1 (jmp, %2);
  		}
  	      else
  	        {
! 	          operands[3] = GEN_INT (CONST_DOUBLE_LOW (operands[0]) - 1);
! 		  operands[4] = GEN_INT (CONST_DOUBLE_HIGH (operands[0])
! 					 - (CONST_DOUBLE_LOW (operands[0])
! 					    ? 1 : 0));
  	          OUT_AS2 (mov, w, %D3);
  	          OUT_AS2 (sub, w, %Z1);
  	          OUT_AS2 (mov, w, %C3);
--- 2781,2818 ----
  	case GEU:
  	  if (imm_sub)
  	    {
! 	      HOST_WIDE_INT const_low0;
! 	      HOST_WIDE_INT const_high0;
! 	      
! 	      if (GET_CODE (operands[0]) == CONST_INT)
! 		{
! 		  const_low0 = INTVAL (operands[0]);
! 		  const_high0 = (const_low >= 0) - 1;
! 		}
! 	      else if (GET_CODE (operands[0]) == CONST_DOUBLE)
! 		{
! 		  const_low0 = CONST_DOUBLE_LOW (operands[0]);
! 		  const_high0 = CONST_DOUBLE_HIGH (operands[0]);
! 		}
! 	      
! 	      if (const_high0 == 0 && const_low0 == 0)
  		{
!                   OUT_AS2 (mov, w, %S1);
!                   OUT_AS2 (or, w, %T1);
!                   OUT_AS2 (or, w, %U1);
!                   OUT_AS2 (or, w, %V1);
!                   OUT_AS2 (or, w, %W1);
!                   OUT_AS2 (or, w, %X1);
!                   OUT_AS2 (or, w, %Y1);
!                   OUT_AS2 (or, w, %Z1);
  		  OUT_AS1 (snz,);
  	          OUT_AS1 (page, %2);
  	          OUT_AS1 (jmp, %2);
  		}
  	      else
  	        {
! 	          operands[3] = GEN_INT (const_low0 - 1);
! 		  operands[4] = GEN_INT (const_high0 - (const_low0 ? 1 : 0));
  	          OUT_AS2 (mov, w, %D3);
  	          OUT_AS2 (sub, w, %Z1);
  	          OUT_AS2 (mov, w, %C3);
*************** ip2k_gen_unsigned_comp_branch (insn, cod
*** 2859,2885 ****
  	case LTU:
  	  if (imm_sub)
  	    {
! 	      if ((CONST_DOUBLE_HIGH (operands[0]) == 0)
! 		  && (CONST_DOUBLE_LOW (operands[0]) == 0))
  		{
!                   OUT_AS2 (mov, w, %S0);
!                   OUT_AS2 (or, w, %T0);
!                   OUT_AS2 (or, w, %U0);
!                   OUT_AS2 (or, w, %V0);
!                   OUT_AS2 (or, w, %W0);
!                   OUT_AS2 (or, w, %X0);
!                   OUT_AS2 (or, w, %Y0);
!                   OUT_AS2 (or, w, %Z0);
  		  OUT_AS1 (sz,);
  	          OUT_AS1 (page, %2);
  	          OUT_AS1 (jmp, %2);
  		}
  	      else
  	        {
! 	          operands[3] = GEN_INT (CONST_DOUBLE_LOW (operands[0]) - 1);
! 		  operands[4] = GEN_INT (CONST_DOUBLE_HIGH (operands[0])
! 					 - (CONST_DOUBLE_LOW (operands[0])
! 					    ? 1 : 0));
  	          OUT_AS2 (mov, w, %D3);
  	          OUT_AS2 (sub, w, %Z1);
  	          OUT_AS2 (mov, w, %C3);
--- 2861,2898 ----
  	case LTU:
  	  if (imm_sub)
  	    {
! 	      HOST_WIDE_INT const_low0;
! 	      HOST_WIDE_INT const_high0;
! 	      
! 	      if (GET_CODE (operands[0]) == CONST_INT)
! 		{
! 		  const_low0 = INTVAL (operands[0]);
! 		  const_high0 = (const_low >= 0) - 1;
! 		}
! 	      else if (GET_CODE (operands[0]) == CONST_DOUBLE)
! 		{
! 		  const_low0 = CONST_DOUBLE_LOW (operands[0]);
! 		  const_high0 = CONST_DOUBLE_HIGH (operands[0]);
! 		}
! 	      
! 	      if (const_high0 == 0 && const_low0 == 0)
  		{
!                   OUT_AS2 (mov, w, %S1);
!                   OUT_AS2 (or, w, %T1);
!                   OUT_AS2 (or, w, %U1);
!                   OUT_AS2 (or, w, %V1);
!                   OUT_AS2 (or, w, %W1);
!                   OUT_AS2 (or, w, %X1);
!                   OUT_AS2 (or, w, %Y1);
!                   OUT_AS2 (or, w, %Z1);
  		  OUT_AS1 (sz,);
  	          OUT_AS1 (page, %2);
  	          OUT_AS1 (jmp, %2);
  		}
  	      else
  	        {
! 	          operands[3] = GEN_INT (const_low0 - 1);
! 		  operands[4] = GEN_INT (const_high0 - (const_low0 ? 1 : 0));
  	          OUT_AS2 (mov, w, %D3);
  	          OUT_AS2 (sub, w, %Z1);
  	          OUT_AS2 (mov, w, %C3);
*************** ip2k_gen_unsigned_comp_branch (insn, cod
*** 2928,2937 ****
  	case LEU:
  	  if (imm_sub)
  	    {
! 	      if (((CONST_DOUBLE_HIGH (operands[1]) & 0xffffffff)
! 		   == 0xffffffff)
! 		  && ((CONST_DOUBLE_LOW (operands[1]) & 0xffffffff)
! 		      == 0xffffffff))
  	        {
  		  /* <= 0xffffffffffffffff always suceeds.  */
  		  OUT_AS1 (page, %2);
--- 2941,2948 ----
  	case LEU:
  	  if (imm_sub)
  	    {
! 	      if (((const_high & 0xffffffff) == 0xffffffff)
! 		  && ((const_low & 0xffffffff) == 0xffffffff))
  	        {
  		  /* <= 0xffffffffffffffff always suceeds.  */
  		  OUT_AS1 (page, %2);
*************** ip2k_gen_unsigned_comp_branch (insn, cod
*** 2939,2946 ****
  		}
  	      else
  		{
! 	          operands[3] = GEN_INT (CONST_DOUBLE_LOW (operands[1]) + 1);
! 		  operands[4] = GEN_INT (CONST_DOUBLE_HIGH (operands[1])
  					 + (INTVAL (operands[3]) ? 0 : 1));
  	          OUT_AS2 (mov, w, %D3);
  	          OUT_AS2 (sub, w, %Z0);
--- 2950,2957 ----
  		}
  	      else
  		{
! 	          operands[3] = GEN_INT (const_low + 1);
! 		  operands[4] = GEN_INT (const_high
  					 + (INTVAL (operands[3]) ? 0 : 1));
  	          OUT_AS2 (mov, w, %D3);
  	          OUT_AS2 (sub, w, %Z0);


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