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]

simplify multiplication by reciprocals to division


Hi,
this patch makes combine to simplify multiplication by reciprocals to
division.

Honza

Mon Jul 16 22:38:44 CEST 2001  Jan Hubicka  <jh@suse.cz>
	* combine.c (combine_simplify_rtx): Attempt to simplify
	a*(b/c) as (a*b)/c for floats in unsafe_math mode.

Index: combine.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/combine.c,v
retrieving revision 1.215
diff -c -3 -p -r1.215 combine.c
*** combine.c	2001/07/16 09:16:04	1.215
--- combine.c	2001/07/16 20:38:11
*************** combine_simplify_rtx (x, op0_mode, last,
*** 4231,4236 ****
--- 4233,4248 ----
  	  if (GET_CODE (x) != MULT)
  	    return x;
  	}
+       /* Try simplify a*(b/c) as (a*b)/c.  */
+       if (FLOAT_MODE_P (mode) && flag_unsafe_math_optimizations
+ 	  && GET_CODE (XEXP (x, 0)) == DIV)
+ 	{
+ 	  rtx tem = simplify_binary_operation (MULT, mode,
+ 					       XEXP (XEXP (x, 0), 0),
+ 					       XEXP (x, 1));
+ 	  if (tem)
+ 	    return gen_binary (DIV, mode, tem, XEXP (XEXP (x, 0), 1));
+ 	}
        break;
  
      case UDIV:


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