From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20205 invoked by alias); 19 Mar 2010 10:35:22 -0000 Received: (qmail 20135 invoked by uid 48); 19 Mar 2010 10:35:04 -0000 Date: Fri, 19 Mar 2010 10:35:00 -0000 Message-ID: <20100319103504.20133.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug middle-end/40106] [4.4/4.5 Regression] Weird interaction between optimize_insn_for_speed_p and -funsafe-math-optimizations In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "rguenth at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-03/txt/msg01834.txt.bz2 ------- Comment #48 from rguenth at gcc dot gnu dot org 2010-03-19 10:35 ------- Untested patch doing 2): Index: builtins.c =================================================================== --- builtins.c (revision 157561) +++ builtins.c (working copy) @@ -2980,10 +2980,16 @@ expand_builtin_pow (tree exp, rtx target && ((flag_unsafe_math_optimizations && optimize_insn_for_speed_p () && powi_cost (n/2) <= POWI_MAX_MULTS) - /* Even the c==0.5 case cannot be done unconditionally + /* Even the c == 0.5 case cannot be done unconditionally when we need to preserve signed zeros, as pow (-0, 0.5) is +0, while sqrt(-0) is -0. */ - || (!HONOR_SIGNED_ZEROS (mode) && n == 1))) + || (!HONOR_SIGNED_ZEROS (mode) && n == 1) + /* For c == 1.5 we can assume that x * sqrt (x) is always + smaller than pow (x, 1.5) if sqrt will not be expanded + as a call. */ + || (n == 2 + && (optab_handler (sqrt_optab, mode)->insn_code + != CODE_FOR_nothing)))) { tree call_expr = build_call_nofold (fn, 1, narg0); /* Use expand_expr in case the newly built call expression -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40106