From patchwork Fri Nov 12 02:17:46 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 70912 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 13685B7110 for ; Fri, 12 Nov 2010 13:17:55 +1100 (EST) Received: (qmail 21314 invoked by alias); 12 Nov 2010 02:17:53 -0000 Received: (qmail 21306 invoked by uid 22791); 12 Nov 2010 02:17:53 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from a.mail.sonic.net (HELO a.mail.sonic.net) (64.142.16.245) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 12 Nov 2010 02:17:48 +0000 Received: from are.twiddle.net (are.twiddle.net [75.101.38.216]) by a.mail.sonic.net (8.13.8.Beta0-Sonic/8.13.7) with ESMTP id oAC2HktX024384 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 11 Nov 2010 18:17:47 -0800 Received: from are.twiddle.net (localhost [127.0.0.1]) by are.twiddle.net (8.14.4/8.14.4) with ESMTP id oAC2Hktc013360; Thu, 11 Nov 2010 18:17:46 -0800 Received: (from rth@localhost) by are.twiddle.net (8.14.4/8.14.4/Submit) id oAC2HktN013359; Thu, 11 Nov 2010 18:17:46 -0800 Date: Thu, 11 Nov 2010 18:17:46 -0800 From: Richard Henderson To: gcc-patches@gcc.gnu.org Cc: sterling@tensilica.com Subject: [patch 7/N][xtensa] convert to fma Message-ID: <20101112021746.GA13310@twiddle.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Straight-forward conversion here. Untested except for cross-compile. Ok? r~ diff --git a/gcc/config.gcc b/gcc/config.gcc index f92483d..c6a2d4c 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -393,12 +393,16 @@ 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-*-*) cpu_type=sh need_64bit_hwint=yes ;; +xtensa*-*-*) + extra_options="${extra_options} fused-madd.opt" + ;; esac tm_file=${cpu_type}/${cpu_type}.h diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c index a01fb0b..033779c 100644 --- a/gcc/config/xtensa/xtensa.c +++ b/gcc/config/xtensa/xtensa.c @@ -193,7 +193,7 @@ static const struct default_options xtensa_option_optimization_table[] = #define TARGET_ASM_SELECT_RTX_SECTION xtensa_select_rtx_section #undef TARGET_DEFAULT_TARGET_FLAGS -#define TARGET_DEFAULT_TARGET_FLAGS (TARGET_DEFAULT | MASK_FUSED_MADD) +#define TARGET_DEFAULT_TARGET_FLAGS (TARGET_DEFAULT) #undef TARGET_LEGITIMIZE_ADDRESS #define TARGET_LEGITIMIZE_ADDRESS xtensa_legitimize_address diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md index 13883f1..9d9bf9c 100644 --- a/gcc/config/xtensa/xtensa.md +++ b/gcc/config/xtensa/xtensa.md @@ -315,24 +315,25 @@ (set_attr "mode" "SF") (set_attr "length" "3")]) -(define_insn "muladdsf3" +(define_insn "fmasf4" [(set (match_operand:SF 0 "register_operand" "=f") - (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "%f") - (match_operand:SF 2 "register_operand" "f")) - (match_operand:SF 3 "register_operand" "0")))] - "TARGET_HARD_FLOAT && TARGET_FUSED_MADD" + (fma:SF (match_operand:SF 1 "register_operand" "f") + (match_operand:SF 2 "register_operand" "f") + (match_operand:SF 3 "register_operand" "0")))] + "TARGET_HARD_FLOAT" "madd.s\t%0, %1, %2" [(set_attr "type" "fmadd") (set_attr "mode" "SF") (set_attr "length" "3")]) -(define_insn "mulsubsf3" +;; Note that (C - A*B) = (-A*B + C) +(define_insn "fnmasf4" [(set (match_operand:SF 0 "register_operand" "=f") - (minus:SF (match_operand:SF 1 "register_operand" "0") - (mult:SF (match_operand:SF 2 "register_operand" "%f") - (match_operand:SF 3 "register_operand" "f"))))] - "TARGET_HARD_FLOAT && TARGET_FUSED_MADD" - "msub.s\t%0, %2, %3" + (fma:SF (neg:SF (match_operand:SF 1 "register_operand" "f")) + (match_operand:SF 2 "register_operand" "f") + (match_operand:SF 3 "register_operand" "0")))] + "TARGET_HARD_FLOAT" + "msub.s\t%0, %1, %2" [(set_attr "type" "fmadd") (set_attr "mode" "SF") (set_attr "length" "3")]) diff --git a/gcc/config/xtensa/xtensa.opt b/gcc/config/xtensa/xtensa.opt index 18f8bf3..9ae8b39 100644 --- a/gcc/config/xtensa/xtensa.opt +++ b/gcc/config/xtensa/xtensa.opt @@ -22,10 +22,6 @@ mconst16 Target Report Mask(CONST16) Use CONST16 instruction to load constants -mfused-madd -Target Report Mask(FUSED_MADD) -Enable fused multiply/add and multiply/subtract FP instructions - mforce-no-pic Target Report Mask(FORCE_NO_PIC) Disable position-independent code (PIC) for use in OS kernel code