Patchwork Fix errno math builtins WRT -Os

login
register
mail settings
Submitter Jan Hubicka
Date Nov. 17, 2010, 6:20 p.m.
Message ID <20101117182016.GE4514@kam.mff.cuni.cz>
Download mbox | patch
Permalink /patch/71609/
State New
Headers show

Comments

Jan Hubicka - Nov. 17, 2010, 6:20 p.m.
Hi,
another minor CSiBE regression comes from fact that we no longer expand
sqrt(var) as sqrtss by default. Instead we do
 res = sqrt(var)
 if (res == NaN)
   fsqrt (var)
this is to set errno.  This is always a loss when optimizing for size.
Fixed thus.

Regtested/bootstrapped x86_64-linux, will commit it later today.

Honza

	* builtins.c (expand_builtin_mathfn, expand_builtin_mathfn_2):
	When optimizing for size, do not expand variants with errno
	set.

Patch

Index: builtins.c
===================================================================
--- builtins.c	(revision 166864)
+++ builtins.c	(working copy)
@@ -2039,7 +2039,8 @@  expand_builtin_mathfn (tree exp, rtx tar
     errno_set = false;
 
   /* Before working hard, check whether the instruction is available.  */
-  if (optab_handler (builtin_optab, mode) != CODE_FOR_nothing)
+  if (optab_handler (builtin_optab, mode) != CODE_FOR_nothing
+      && (!errno_set || !optimize_insn_for_size_p ()))
     {
       target = gen_reg_rtx (mode);
 
@@ -2149,6 +2150,9 @@  expand_builtin_mathfn_2 (tree exp, rtx t
   if (! flag_errno_math || ! HONOR_NANS (mode))
     errno_set = false;
 
+  if (errno_set && optimize_insn_for_size_p ())
+    return 0;
+
   /* Always stabilize the argument list.  */
   CALL_EXPR_ARG (exp, 0) = arg0 = builtin_save_expr (arg0);
   CALL_EXPR_ARG (exp, 1) = arg1 = builtin_save_expr (arg1);