From d7ecb504b9a8d854d5b558334f3a4b1e65fc0066 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Tue, 16 Nov 2010 15:24:53 -0800 Subject: [PATCH] s390: -mfused-madd cleanup * config.gcc [s390*-*] (extra_options): Add fused-madd.opt. * config/s390/s390.opt (mfused-madd): Remove. * config/s390/s390.c (s390_rtx_costs): Handle FMA. (TARGET_DEFAULT_TARGET_FLAGS): Remove MASK_FUSED_MADD. * config/s390/s390.md (fma4): Rename from *fmadd; use FMA. (fms4): Rename from *fmsub; use FMA. From-SVN: r166838 --- gcc/ChangeLog | 9 +++++++++ gcc/config.gcc | 1 + gcc/config/s390/s390.c | 39 +++++++++++++++++++++++---------------- gcc/config/s390/s390.md | 18 +++++++++--------- gcc/config/s390/s390.opt | 4 ---- 5 files changed, 42 insertions(+), 29 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6f6da0790385..a9b8f7682ba6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2010-11-16 Richard Henderson + + * config.gcc [s390*-*] (extra_options): Add fused-madd.opt. + * config/s390/s390.opt (mfused-madd): Remove. + * config/s390/s390.c (s390_rtx_costs): Handle FMA. + (TARGET_DEFAULT_TARGET_FLAGS): Remove MASK_FUSED_MADD. + * config/s390/s390.md (fma4): Rename from *fmadd; use FMA. + (fms4): Rename from *fmsub; use FMA. + 2010-11-16 Richard Henderson * config.gcc [powerpc*, rs6000*] (extra_options): Add fused-madd.opt. diff --git a/gcc/config.gcc b/gcc/config.gcc index 0202a2293747..c6a2d4cb113f 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -393,6 +393,7 @@ spu*-*-*) s390*-*-*) cpu_type=s390 need_64bit_hwint=yes + extra_options="${extra_options} fused-madd.opt" ;; # Note the 'l'; we need to be able to match e.g. "shle" or "shl". sh[123456789lbe]*-*-* | sh-*-*) diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index 11ca919af288..2c40b67811ba 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -2464,21 +2464,6 @@ s390_rtx_costs (rtx x, int code, int outer_code, int *total, case PLUS: case MINUS: - /* Check for multiply and add. */ - if ((GET_MODE (x) == DFmode || GET_MODE (x) == SFmode) - && GET_CODE (XEXP (x, 0)) == MULT - && TARGET_HARD_FLOAT && TARGET_FUSED_MADD) - { - /* This is the multiply and add case. */ - if (GET_MODE (x) == DFmode) - *total = s390_cost->madbr; - else - *total = s390_cost->maebr; - *total += (rtx_cost (XEXP (XEXP (x, 0), 0), MULT, speed) - + rtx_cost (XEXP (XEXP (x, 0), 1), MULT, speed) - + rtx_cost (XEXP (x, 1), (enum rtx_code) code, speed)); - return true; /* Do not do an additional recursive descent. */ - } *total = COSTS_N_INSNS (1); return false; @@ -2541,6 +2526,28 @@ s390_rtx_costs (rtx x, int code, int outer_code, int *total, } return false; + case FMA: + switch (GET_MODE (x)) + { + case DFmode: + *total = s390_cost->madbr; + break; + case SFmode: + *total = s390_cost->maebr; + break; + default: + return false; + } + /* Negate in the third argument is free: FMSUB. */ + if (GET_CODE (XEXP (x, 2)) == NEG) + { + *total += (rtx_cost (XEXP (x, 0), FMA, speed) + + rtx_cost (XEXP (x, 1), FMA, speed) + + rtx_cost (XEXP (XEXP (x, 2), 0), FMA, speed)); + return true; + } + return false; + case UDIV: case UMOD: if (GET_MODE (x) == TImode) /* 128 bit division */ @@ -10511,7 +10518,7 @@ s390_loop_unroll_adjust (unsigned nunroll, struct loop *loop) #define TARGET_ASM_CLOSE_PAREN "" #undef TARGET_DEFAULT_TARGET_FLAGS -#define TARGET_DEFAULT_TARGET_FLAGS (TARGET_DEFAULT | MASK_FUSED_MADD) +#define TARGET_DEFAULT_TARGET_FLAGS (TARGET_DEFAULT) #undef TARGET_HANDLE_OPTION #define TARGET_HANDLE_OPTION s390_handle_option diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md index ce8c3ce2429c..701fca1f9bed 100644 --- a/gcc/config/s390/s390.md +++ b/gcc/config/s390/s390.md @@ -5488,12 +5488,12 @@ (set_attr "type" "fmul")]) ; madbr, maebr, maxb, madb, maeb -(define_insn "*fmadd" +(define_insn "fma4" [(set (match_operand:DSF 0 "register_operand" "=f,f") - (plus:DSF (mult:DSF (match_operand:DSF 1 "nonimmediate_operand" "%f,f") - (match_operand:DSF 2 "nonimmediate_operand" "f,R")) + (fma:DSF (match_operand:DSF 1 "nonimmediate_operand" "%f,f") + (match_operand:DSF 2 "nonimmediate_operand" "f,R") (match_operand:DSF 3 "register_operand" "0,0")))] - "TARGET_HARD_FLOAT && TARGET_FUSED_MADD" + "TARGET_HARD_FLOAT" "@ mabr\t%0,%1,%2 mab\t%0,%1,%2" @@ -5501,12 +5501,12 @@ (set_attr "type" "fmadd")]) ; msxbr, msdbr, msebr, msxb, msdb, mseb -(define_insn "*fmsub" +(define_insn "fms4" [(set (match_operand:DSF 0 "register_operand" "=f,f") - (minus:DSF (mult:DSF (match_operand:DSF 1 "nonimmediate_operand" "f,f") - (match_operand:DSF 2 "nonimmediate_operand" "f,R")) - (match_operand:DSF 3 "register_operand" "0,0")))] - "TARGET_HARD_FLOAT && TARGET_FUSED_MADD" + (fma:DSF (match_operand:DSF 1 "nonimmediate_operand" "%f,f") + (match_operand:DSF 2 "nonimmediate_operand" "f,R") + (neg:DSF (match_operand:DSF 3 "register_operand" "0,0"))))] + "TARGET_HARD_FLOAT" "@ msbr\t%0,%1,%2 msb\t%0,%1,%2" diff --git a/gcc/config/s390/s390.opt b/gcc/config/s390/s390.opt index 9451b74dfb36..57ab838ff564 100644 --- a/gcc/config/s390/s390.opt +++ b/gcc/config/s390/s390.opt @@ -42,10 +42,6 @@ mesa Target Report RejectNegative Negative(mzarch) InverseMask(ZARCH) ESA/390 architecture -mfused-madd -Target Report Mask(FUSED_MADD) -Enable fused multiply/add instructions - mhard-dfp Target Report Mask(HARD_DFP) Enable decimal floating point hardware support