From 88ce9dc38a0590608dd036e08758b478f8ca429c Mon Sep 17 00:00:00 2001 From: Uros Bizjak Date: Fri, 12 May 2017 20:52:51 +0200 Subject: [PATCH] re PR target/80723 (FAIL gcc.target/i386/cadd.c scan assembler sbb) PR target/80723 * config/i386/i386.c (ix86_rtx_cost) [case PLUS]: Ignore the cost of adding a carry flag for ADC instruction. [case MINUS]: Ignore the cost of subtracting a carry flag for SBB instruction. From-SVN: r247991 --- gcc/ChangeLog | 10 +++++++++- gcc/config/i386/i386.c | 27 ++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 99f1648f914..cc9f7a32be9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2017-05-12 Uros Bizjak + + PR target/80723 + * config/i386/i386.c (ix86_rtx_cost) [case PLUS]: Ignore the + cost of adding a carry flag for ADC instruction. + [case MINUS]: Ignore the cost of subtracting a carry flag + for SBB instruction. + 2017-05-12 Steven Munroe * config.gcc (powerpc*-*-*): Add bmi2intrin.h, bmiintrin.h, @@ -8,7 +16,7 @@ 2017-05-12 Jeff Law - * tree-vrp.c (vrp_dom_walker::before_dom_childern): Push unwinding + * tree-vrp.c (vrp_dom_walker::before_dom_children): Push unwinding markers. 2017-05-12 Peter Bergner diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 7e8cdb9602a..b5bdcd63608 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -40913,9 +40913,16 @@ ix86_rtx_costs (rtx x, machine_mode mode, int outer_code_i, int opno, } else if (GET_CODE (XEXP (x, 0)) == PLUS) { - *total = cost->lea; - *total += rtx_cost (XEXP (XEXP (x, 0), 0), mode, - outer_code, opno, speed); + /* Add with carry, ignore the cost of adding a carry flag. */ + if (ix86_carry_flag_operator (XEXP (XEXP (x, 0), 0), mode)) + *total = cost->add; + else + { + *total = cost->lea; + *total += rtx_cost (XEXP (XEXP (x, 0), 0), mode, + outer_code, opno, speed); + } + *total += rtx_cost (XEXP (XEXP (x, 0), 1), mode, outer_code, opno, speed); *total += rtx_cost (XEXP (x, 1), mode, @@ -40926,6 +40933,20 @@ ix86_rtx_costs (rtx x, machine_mode mode, int outer_code_i, int opno, /* FALLTHRU */ case MINUS: + /* Subtract with borrow, ignore the cost of subtracting a carry flag. */ + if (GET_MODE_CLASS (mode) == MODE_INT + && GET_MODE_SIZE (mode) <= UNITS_PER_WORD + && GET_CODE (XEXP (x, 0)) == MINUS + && ix86_carry_flag_operator (XEXP (XEXP (x, 0), 1), mode)) + { + *total = cost->add; + *total += rtx_cost (XEXP (XEXP (x, 0), 0), mode, + outer_code, opno, speed); + *total += rtx_cost (XEXP (x, 1), mode, + outer_code, opno, speed); + return true; + } + if (SSE_FLOAT_MODE_P (mode) && TARGET_SSE_MATH) { /* ??? SSE cost should be used here. */ -- 2.30.2