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]

Allow folding of floats on logicals


Hi,
this patch should make simplify-rtx to cope correctly with logicals on floats
we use now by i386 backend with my proposed SSE fix.

Bootstrapped/regtested i686, does it look OK?
Honza

2004-02-16  Jan Hubicka  <jh@suse.cz>
	* simplify-rtx.c (simplify_unary_operation): Deal with logicals on
	floats.
	(simplify_binary_operation): Deal with logicals on floats.
Index: simplify-rtx.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/simplify-rtx.c,v
retrieving revision 1.176
diff -c -3 -p -r1.176 simplify-rtx.c
*** simplify-rtx.c	24 Jan 2004 11:01:25 -0000	1.176
--- simplify-rtx.c	15 Feb 2004 17:41:16 -0000
*************** simplify_unary_operation (enum rtx_code 
*** 446,462 ****
    if (code == FLOAT && GET_MODE (trueop) == VOIDmode
        && (GET_CODE (trueop) == CONST_DOUBLE || GET_CODE (trueop) == CONST_INT))
      {
!       HOST_WIDE_INT hv, lv;
!       REAL_VALUE_TYPE d;
! 
!       if (GET_CODE (trueop) == CONST_INT)
! 	lv = INTVAL (trueop), hv = HWI_SIGN_EXTEND (lv);
        else
! 	lv = CONST_DOUBLE_LOW (trueop),  hv = CONST_DOUBLE_HIGH (trueop);
  
!       REAL_VALUE_FROM_INT (d, lv, hv, mode);
!       d = real_value_truncate (mode, d);
!       return CONST_DOUBLE_FROM_REAL_VALUE (d, mode);
      }
    else if (code == UNSIGNED_FLOAT && GET_MODE (trueop) == VOIDmode
  	   && (GET_CODE (trueop) == CONST_DOUBLE
--- 446,483 ----
    if (code == FLOAT && GET_MODE (trueop) == VOIDmode
        && (GET_CODE (trueop) == CONST_DOUBLE || GET_CODE (trueop) == CONST_INT))
      {
!       if (code == NOT)
! 	{
! 	  long tmp[4];
! 	  REAL_VALUE_TYPE r;
! 	  int i;
! 
! 	  real_to_target (tmp, CONST_DOUBLE_REAL_VALUE (trueop),
! 			  GET_MODE (trueop));
! 	  for (i = 0; i < 4; i++)
! 	    {
! 	      if (code == NOT)
! 		tmp[i] = ~tmp[i];
! 	      else
! 		abort ();
! 	    }
! 	   real_from_target (&r, tmp, mode);
! 	   return CONST_DOUBLE_FROM_REAL_VALUE (r, mode);
! 	}
        else
! 	{
! 	  HOST_WIDE_INT hv, lv;
! 	  REAL_VALUE_TYPE d;
  
! 	  if (GET_CODE (trueop) == CONST_INT)
! 	    lv = INTVAL (trueop), hv = HWI_SIGN_EXTEND (lv);
! 	  else
! 	    lv = CONST_DOUBLE_LOW (trueop),  hv = CONST_DOUBLE_HIGH (trueop);
! 
! 	  REAL_VALUE_FROM_INT (d, lv, hv, mode);
! 	  d = real_value_truncate (mode, d);
! 	  return CONST_DOUBLE_FROM_REAL_VALUE (d, mode);
! 	}
      }
    else if (code == UNSIGNED_FLOAT && GET_MODE (trueop) == VOIDmode
  	   && (GET_CODE (trueop) == CONST_DOUBLE
*************** simplify_binary_operation (enum rtx_code
*** 1210,1235 ****
        && GET_CODE (trueop1) == CONST_DOUBLE
        && mode == GET_MODE (op0) && mode == GET_MODE (op1))
      {
!       REAL_VALUE_TYPE f0, f1, value;
  
!       REAL_VALUE_FROM_CONST_DOUBLE (f0, trueop0);
!       REAL_VALUE_FROM_CONST_DOUBLE (f1, trueop1);
!       f0 = real_value_truncate (mode, f0);
!       f1 = real_value_truncate (mode, f1);
! 
!       if (HONOR_SNANS (mode)
! 	  && (REAL_VALUE_ISNAN (f0) || REAL_VALUE_ISNAN (f1)))
! 	return 0;
! 
!       if (code == DIV
! 	  && REAL_VALUES_EQUAL (f1, dconst0)
! 	  && (flag_trapping_math || ! MODE_HAS_INFINITIES (mode)))
! 	return 0;
  
!       REAL_ARITHMETIC (value, rtx_to_tree_code (code), f0, f1);
  
!       value = real_value_truncate (mode, value);
!       return CONST_DOUBLE_FROM_REAL_VALUE (value, mode);
      }
  
    /* We can fold some multi-word operations.  */
--- 1231,1286 ----
        && GET_CODE (trueop1) == CONST_DOUBLE
        && mode == GET_MODE (op0) && mode == GET_MODE (op1))
      {
!       if (code == AND
! 	  || code == IOR
! 	  || code == XOR)
! 	{
! 	  long tmp0[4];
! 	  long tmp1[4];
! 	  REAL_VALUE_TYPE r;
! 	  int i;
! 
! 	  real_to_target (tmp0, CONST_DOUBLE_REAL_VALUE (op0),
! 			  GET_MODE (op0));
! 	  real_to_target (tmp1, CONST_DOUBLE_REAL_VALUE (op1),
! 			  GET_MODE (op1));
! 	  for (i = 0; i < 4; i++)
! 	    {
! 	      if (code == AND)
! 		tmp0[i] &= tmp1[i];
! 	      else if (code == IOR)
! 		tmp0[i] |= tmp1[i];
! 	      else if (code == XOR)
! 		tmp0[i] ^= tmp1[i];
! 	      else
! 		abort ();
! 	    }
! 	   real_from_target (&r, tmp0, mode);
! 	   return CONST_DOUBLE_FROM_REAL_VALUE (r, mode);
! 	}
!       else
! 	{
! 	  REAL_VALUE_TYPE f0, f1, value;
  
! 	  REAL_VALUE_FROM_CONST_DOUBLE (f0, trueop0);
! 	  REAL_VALUE_FROM_CONST_DOUBLE (f1, trueop1);
! 	  f0 = real_value_truncate (mode, f0);
! 	  f1 = real_value_truncate (mode, f1);
  
! 	  if (HONOR_SNANS (mode)
! 	      && (REAL_VALUE_ISNAN (f0) || REAL_VALUE_ISNAN (f1)))
! 	    return 0;
  
! 	  if (code == DIV
! 	      && REAL_VALUES_EQUAL (f1, dconst0)
! 	      && (flag_trapping_math || ! MODE_HAS_INFINITIES (mode)))
! 	    return 0;
! 
! 	  REAL_ARITHMETIC (value, rtx_to_tree_code (code), f0, f1);
! 
! 	  value = real_value_truncate (mode, value);
! 	  return CONST_DOUBLE_FROM_REAL_VALUE (value, mode);
! 	}
      }
  
    /* We can fold some multi-word operations.  */


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