From patchwork Wed Mar 6 00:43:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Endo X-Patchwork-Id: 225221 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 E119D2C02A8 for ; Wed, 6 Mar 2013 11:44:14 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1363135456; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Subject:From:To:Cc:Date:Content-Type:Mime-Version: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=qPC3TzuxjpcQoQ19+TZN kHrn5V8=; b=ytYNcY/o9qDfuBS9oNdBRfXuWnTACip898QT/dxGMO5u6W2Jc94x pTwOb9pe8awoNLjGjk02da+RgWeibN8hOE+IZRiW04DzIYHZ4X1sHAQMhmQeDp2h S3gOeEAF7VKG39tuaooLfSCPkq7jFWkvfUfsUNLh++kbEG+9/jwYbsw= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Subject:From:To:Cc:Date:Content-Type:Mime-Version:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=AvQDn1h9KDl5OlCvw5unetyH1nrjz2ox7FKO1BJUJpqo1rI4KmFxabIBbWVwNF A/bDVz3hP1mQ7r0DGhOrPe/ehqPZ/U397dPMmB/L75yU3zmPPstxarsg3Oye/PlN 9TUqiT6GvcD/LRlz+dj5d5XP1vv0seZ2lgjQuk61/yfzk=; Received: (qmail 12533 invoked by alias); 6 Mar 2013 00:44:04 -0000 Received: (qmail 12525 invoked by uid 22791); 6 Mar 2013 00:44:03 -0000 X-SWARE-Spam-Status: No, hits=-3.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_HOSTKARMA_NO, RP_MATCHES_RCVD, UNPARSEABLE_RELAY X-Spam-Check-By: sourceware.org Received: from mailout09.t-online.de (HELO mailout09.t-online.de) (194.25.134.84) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 06 Mar 2013 00:43:58 +0000 Received: from fwd53.aul.t-online.de (fwd53.aul.t-online.de ) by mailout09.t-online.de with smtp id 1UD2SZ-0001qz-Qx; Wed, 06 Mar 2013 01:43:55 +0100 Received: from [192.168.0.103] (bdfz5QZCZhiwTDH9WZViQMA3nIFVTkOwnYv-S5Nglr6-bzERpDIEcCCCyg+KZgNwC0@[87.155.251.108]) by fwd53.t-online.de with esmtp id 1UD2SU-21Ckee0; Wed, 6 Mar 2013 01:43:50 +0100 Message-ID: <1362530624.2219.69.camel@yam-132-YW-E178-FTW> Subject: [SH, committed] PR 56529 - Calls to __sdivsi3_i4i and __udivsi3_i4i are generated on SH2 From: Oleg Endo To: gcc-patches Cc: Yoshinori Sato Date: Wed, 06 Mar 2013 01:43:44 +0100 Mime-Version: 1.0 X-IsSubscribed: yes 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 Hi, This is the patch that I posted in the PR and that was pre-approved by Kaz, with some documentation bits added. Tested with 'make info dvi pdf' and 'make all'. Applied as revision 196484. Will backport it to 4.7 branch. Cheers, Oleg gcc/ChangeLog: PR target/56529 * config/sh/sh.c (sh_option_override): Check for TARGET_DYNSHIFT instead of TARGET_SH2 for call-table case. Do not set sh_div_strategy to SH_DIV_CALL_TABLE for TARGET_SH2. * config.gcc (sh_multilibs): Add m2 and m2a to sh*-*-linux* multilib list. * doc/invoke.texi (SH options): Document mdiv= call-div1, call-fp, call-table options. libgcc/ChangeLog: PR target/56529 * config/sh/lib1funcs.S (udivsi3_i4i, sdivsi3_i4i): Add __SH2A__ to inclusion list. Index: gcc/config/sh/sh.c =================================================================== --- gcc/config/sh/sh.c (revision 196483) +++ gcc/config/sh/sh.c (working copy) @@ -820,7 +820,7 @@ || (TARGET_HARD_SH4 && TARGET_SH2E) || (TARGET_SHCOMPACT && TARGET_FPU_ANY))) sh_div_strategy = SH_DIV_CALL_FP; - else if (! strcmp (sh_div_str, "call-table") && TARGET_SH2) + else if (! strcmp (sh_div_str, "call-table") && TARGET_DYNSHIFT) sh_div_strategy = SH_DIV_CALL_TABLE; else /* Pick one that makes most sense for the target in general. @@ -840,8 +840,6 @@ sh_div_strategy = SH_DIV_CALL_FP; /* SH1 .. SH3 cores often go into small-footprint systems, so default to the smallest implementation available. */ - else if (TARGET_SH2) /* ??? EXPERIMENTAL */ - sh_div_strategy = SH_DIV_CALL_TABLE; else sh_div_strategy = SH_DIV_CALL_DIV1; } Index: gcc/config.gcc =================================================================== --- gcc/config.gcc (revision 196483) +++ gcc/config.gcc (working copy) @@ -2371,7 +2371,7 @@ sh[1234]*) sh_multilibs=${sh_cpu_target} ;; sh64* | sh5*) sh_multilibs=m5-32media,m5-32media-nofpu,m5-compact,m5-compact-nofpu,m5-64media,m5-64media-nofpu ;; sh-superh-*) sh_multilibs=m4,m4-single,m4-single-only,m4-nofpu ;; - sh*-*-linux*) sh_multilibs=m1,m3e,m4 ;; + sh*-*-linux*) sh_multilibs=m1,m2,m2a,m3e,m4 ;; sh*-*-netbsd*) sh_multilibs=m3,m3e,m4 ;; *) sh_multilibs=m1,m2,m2e,m4,m4-single,m4-single-only,m2a,m2a-single ;; esac Index: gcc/doc/invoke.texi =================================================================== --- gcc/doc/invoke.texi (revision 196483) +++ gcc/doc/invoke.texi (working copy) @@ -18749,8 +18749,8 @@ @item -mdiv=@var{strategy} @opindex mdiv=@var{strategy} -Set the division strategy to use for SHmedia code. @var{strategy} must be -one of: +Set the division strategy to be used for integer division operations. +For SHmedia @var{strategy} can be one of: @table @samp @@ -18808,6 +18808,36 @@ @end table +For targets other than SHmedia @var{strategy} can be one of: + +@table @samp + +@item call-div1 +Calls a library function that uses the single-step division instruction +@code{div1} to perform the operation. Division by zero calculates an +unspecified result and does not trap. This is the default except for SH4, +SH2A and SHcompact. + +@item call-fp +Calls a library function that performs the operation in double precision +floating point. Division by zero causes a floating-point exception. This is +the default for SHcompact with FPU. Specifying this for targets that do not +have a double precision FPU will default to @code{call-div1}. + +@item call-table +Calls a library function that uses a lookup table for small divisors and +the @code{div1} instruction with case distinction for larger divisors. Division +by zero calculates an unspecified result and does not trap. This is the default +for SH4. Specifying this for targets that do not have dynamic shift +instructions will default to @code{call-div1}. + +@end table + +When a division strategy has not been specified the default strategy will be +selected based on the current target. For SH2A the default strategy is to +use the @code{divs} and @code{divu} instructions instead of library function +calls. + @item -maccumulate-outgoing-args @opindex maccumulate-outgoing-args Reserve space once for outgoing arguments in the function prologue rather Index: libgcc/config/sh/lib1funcs.S =================================================================== --- libgcc/config/sh/lib1funcs.S (revision 196483) +++ libgcc/config/sh/lib1funcs.S (working copy) @@ -3288,8 +3288,8 @@ .word 17136 .word 16639 -#elif defined (__SH3__) || defined (__SH3E__) || defined (__SH4__) || defined (__SH4_SINGLE__) || defined (__SH4_SINGLE_ONLY__) || defined (__SH4_NOFPU__) -/* This code used shld, thus is not suitable for SH1 / SH2. */ +#elif defined (__SH2A__) || defined (__SH3__) || defined (__SH3E__) || defined (__SH4__) || defined (__SH4_SINGLE__) || defined (__SH4_SINGLE_ONLY__) || defined (__SH4_NOFPU__) +/* This code uses shld, thus is not suitable for SH1 / SH2. */ /* Signed / unsigned division without use of FPU, optimized for SH4. Uses a lookup table for divisors in the range -128 .. +128, and