From patchwork Thu Jan 19 12:14:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 717040 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 3v42pC6xgtz9sDF for ; Thu, 19 Jan 2017 23:14:43 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="fylcGOVy"; 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:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=qHwULBVJ44sui/FhimM+fa9PaaSTzrmTBF15uCnuCQ1w++BPNX r/WxApE2iBMQvbgPcp5etLCgsuXQjb1naEF+ACHN0OlbuTAnX9SMVqGVERbaaqcH Y8khVJArjIwhKmHnKQ8fPBFbb/G2abXp93QlzwnMhEK0J75OHbkVXK3jc= 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:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=8fHJxyQxA39KkwAbAs5uDfUjHZk=; b=fylcGOVykonvN6OJktvR u0gyDc0RiD8ZDR+0NjJmvo+/0aNwt2Lsj0v23+uHjhn8YxjvjpXKZriSs45UvKHT wjSIXsLAFfOk5RR3zpab29h9B90ihNIPFaxk/7az2ZvOZMi8A0P3ynRTeDCXAITk m0dGfpattyzZwRNnyGG61uU= Received: (qmail 96466 invoked by alias); 19 Jan 2017 12:14:36 -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 96454 invoked by uid 89); 19 Jan 2017 12:14:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=GEN_INT, sk:gen_rtx, gen_int, get_mode X-HELO: mail-pf0-f179.google.com Received: from mail-pf0-f179.google.com (HELO mail-pf0-f179.google.com) (209.85.192.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 19 Jan 2017 12:14:33 +0000 Received: by mail-pf0-f179.google.com with SMTP id y143so13313237pfb.0 for ; Thu, 19 Jan 2017 04:14:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=jYMc3krzY9cNUqcMzOTH9dt77veNXYzdwv10wvQmLfQ=; b=GVqkz9LC9uybHS0tmmhMxpqnfZbntiw/4Hw9ApuD2PA2rMZULCiX7BW09kL1qIQGYH DLezkm+okMox6FWpuJBsW8QfQQZnFHtcv4f7v39kMvcIJVCixxvwqijNhDCDNR716NeJ cLf/0JVcrcnUiSdZU2E15POtjdx2Aez9rAWP8pS4VbKd5kIw+IhntXWIvnAH8ViHIMd4 kyuI9g8bzknrGDHTq7CAUU9FuqURMvBWnEsNBGH5+OnJGZ3UX5f+jKqx4rXcIezU7plv Hn40PL0G2khk9Q3WSSN47O2Z6LmuaBwea4snhj9ReD637TlH93aSx36IDQy5YOf0SNNM TJeQ== X-Gm-Message-State: AIkVDXIXpACOJEyYMRasYDk8+SNAEXMNO++Sxnl9bMM62YnlxLHMR4JLaRem5mCMtm4V2A== X-Received: by 10.99.133.65 with SMTP id u62mr9980665pgd.70.1484828071980; Thu, 19 Jan 2017 04:14:31 -0800 (PST) Received: from bubble.grove.modra.org (CPE-58-160-71-80.tyqh2.lon.bigpond.net.au. [58.160.71.80]) by smtp.gmail.com with ESMTPSA id r21sm8355901pfd.95.2017.01.19.04.14.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Jan 2017 04:14:31 -0800 (PST) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 30B19C06C1; Thu, 19 Jan 2017 22:44:27 +1030 (ACDT) Date: Thu, 19 Jan 2017 22:44:27 +1030 From: Alan Modra To: gcc-patches@gcc.gnu.org Cc: Segher Boessenkool Subject: [RS6000] PR79144, cmpstrnsi optimization breaks glibc Message-ID: <20170119121427.GQ32333@bubble.grove.modra.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes glibc compiled with current gcc-7 fails one test due to strcmp and strncmp appearing in the PLT. This is because the inline expansion of those functions falls back to a function call, but not using the asm name for the call. Fixed by retrieving the asm name from the builtin decl. I used the builtin decl simply because it is in a handy table. Bootstrapped and regression tested powerpc64le-linux. OK to apply? * config/rs6000/rs6000.c (expand_strn_compare): Get the asm name for strcmp and strncmp from corresponding builtin decl. diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 44d18e9..4c6bada 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -19869,10 +19869,13 @@ expand_strn_compare (rtx operands[], int no_length) } if (no_length) - emit_library_call_value (gen_rtx_SYMBOL_REF (Pmode, "strcmp"), - target, LCT_NORMAL, GET_MODE (target), 2, - force_reg (Pmode, XEXP (src1, 0)), Pmode, - force_reg (Pmode, XEXP (src2, 0)), Pmode); + { + tree fun = builtin_decl_explicit (BUILT_IN_STRCMP); + emit_library_call_value (XEXP (DECL_RTL (fun), 0), + target, LCT_NORMAL, GET_MODE (target), 2, + force_reg (Pmode, XEXP (src1, 0)), Pmode, + force_reg (Pmode, XEXP (src2, 0)), Pmode); + } else { /* -m32 -mpowerpc64 results in word_mode being DImode even @@ -19886,7 +19889,8 @@ expand_strn_compare (rtx operands[], int no_length) emit_move_insn (len_rtx, bytes_rtx); - emit_library_call_value (gen_rtx_SYMBOL_REF (Pmode, "strncmp"), + tree fun = builtin_decl_explicit (BUILT_IN_STRNCMP); + emit_library_call_value (XEXP (DECL_RTL (fun), 0), target, LCT_NORMAL, GET_MODE (target), 3, force_reg (Pmode, XEXP (src1, 0)), Pmode, force_reg (Pmode, XEXP (src2, 0)), Pmode, @@ -20131,10 +20135,13 @@ expand_strn_compare (rtx operands[], int no_length) /* Construct call to strcmp/strncmp to compare the rest of the string. */ if (no_length) - emit_library_call_value (gen_rtx_SYMBOL_REF (Pmode, "strcmp"), - target, LCT_NORMAL, GET_MODE (target), 2, - force_reg (Pmode, XEXP (src1, 0)), Pmode, - force_reg (Pmode, XEXP (src2, 0)), Pmode); + { + tree fun = builtin_decl_explicit (BUILT_IN_STRCMP); + emit_library_call_value (XEXP (DECL_RTL (fun), 0), + target, LCT_NORMAL, GET_MODE (target), 2, + force_reg (Pmode, XEXP (src1, 0)), Pmode, + force_reg (Pmode, XEXP (src2, 0)), Pmode); + } else { rtx len_rtx; @@ -20144,7 +20151,8 @@ expand_strn_compare (rtx operands[], int no_length) len_rtx = gen_reg_rtx (SImode); emit_move_insn (len_rtx, GEN_INT (bytes - compare_length)); - emit_library_call_value (gen_rtx_SYMBOL_REF (Pmode, "strncmp"), + tree fun = builtin_decl_explicit (BUILT_IN_STRNCMP); + emit_library_call_value (XEXP (DECL_RTL (fun), 0), target, LCT_NORMAL, GET_MODE (target), 3, force_reg (Pmode, XEXP (src1, 0)), Pmode, force_reg (Pmode, XEXP (src2, 0)), Pmode,