From patchwork Wed Dec 21 18:54:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yunqiang Su X-Patchwork-Id: 707930 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tkP336rHcz9t0X for ; Thu, 22 Dec 2016 05:54:39 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="LGbSqvqU"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:content-type:content-id :content-transfer-encoding:mime-version; q=dns; s=default; b=XcM If2HJ2iPb7MopJdvk6P0sKLUoSCwfM2vwIyTbv1WcUFpQzeG6zf4s5S8pBffqwR+ tEMROub+vDiKB9szfDQBoQbU6jDhRGoxSVF2xTNZ5I0QXK+5ZGrFuY4+PZi0mnwl dU/nTYSZGwdMtsHlLysjUTq3zucI3nvtCRHAHHAA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:content-type:content-id :content-transfer-encoding:mime-version; s=default; bh=l1DGPMyln fpj/GtOzvtGrigaoYc=; b=LGbSqvqURwpIYjbCz3LDHaK0SJaaMuhhF9ekbLOkb dG6S9K3E6Plj+mBC4QtS1WgONQIxEth2EDizYx+YX/4LtVHy7WcLuPyeoh70IoeN eizDUbYZumhxq6OifMOFmQ5Xxs3//MUyKB9mxONU6TbDVdCua4XQ/6Xoc/NbULZM +4= Received: (qmail 20340 invoked by alias); 21 Dec 2016 18:54:28 -0000 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 Received: (qmail 20170 invoked by uid 89); 21 Dec 2016 18:54:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.5 required=5.0 tests=BAYES_00, KAM_WEIRDTRICK1, MIME_BASE64_BLANKS, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=H*c:gb2312, eval, 8927, HAccept-Language:en-GB X-HELO: mailapp01.imgtec.com Received: from mailapp01.imgtec.com (HELO mailapp01.imgtec.com) (195.59.15.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 21 Dec 2016 18:54:24 +0000 Received: from hhmail02.hh.imgtec.org (unknown [10.100.10.20]) by Forcepoint Email with ESMTPS id 297583F02E4A6 for ; Wed, 21 Dec 2016 18:54:18 +0000 (GMT) Received: from HHMAIL01.hh.imgtec.org ([fe80::710b:f219:72bc:e0b3]) by hhmail02.hh.imgtec.org ([fe80::5400:d33e:81a4:f775%25]) with mapi id 14.03.0294.000; Wed, 21 Dec 2016 18:54:21 +0000 From: Yunqiang Su To: gcc-patches CC: Matthew Fortune Subject: [Patch , gcc/MIPS] add an build-time/runtime option to disable madd.fmt Date: Wed, 21 Dec 2016 18:54:20 +0000 Message-ID: <7FDC38C0-90D4-4A32-8FD5-ED65DC469055@imgtec.com> Content-ID: MIME-Version: 1.0 By this patch, I add a build-time option ` --with-unfused-madd4=yes/no’, and runtime option -m(no-)unfused-madd4, to disable generate madd.fmt instructions. These 2 options is needed due to madd.fmt/msub.fmt on Loongson are broken, which may generate wrong calculator result. diff --git a/src/gcc/config.gcc b/src/gcc/config.gcc index 1b7da0e..3a30b44 100644 --- a/src/gcc/config.gcc +++ b/src/gcc/config.gcc @@ -3991,7 +3991,7 @@ case "${target}" in ;; mips*-*-*) - supported_defaults="abi arch arch_32 arch_64 float fpu nan fp_32 odd_spreg_32 tune tune_32 tune_64 divide llsc mips-plt synci" + supported_defaults="abi arch arch_32 arch_64 float fpu nan fp_32 odd_spreg_32 unfused_madd4 tune tune_32 tune_64 divide llsc mips-plt synci" case ${with_float} in "" | soft | hard) @@ -4048,6 +4048,19 @@ case "${target}" in exit 1 ;; esac + + case ${with_unfused_madd4} in + "" | yes) + with_unfused_madd4="unfused-madd4" + ;; + no) + with_unfused_madd4="no-unfused-madd4" + ;; + *) + echo "Unknown unfused_madd4 type used in --with-unfused-madd4=$with_unfused_madd4" 1>&2 + exit 1 + ;; + esac case ${with_abi} in "" | 32 | o64 | n32 | 64 | eabi) @@ -4547,7 +4560,7 @@ case ${target} in esac t= -all_defaults="abi cpu cpu_32 cpu_64 arch arch_32 arch_64 tune tune_32 tune_64 schedule float mode fpu nan fp_32 odd_spreg_32 divide llsc mips-plt synci tls" +all_defaults="abi cpu cpu_32 cpu_64 arch arch_32 arch_64 tune tune_32 tune_64 schedule float mode fpu nan fp_32 odd_spreg_32 unfused_madd4 divide llsc mips-plt synci tls" for option in $all_defaults do eval "val=\$with_"`echo $option | sed s/-/_/g` diff --git a/src/gcc/config/mips/mips.c b/src/gcc/config/mips/mips.c index 5af3d1e..236ab94 100644 --- a/src/gcc/config/mips/mips.c +++ b/src/gcc/config/mips/mips.c @@ -17992,6 +17992,16 @@ mips_option_override (void) will be produced. */ target_flags |= MASK_ODD_SPREG; } + + /* If neither -munfused-madd nor -mno-unfused-madd was given on the command + line, set MASK_UNFSUED_MADD based on the ISA. */ + if ((target_flags_explicit & MASK_UNFUSED_MADD4) == 0) + { + if (!ISA_HAS_UNFUSED_MADD4) + target_flags &= ~MASK_UNFUSED_MADD4; + else + target_flags |= MASK_UNFUSED_MADD4; + } if (!ISA_HAS_COMPACT_BRANCHES && mips_cb == MIPS_CB_ALWAYS) { diff --git a/src/gcc/config/mips/mips.h b/src/gcc/config/mips/mips.h index 763ca58..8c7d24e 100644 --- a/src/gcc/config/mips/mips.h +++ b/src/gcc/config/mips/mips.h @@ -892,6 +892,7 @@ struct mips_cpu_info { ":%{!msoft-float:%{!msingle-float:%{!mfp*:-mfp%(VALUE)}}}}" }, \ {"odd_spreg_32", "%{" OPT_ARCH32 ":%{!msoft-float:%{!msingle-float:" \ "%{!modd-spreg:%{!mno-odd-spreg:-m%(VALUE)}}}}}" }, \ + {"unfused_madd4", "%{!munfused-madd4:%{!mno-unfused-madd4:-m%(VALUE)}}" }, \ {"divide", "%{!mdivide-traps:%{!mdivide-breaks:-mdivide-%(VALUE)}}" }, \ {"llsc", "%{!mllsc:%{!mno-llsc:-m%(VALUE)}}" }, \ {"mips-plt", "%{!mplt:%{!mno-plt:-m%(VALUE)}}" }, \ @@ -1089,7 +1090,7 @@ struct mips_cpu_info { /* ISA has 4 operand unfused madd instructions of the form 'd = [+-] (a * b [+-] c)'. */ -#define ISA_HAS_UNFUSED_MADD4 (ISA_HAS_FP4 && !TARGET_MIPS8000) +#define ISA_HAS_UNFUSED_MADD4 (ISA_HAS_FP4 && !TARGET_MIPS8000 && TARGET_UNFUSED_MADD4) /* ISA has 3 operand r6 fused madd instructions of the form 'c = c [+-] (a * b)'. */ diff --git a/src/gcc/config/mips/mips.opt b/src/gcc/config/mips/mips.opt index ebd67e4..a8c23f6 100644 --- a/src/gcc/config/mips/mips.opt +++ b/src/gcc/config/mips/mips.opt @@ -412,6 +412,10 @@ modd-spreg Target Report Mask(ODD_SPREG) Enable use of odd-numbered single-precision registers. +munfused-madd4 +Target Report Mask(UNFUSED_MADD4) +Enable unfused multiply-add/multiply-sub instruction, aka madd.fmt/msub.fmt. + mframe-header-opt Target Report Var(flag_frame_header_optimization) Optimization Optimize frame header.