From patchwork Sat Oct 19 09:30:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Endo X-Patchwork-Id: 284859 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 582A02C00E3 for ; Sat, 19 Oct 2013 20:31:07 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:subject:from:to:cc:date:in-reply-to:references :content-type:mime-version; q=dns; s=default; b=f9OPlbJPaAJraZFg DsAzACS1wnjQnA/EheeUcC/2VsU9n3tZ8FFauOGeBP9JMRQmQnRuDlYsNpoQatO7 8HY9lZYpPnH8f4YzDcNww7nS84py9fl1hm9+ZG8tqOHY8iAybEn99I3hSkMr0COb +3kKMeGcHO1uwsdgrh6U6Vdqd2c= 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 :message-id:subject:from:to:cc:date:in-reply-to:references :content-type:mime-version; s=default; bh=r0jyuHHxZvgQIMl5XopBrP n4HGo=; b=qu8czPwAhDubWX/ujNs5Q6/M2aymJLTHlzl+folhVG9NSIT9mctZm/ iC1JIoR7k66xkRCD8E6SKbw8rlfbemeYGC/yS2Xa+BKX58Due9tXLCaoxWaTYuaU qbOhsRlay0f1q/QuscVuWx2H0KVpYiPMftABSBSxfZemRsZHw92Ak= Received: (qmail 26150 invoked by alias); 19 Oct 2013 09:31:01 -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 26137 invoked by uid 89); 19 Oct 2013 09:31:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.2 X-HELO: mailout07.t-online.de Received: from mailout07.t-online.de (HELO mailout07.t-online.de) (194.25.134.83) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 19 Oct 2013 09:30:58 +0000 Received: from fwd51.aul.t-online.de (fwd51.aul.t-online.de ) by mailout07.t-online.de with smtp id 1VXSrz-000167-07; Sat, 19 Oct 2013 11:30:51 +0200 Received: from [192.168.0.103] (bLxs7GZD8h3W8MgRMGqOf8+z1Y6fzrQxB-aIOW7EjAcy-v4ny40w4B+G2vuRHR1ZOn@[93.195.21.62]) by fwd51.t-online.de with esmtp id 1VXSrr-0rwbrM0; Sat, 19 Oct 2013 11:30:43 +0200 Message-ID: <1382175042.2445.84.camel@yam-132-YW-E178-FTW> Subject: Re: [PATCH, SH] Add support for inlined builtin-strcmp (2/2) From: Oleg Endo To: Christian Bruel Cc: "gcc-patches@gcc.gnu.org" , Kaz Kojima Date: Sat, 19 Oct 2013 11:30:42 +0200 In-Reply-To: <5260EA68.9080603@st.com> References: <525FF0F9.4010704@st.com> <1382051119.2445.62.camel@yam-132-YW-E178-FTW> <5260EA68.9080603@st.com> Mime-Version: 1.0 X-IsSubscribed: yes On Fri, 2013-10-18 at 09:59 +0200, Christian Bruel wrote: > On 10/18/2013 01:05 AM, Oleg Endo wrote: > > I was wondering, in file sh-mem.c, the new function > > 'sh4_expand_cmpstr' ... why is it SH4-something? It's a bit confusing, > > since cmp/str has been around since ever (i.e. since SH1). Maybe just > > rename it to 'sh_expand_cmpstr' instead? > > Just historical. (SH4* are our primary SH platforms). The code is > enabled/tested for all SH1 of course, I will rename. Thanks . > > > Maybe just > > rename it to 'sh_expand_cmpstr' instead? The function always returns > > 'true', so maybe just make it return 'void'? > > yes, it's for genericity as I plan to reuse/specialize the code based on > the count parameter for strncmp to be contributed next. I already assumed so :) > > > > Also, in the expander ... > > > > + [(set (match_operand:SI 0 "register_operand" "") > > + (compare:SI (match_operand:BLK 1 "memory_operand" "") > > > > ... no need to use empty "" constraints > > OK, thanks Could you also please remove the quotes around the preparation block: " { if (! optimize_insn_for_size_p () && sh4_expand_cmpstr(operands)) DONE; else FAIL; }") I've attached two test cases, tested with make -k check-gcc RUNTESTFLAGS="sh.exp=strcmp* --target_board=sh-sim \{-m2/-ml,-m2/-mb,-m2a/-mb,-m4/-ml,-m4/-mb,-m4a/-ml,-m4a/-mb}" Could you please include them? Cheers, Oleg Index: gcc/testsuite/gcc.target/sh/strcmp-2.c =================================================================== --- gcc/testsuite/gcc.target/sh/strcmp-2.c (revision 0) +++ gcc/testsuite/gcc.target/sh/strcmp-2.c (revision 0) @@ -0,0 +1,13 @@ +/* Check that the __builtin_strcmp function is not inlined when optimizing + for size. */ +/* { dg-do compile { target "sh*-*-*" } } */ +/* { dg-options "-Os" } */ +/* { dg-skip-if "" { "sh*-*-*" } { "-m5*" } { "" } } */ +/* { dg-final { scan-assembler-not "cmp/str" } } */ +/* { dg-final { scan-assembler "jsr|jmp|bsr|bra" } } */ + +int +test00 (const char* a, const char* b) +{ + return __builtin_strcmp (a, b); +} Index: gcc/testsuite/gcc.target/sh/strcmp-1.c =================================================================== --- gcc/testsuite/gcc.target/sh/strcmp-1.c (revision 0) +++ gcc/testsuite/gcc.target/sh/strcmp-1.c (revision 0) @@ -0,0 +1,12 @@ +/* Check that the __builtin_strcmp function is inlined utilizing cmp/str insn + when optimizing for speed. */ +/* { dg-do compile { target "sh*-*-*" } } */ +/* { dg-options "-O2" } */ +/* { dg-skip-if "" { "sh*-*-*" } { "-m5*" } { "" } } */ +/* { dg-final { scan-assembler "cmp/str" } } */ + +int +test00 (const char* a, const char* b) +{ + return __builtin_strcmp (a, b); +}