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]

[PATCH] do not lower a/b to a*(1/b)


This patch removes the hunk of expr.c that tries to lower a/b to a*(1/b) in the hope of CSEing the reciprocal and save a divide. This optimization is now part of loop-invariant motion thanks to a patch by David Edelsohn.

Bootstrapped/regtested powerpc-apple-darwin, ok for mainline?

Paolo
2005-05-13  Paolo Bonzini  <bonzini@gnu.org>

	* expr.c (expand_expr_real_1) <case RDIV_EXPR>: Never emit as a*(1/b).

Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expr.c,v
retrieving revision 1.789
diff -p -u -u -r1.789 expr.c
--- expr.c	3 May 2005 22:21:48 -0000	1.789
+++ expr.c	13 May 2005 08:26:25 -0000
@@ -7806,18 +7806,6 @@ expand_expr_real_1 (tree exp, rtx target
       return expand_divmod (0, code, mode, op0, op1, target, unsignedp);
 
     case RDIV_EXPR:
-      /* Emit a/b as a*(1/b).  Later we may manage CSE the reciprocal saving
-         expensive divide.  If not, combine will rebuild the original
-         computation.  */
-      if (flag_unsafe_math_optimizations && optimize && !optimize_size
-	  && TREE_CODE (type) == REAL_TYPE
-	  && !real_onep (TREE_OPERAND (exp, 0)))
-        return expand_expr (build2 (MULT_EXPR, type, TREE_OPERAND (exp, 0),
-				    build2 (RDIV_EXPR, type,
-					    build_real (type, dconst1),
-					    TREE_OPERAND (exp, 1))),
-			    target, tmode, modifier);
-
       goto binop;
 
     case TRUNC_MOD_EXPR:

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