From patchwork Wed Jul 11 20:07:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Steve Ellcey X-Patchwork-Id: 942694 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-481382-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=cavium.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="kKV+SjYs"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=CAVIUMNETWORKS.onmicrosoft.com header.i=@CAVIUMNETWORKS.onmicrosoft.com header.b="KhAZ2c+k"; dkim-atps=neutral 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 41QqqQ2RJdz9s01 for ; Thu, 12 Jul 2018 06:07:29 +1000 (AEST) 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:reply-to:to:date:content-type :mime-version:content-transfer-encoding; q=dns; s=default; b=oej ujXZbktBs1XQIw2j1xU+bpJ6uAF6/b7BobU5drXeN+RHrXr3s7wiJ7t4azIsQsKc U8SPrey4Jum/yDap/KksrafJhVbwyYKwL347LP8jKstbVktPIctJs077hgKclXv5 HvFMvrrijpNHBLbXY/TlIXFTcYIpSis23dRGvJ1U= 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:reply-to:to:date:content-type :mime-version:content-transfer-encoding; s=default; bh=sGgycVdTF 645wUUkFqceICPlvSU=; b=kKV+SjYs2m4u69W9L58tAnMSaBE45wnugbg4BylSu 2wotJhFbuuM/o89XI5A6NjUNTSEzrLRRFNdWReqU2uMjwNDOec0wF1pP10SAN4ow GQXuBZgNRf5dHqAwqcYFQNOALntz7a3aVdgsavnBNlWnCjerl3rMY/+8a9MbarKC +I= Received: (qmail 2882 invoked by alias); 11 Jul 2018 20:07:22 -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 2873 invoked by uid 89); 11 Jul 2018 20:07:21 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: =?iso-8859-1?q?No=2C_score=3D-25=2E2_required=3D5=2E?= =?iso-8859-1?q?0_tests=3DAWL=2CBAYES_00=2CGIT_PATCH_0=2CGIT_PATCH_?= =?iso-8859-1?q?1=2CGIT_PATCH_2=2CGIT_PATCH_3=2CKAM_SHORT=2CRCVD_IN?= =?iso-8859-1?q?_DNSWL_NONE=2CSPF_HELO_PASS=2CSPF_PASS_autolearn=3D?= =?iso-8859-1?q?ham_version=3D3=2E3=2E2_spammy=3Dnot=2C_ditto=2C_Di?= =?iso-8859-1?q?tto=2C_calls=2E=C2?= X-HELO: NAM01-BY2-obe.outbound.protection.outlook.com Received: from mail-by2nam01on0087.outbound.protection.outlook.com (HELO NAM01-BY2-obe.outbound.protection.outlook.com) (104.47.34.87) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Jul 2018 20:07:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kqXVw7EkG83MgtK1eKRAHeCsB9Zj1kcmIoC1lDqDIoo=; b=KhAZ2c+k74FlroKYqhL5qL6F1UwrumWjBc4rZE400Q3RPW8gHag1q8Peh6SlK+Nrc4hsCYCDGmEC1JhVS9pVUZKmrB+w3T30Z9KUSozE9foHCNMTXwUhuTmldcGIqigZ0GOEjfX/ef/kJ5TM2p7qySA5TWEjAdUldwX0GvUjCJ0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Steve.Ellcey@cavium.com; Received: from sellcey-dt.caveonetworks.com (50.233.148.155) by BYAPR07MB5031.namprd07.prod.outlook.com (2603:10b6:a03:5b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.930.20; Wed, 11 Jul 2018 20:07:16 +0000 Message-ID: <1531339634.31833.51.camel@cavium.com> Subject: RFC: lra-constraints.c and TARGET_HARD_REGNO_CALL_PART_CLOBBERED question/patch From: Steve Ellcey Reply-To: sellcey@cavium.com To: gcc-patches Date: Wed, 11 Jul 2018 13:07:14 -0700 Mime-Version: 1.0 Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) I have a reload/register allocation question and possible patch.  While working on the Aarch64 SIMD ABI[1] I ran into a problem where GCC was saving and restoring registers that it did not need to.  I tracked it down to lra-constraints.c and its use of targetm.hard_regno_call_part_clobbered on instructions that are not calls.  Specifically need_for_call_save_p would check this macro even when the instruction in question (unknown to need_for_call_save_p) was not a call instruction. This seems wrong to me and I was wondering if anyone more familiar with the register allocator and reload could look at this patch and tell me if it seems reasonable or not.  It passed bootstrap and I am running tests now. I am just wondering if there is any reason why this target function would need to be called on non-call instructions or if doing so is just an oversight/bug. Steve Ellcey sellcey@cavium.com [1] https://gcc.gnu.org/ml/gcc/2018-07/msg00012.html 2018-07-11  Steve Ellcey   * lra-constraints.c (need_for_call_save_p): Add insn argument and only check targetm.hard_regno_call_part_clobbered on calls. (need_for_split_p): Add insn argument, pass to need_for_call_save_p. (split_reg): Pass insn to need_for_call_save_p. (split_if_necessary): Pass curr_insn to need_for_split_p. (inherit_in_ebb): Ditto. diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c index 7eeec76..7fc8e7f 100644 --- a/gcc/lra-constraints.c +++ b/gcc/lra-constraints.c @@ -5344,7 +5344,7 @@ inherit_reload_reg (bool def_p, int original_regno,  /* Return true if we need a caller save/restore for pseudo REGNO which     was assigned to a hard register.  */  static inline bool -need_for_call_save_p (int regno) +need_for_call_save_p (int regno, rtx_insn *insn)  {    lra_assert (regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] >= 0);    return (usage_insns[regno].calls_num < calls_num @@ -5354,7 +5354,7 @@ need_for_call_save_p (int regno)          ? lra_reg_info[regno].actual_call_used_reg_set          : call_used_reg_set,          PSEUDO_REGNO_MODE (regno), reg_renumber[regno]) -       || (targetm.hard_regno_call_part_clobbered +       || (CALL_P (insn) && targetm.hard_regno_call_part_clobbered     (reg_renumber[regno], PSEUDO_REGNO_MODE (regno)))));  }   @@ -5374,7 +5374,8 @@ static bitmap_head ebb_global_regs;     assignment pass because of too many generated moves which will be     probably removed in the undo pass.  */  static inline bool -need_for_split_p (HARD_REG_SET potential_reload_hard_regs, int regno) +need_for_split_p (HARD_REG_SET potential_reload_hard_regs, +   int regno, rtx_insn *insn)  {    int hard_regno = regno < FIRST_PSEUDO_REGISTER ? regno : reg_renumber[regno];   @@ -5416,7 +5417,8 @@ need_for_split_p (HARD_REG_SET potential_reload_hard_regs, int regno)          || (regno >= FIRST_PSEUDO_REGISTER      && lra_reg_info[regno].nrefs > 3      && bitmap_bit_p (&ebb_global_regs, regno)))) -   || (regno >= FIRST_PSEUDO_REGISTER && need_for_call_save_p (regno))); +   || (regno >= FIRST_PSEUDO_REGISTER +       && need_for_call_save_p (regno, insn)));  }    /* Return class for the split pseudo created from original pseudo with @@ -5536,7 +5538,7 @@ split_reg (bool before_p, int original_regno, rtx_insn *insn,        nregs = hard_regno_nregs (hard_regno, mode);        rclass = lra_get_allocno_class (original_regno);        original_reg = regno_reg_rtx[original_regno]; -      call_save_p = need_for_call_save_p (original_regno); +      call_save_p = need_for_call_save_p (original_regno, insn);      }    lra_assert (hard_regno >= 0);    if (lra_dump_file != NULL) @@ -5759,7 +5761,7 @@ split_if_necessary (int regno, machine_mode mode,        && INSN_UID (next_usage_insns) < max_uid)       || (GET_CODE (next_usage_insns) == INSN_LIST   && (INSN_UID (XEXP (next_usage_insns, 0)) < max_uid))) - && need_for_split_p (potential_reload_hard_regs, regno + i) + && need_for_split_p (potential_reload_hard_regs, regno + i, insn)   && split_reg (before_p, regno + i, insn, next_usage_insns, NULL))      res = true;    return res; @@ -6529,7 +6531,8 @@ inherit_in_ebb (rtx_insn *head, rtx_insn *tail)     && usage_insns[j].check == curr_usage_insns_check     && (next_usage_insns = usage_insns[j].insns) != NULL_RTX)   { -   if (need_for_split_p (potential_reload_hard_regs, j)) +   if (need_for_split_p (potential_reload_hard_regs, j, + curr_insn))       {         if (lra_dump_file != NULL && head_p)   {