From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1491 invoked by alias); 4 Feb 2015 14:43:59 -0000 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 Received: (qmail 30262 invoked by uid 48); 4 Feb 2015 14:43:56 -0000 From: "ebotcazou at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/62631] gcc.dg/tree-ssa/ivopts-lt-2.c FAILs Date: Wed, 04 Feb 2015 14:43:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ebotcazou at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 5.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-02/txt/msg00321.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62631 --- Comment #17 from Eric Botcazou --- This looks a generic problem in get_shiftadd_cost to me, it ought to mimic the algorithms in expmed.c, something like: @@ -3597,22 +3597,26 @@ get_shiftadd_cost (tree expr, machine_mo tree multop = TREE_OPERAND (mult, 0); int m = exact_log2 (int_cst_value (cst)); int maxm = MIN (BITS_PER_WORD, GET_MODE_BITSIZE (mode)); - int sa_cost; - bool equal_p = false; + int as_cost, sa_cost; + bool mult_in_op1; if (!(m >= 0 && m < maxm)) return false; - if (operand_equal_p (op1, mult, 0)) - equal_p = true; + mult_in_op1 = operand_equal_p (op1, mult, 0); + as_cost = add_cost (speed, mode) + shift_cost (speed, mode, m); + + /* If the target has a cheap shift-and-add or shift-and-sub instruction, + use that in preference to a shift insn followed by an add insn. */ sa_cost = (TREE_CODE (expr) != MINUS_EXPR ? shiftadd_cost (speed, mode, m) - : (equal_p + : (mult_in_op1 ? shiftsub1_cost (speed, mode, m) : shiftsub0_cost (speed, mode, m))); - res = new_cost (sa_cost, 0); - res = add_costs (res, equal_p ? cost0 : cost1); + + res = new_cost (MIN (as_cost, sa_cost), 0); + res = add_costs (res, mult_in_op1 ? cost0 : cost1); STRIP_NOPS (multop); if (!is_gimple_val (multop))