From patchwork Sun Nov 12 12:08:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lehua Ding X-Patchwork-Id: 164250 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp660059vqg; Sun, 12 Nov 2023 04:10:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IHunYFsp86B6OxRjmr+Jt8n8nisL4MLfP8jiPEnyi2QUtKsEHSQSZszRz/cpNtTuqcLcS8N X-Received: by 2002:a05:6870:a792:b0:1f4:e209:a7ea with SMTP id x18-20020a056870a79200b001f4e209a7eamr3511818oao.42.1699791028393; Sun, 12 Nov 2023 04:10:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699791028; cv=pass; d=google.com; s=arc-20160816; b=muoItCiqNcn6qv9oYfFHmxHtrOcYmpqWRuqJhSPiy7GZdTR+yIH6bZJ40yHgYpywL1 yxhgi49xo+hGk3qnhZ0G9ErWyZIXtgZPteiXhiPmkYfEVCeEg6FIyVmZl8cau+gNhRuC T5FguBg4X1cKJb32uwLUNrYzpSLBOXNdNDfSpLwSPgveEL/6BgDD3Ae4UeIoy3Z8Q/WO JqGWCQ4RgdXx1CvvBYw5JYz0xEeF7Puj+J9uqLnogCtX1XxHeTNKWLh0gjEz14k3+Wsp BOgLZduu4K7LKlRg5SiCJ5VfDg8GId+mCZR2hT26odDpbB4GDTOWMzIm5XoFLle9YcRH LmyQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:feedback-id :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-filter:dmarc-filter :delivered-to; bh=i+9efPhpHu8/a1AVWASoq9hwk8svFe7BGqJNx2WnVvM=; fh=9Ok8HNl3eD0lUFF4nhUPZJmQfyAUbHnIPw/rSVNIfK0=; b=pRaA6AvgqZaSh2Fo73wNhJqN1wAN4XfTgBsWi0vtXJHVkx2Mb1XkDInNhFeT/nG9ir ZQ+m3VRY8mGPjZZda03P4vy9Iv0u44RE5Nr5/3yxustbC2i8XSeE6VJ1TQh55Bqw60j2 OdNWkCZxCNeOykHyHbYzWpEfmO37wdwQJ3lTpD2yhkB0UM5l+CYKN1QgV1B4rmP3V3k1 tUiSw8h0oJirin2ENDFbyJ1I+2QfTXOn6tGRHPlLmqrBWA2FBIckEPfj24n89qt+7HYE 7Up4VtGuXmrk5g/jV2HvDnQBnhgPfd05+Vie2xIZwD442rHdUNAvDq7d71uWtI9qVI2Q XrmQ== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id i6-20020ac85c06000000b00418051c660esi2860202qti.625.2023.11.12.04.10.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Nov 2023 04:10:28 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 23D3E3858C2D for ; Sun, 12 Nov 2023 12:10:28 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbgbr1.qq.com (smtpbgbr1.qq.com [54.207.19.206]) by sourceware.org (Postfix) with ESMTPS id 31CEB3857712 for ; Sun, 12 Nov 2023 12:08:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 31CEB3857712 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivai.ai Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivai.ai ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 31CEB3857712 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=54.207.19.206 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699790926; cv=none; b=U2ZHDn0UkTPCTCyO9CUv1vo0YulvDBlcRLq1XkhLWEt2hRZ9u4l6Go6knoR69ZzQvmCSzjav/HgoDObOntFd0vL7+uPtojkYjZjl7V5FR4uuTSr7tvRBlQZHzYKFaKHZ5kmu7YWWtBpIHV1+6Qfna71crCzBeYsOC4OuROS7ibM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699790926; c=relaxed/simple; bh=iye3d0n9sW9N+o9/WQbNWrWNkyaFoca8WiFpbabmWZE=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=AWdAU6/lBbSjWvTYaJG7IxMoOzwTptqgBhqFlkR5aU4FwLk8nrAFjzwiegY84HYU247GKFkCJGXlxi1MLBNkKWHh3r3tRuHe7vR0hL2L+6ae64+agygpC2Us3aUQTsnUdc9NUPjRnouZIusf2kRMxJlChCWfmjS0twuUgG6x4U4= ARC-Authentication-Results: i=1; server2.sourceware.org X-QQ-mid: bizesmtp67t1699790916tc5ifm63 Received: from rios-cad121.hadoop.rioslab.org ( [58.60.1.9]) by bizesmtp.qq.com (ESMTP) with id ; Sun, 12 Nov 2023 20:08:35 +0800 (CST) X-QQ-SSF: 01400000000000C0F000000A0000000 X-QQ-FEAT: PS/N6jJLnDYW5FxtN8gzZMPPVpAu2OeE+X/r7tSYewqaVs1gzVWDmGUSPb0VJ w8Tvj3PD8/dzdylAR8fQEbyyUe3PRY78E9XRUNG3+h7OYCNwKUCM/Wz2ciFksYkQ4HiGnHi Kw37xMbfZAZOWYEOazW1iSJQiW3XA5SrxX6nPtRuGJ1vRpLY6fq0H82bF1XrZ34o1MPP3Lh picYINuwtLGWRs9UJ+ODVZRgZ65JXfYxugJ6YswQBvgFsdDlk5JAWeG7FjA0n2vTIQeFc90 9QTS/9rjAVONZVR7sF5rkH4Tc5MD5Hky71P9ZhS4Zqw0NeLX7kQ60dKfCTgLgN/vce3KAb+ 2JqvVo+MsF599xDQ0waMHIRMW3vNris/8jSsM+a1uqpDqGQCEaNq0tSTAt+TCj65e3e+Uyh 6ATH11KuVDY= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 5641370456946283451 From: Lehua Ding To: gcc-patches@gcc.gnu.org Cc: vmakarov@redhat.com, richard.sandiford@arm.com, juzhe.zhong@rivai.ai, lehua.ding@rivai.ai Subject: [PATCH V3 5/7] ira: Add all nregs >= 2 pseudos to tracke subreg list Date: Sun, 12 Nov 2023 20:08:15 +0800 Message-Id: <20231112120817.2635864-6-lehua.ding@rivai.ai> X-Mailer: git-send-email 2.36.3 In-Reply-To: <20231112120817.2635864-1-lehua.ding@rivai.ai> References: <20231112120817.2635864-1-lehua.ding@rivai.ai> MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:rivai.ai:qybglogicsvrgz:qybglogicsvrgz6a-0 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782360077610425018 X-GMAIL-MSGID: 1782360077610425018 This patch relax the subreg track capability to all subreg registers. gcc/ChangeLog: * ira-build.cc (get_reg_unit_size): New. (has_same_nregs): New. (ira_set_allocno_class): Adjust. --- gcc/ira-build.cc | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/gcc/ira-build.cc b/gcc/ira-build.cc index 13f0f7336ed..f88aeeeeaef 100644 --- a/gcc/ira-build.cc +++ b/gcc/ira-build.cc @@ -607,6 +607,37 @@ ira_create_allocno (int regno, bool cap_p, return a; } +/* Return single register size of allocno A. */ +static poly_int64 +get_reg_unit_size (ira_allocno_t a) +{ + enum reg_class aclass = ALLOCNO_CLASS (a); + gcc_assert (aclass != NO_REGS); + machine_mode mode = ALLOCNO_MODE (a); + int nregs = ALLOCNO_NREGS (a); + poly_int64 block_size = REGMODE_NATURAL_SIZE (mode); + int nblocks = get_nblocks (mode); + gcc_assert (nblocks % nregs == 0); + return block_size * (nblocks / nregs); +} + +/* Return true if TARGET_CLASS_MAX_NREGS and TARGET_HARD_REGNO_NREGS results is + same. It should be noted that some targets may not implement these two very + uniformly, and need to be debugged step by step. For example, in V3x1DI mode + in AArch64, TARGET_CLASS_MAX_NREGS returns 2 but TARGET_HARD_REGNO_NREGS + returns 3. They are in conflict and need to be repaired in the Hook of + AArch64. */ +static bool +has_same_nregs (ira_allocno_t a) +{ + for (int i = 0; i < FIRST_PSEUDO_REGISTER; i++) + if (REGNO_REG_CLASS (i) != NO_REGS + && reg_class_subset_p (REGNO_REG_CLASS (i), ALLOCNO_CLASS (a)) + && ALLOCNO_NREGS (a) != hard_regno_nregs (i, ALLOCNO_MODE (a))) + return false; + return true; +} + /* Set up register class for A and update its conflict hard registers. */ void @@ -624,12 +655,12 @@ ira_set_allocno_class (ira_allocno_t a, enum reg_class aclass) if (aclass == NO_REGS) return; - /* SET the unit_size of one register. */ - machine_mode mode = ALLOCNO_MODE (a); - int nregs = ira_reg_class_max_nregs[aclass][mode]; - if (nregs == 2 && maybe_eq (GET_MODE_SIZE (mode), nregs * UNITS_PER_WORD)) + gcc_assert (!ALLOCNO_TRACK_SUBREG_P (a)); + /* Set unit size and track_subreg_p flag for pseudo which need occupied multi + hard regs. */ + if (ALLOCNO_NREGS (a) > 1 && has_same_nregs (a)) { - ALLOCNO_UNIT_SIZE (a) = UNITS_PER_WORD; + ALLOCNO_UNIT_SIZE (a) = get_reg_unit_size (a); ALLOCNO_TRACK_SUBREG_P (a) = true; return; }