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]

Simplify FP conversions


Hi,
this patch fixes two problems in nullstone.
I am not 100% sure about the first conversion.  Is overflow in float_truncate
defined differently from overflow in float?

Honza

/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
/* { dg-options "-O2 -march=k8 -mfpmath=sse" } */
/* { dg-final { scan-assembler "cvtsi2sd" } } */
/* Check that conversions will get folded.  */
double
main(short a)
{
  float b=a;
  return b;
}

Sun Feb  9 18:29:27 CET 2003  Jan Hubicka  <jh@suse.cz>
	* combine.c (combine_simplify_rtx): Simplify using
	(float_truncate (float x)) is (float x)
	(float_extend (float_extend x)) is (float_extend x).
Index: combine.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/combine.c,v
retrieving revision 1.337
diff -c -3 -p -r1.337 combine.c
*** combine.c	6 Feb 2003 19:26:42 -0000	1.337
--- combine.c	9 Feb 2003 17:26:05 -0000
*************** combine_simplify_rtx (x, op0_mode, last,
*** 4167,4172 ****
--- 4167,4180 ----
  	  && GET_MODE (XEXP (XEXP (x, 0), 0)) == mode)
  	return XEXP (XEXP (x, 0), 0);
  
+       /*  (float_truncate (float x)) is (float x)  */
+       if (GET_CODE (XEXP (x, 0)) == FLOAT)
+ 	return simplify_gen_unary (FLOAT, mode,
+ 				   XEXP (XEXP (x, 0), 0),
+ 				   GET_MODE (XEXP (XEXP (x, 0), 0)));
+ 
+       break;
+ 
        /* (float_truncate:SF (OP:DF (float_extend:DF foo:sf))) is
  	 (OP:SF foo:SF) if OP is NEG or ABS.  */
        if ((GET_CODE (XEXP (x, 0)) == ABS
*************** combine_simplify_rtx (x, op0_mode, last,
*** 4183,4189 ****
--- 4191,4205 ----
  	  && GET_CODE (SUBREG_REG (XEXP (x, 0))) == FLOAT_TRUNCATE)
  	return SUBREG_REG (XEXP (x, 0));
        break;
+     case FLOAT_EXTEND:
+       /*  (float_extend (float_extend x)) is (float_extend x)  */
+       if (GET_CODE (XEXP (x, 0)) == FLOAT_EXTEND
+ 	  || GET_CODE (XEXP (x, 0)) == FLOAT)
+ 	return simplify_gen_unary (GET_CODE (XEXP (x, 0)), mode,
+ 				   XEXP (XEXP (x, 0), 0),
+ 				   GET_MODE (XEXP (XEXP (x, 0), 0)));
  
+       break;
  #ifdef HAVE_cc0
      case COMPARE:
        /* Convert (compare FOO (const_int 0)) to FOO unless we aren't


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