From patchwork Thu Apr 20 15:07:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 85934 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp406151vqo; Thu, 20 Apr 2023 08:08:05 -0700 (PDT) X-Google-Smtp-Source: AKy350bGBwsdndYauOPth7S9w6u09II2BjxF3u3cowqkaHqczI3YRDws7jd7RDdxDIAmAFDRDd8F X-Received: by 2002:a17:906:4bd4:b0:94f:8118:d74b with SMTP id x20-20020a1709064bd400b0094f8118d74bmr1935451ejv.40.1682003284948; Thu, 20 Apr 2023 08:08:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682003284; cv=none; d=google.com; s=arc-20160816; b=bfTzQS1R39nSCUcKmOKeTIRIv8tfTJyMJn4bCPKzPtXt3hIE4VHbiSMzQU7+HKNnLw AiT3lgZOVLFDbmdDPeIAMzN5uRKZHepXjKz7w0TzkUphnOWmaEvU/dgclgKxYoYoVzCP QKqDm7ZCBqyyK1iY7+Ctv0rWb1Ee/X1bfukXgzdXeIwPOeaIstA5JI3gl8pbXDpnSo8e ghFkbHozxSetjFYWdxKRQpPz22GK97e3YMa33dscZ0qo8VZ/V2Q/8vKC98G9M8HnCRMc WoQ7pkVMnG0mVymNJzN0cXJzm7FI60ii4kmLUInPKvYASJidiK1ij1TbaJOca0QZxpJP Xavw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:content-language :subject:to:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=OjfMyhB4LdgRMVUax/RTSmqnc65cM+hlozr0vsGKgN4=; b=JQlpjGRKjod+lw8XD7yyFxwLR6DYXx2QgWuPA+miFQNiJ4ZaqwhaASQeKa9CC9ExxP pH6UH5RGZat1uq13arwKlCYABd5c2IOK6VH0I/6r+o7yYEbVQqDJrF8hqdpLJnh/G4bl sm310BHw20wu3Ai1z5kyVIg7prdJDiKLBc6ePSBAlCEzT10hfdei8cFP6EscNmN7sXH/ E39ns5WFFSvEnZbbh9jFYG56ahDJ5HqN/C5QnGwUBJ1c+5juhE+27KB6R7d8AcfqJ/dF cEBPJq42HDvcTX4EQwMxn5m7WEpA2P503RP6dZm9bKahNRPPD3yBc3MF1+89+2IwNCIp 6PMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Im0hasIk; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id s2-20020a1709064d8200b00951ad746700si1676721eju.309.2023.04.20.08.08.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Apr 2023 08:08:04 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Im0hasIk; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 919063857711 for ; Thu, 20 Apr 2023 15:08:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 919063857711 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682003283; bh=OjfMyhB4LdgRMVUax/RTSmqnc65cM+hlozr0vsGKgN4=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Im0hasIkZiabQ8uuiSB33AFxTaOyTftYKo5e2aU8sK8mIGwFJ0Q38xIMHBdQxlJPr GI8O4gympfULdbPuAbgAkO8SwKICceQxNP9I0igIWReU72rADN3+YRVDY8h4j9FGvR 7WaMS/AazJiB9oArWqaWNbW5AiXrXga34m96E4Gg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id E67D93858C74 for ; Thu, 20 Apr 2023 15:07:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E67D93858C74 Received: from mail-il1-f198.google.com (mail-il1-f198.google.com [209.85.166.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-543-HyrZgO60MG6K0v-0UyAyAw-1; Thu, 20 Apr 2023 11:07:14 -0400 X-MC-Unique: HyrZgO60MG6K0v-0UyAyAw-1 Received: by mail-il1-f198.google.com with SMTP id e9e14a558f8ab-32b58d571a8so6880625ab.0 for ; Thu, 20 Apr 2023 08:07:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682003232; x=1684595232; h=subject:to:from:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JfNjN4dEdRSS8DBQEKYjTe9kNegORZ5a+tY6o1DOafY=; b=i0C/WlhOXjFBqr7V5j8/7MJdLIa4hPZrSDfUKZwjStsBAT0gSw2mOcU2ra6jtm+EH3 /XYMJlUK4WCOoXBQtlQWd8tdxOXhwuiiXajBs+tyZ/wkOnxlhu5DXYgpYSIiwfUwz3j2 zglORePpRx/Ye3pQaktReCxxQAAJyKwoorYvcDBM+bkP/7sdymZYiddiW+2BzwwlKjUI zpejPHSxUVH+LQON9s9xMQfQTZV/dKOlz6vRgkvWcTSlGiJy8qImprcoaSPB9n558u5R 4keBX5kz3AmY258POgGWM9ctroA4hdEyzMB5zz2sBsxTOubETnQdsePOQrQN4PX2FZrF cPoA== X-Gm-Message-State: AAQBX9f8FltNyLJjdxL2RXUciMeuyLjNxBtKITKbDAatkPrMMwohNhoE oxZR3Lq6puqLSg1bU+95AhK3OLfWybNDV6sZRLyqKAZVMJO1Zyk7OEN8JTTIFrUDcP78pNHFpCJ YRruNC9DHgmMug7edXMMO78uCeupUtw6Yz5+pFI6+FI5f6op2pms5UBME9Zp48iZe57PYW0eldu aOPA== X-Received: by 2002:a92:d6cc:0:b0:32c:c4d9:c756 with SMTP id z12-20020a92d6cc000000b0032cc4d9c756mr1405765ilp.12.1682003232494; Thu, 20 Apr 2023 08:07:12 -0700 (PDT) X-Received: by 2002:a92:d6cc:0:b0:32c:c4d9:c756 with SMTP id z12-20020a92d6cc000000b0032cc4d9c756mr1405735ilp.12.1682003232040; Thu, 20 Apr 2023 08:07:12 -0700 (PDT) Received: from [192.168.1.104] (192-0-143-139.cpe.teksavvy.com. [192.0.143.139]) by smtp.gmail.com with ESMTPSA id g6-20020a056e02130600b0032ca6a1d1bbsm475631ilr.72.2023.04.20.08.07.11 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 20 Apr 2023 08:07:11 -0700 (PDT) Message-ID: Date: Thu, 20 Apr 2023 11:07:10 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 To: "gcc-patches@gcc.gnu.org" Subject: [pushed] [LRA]: Exclude some hard regs for multi-reg inout reload pseudos used in asm in different mode X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Vladimir Makarov via Gcc-patches From: Vladimir Makarov Reply-To: Vladimir Makarov Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763708276388094923?= X-GMAIL-MSGID: =?utf-8?q?1763708276388094923?= The following patch fixes test failure of 20030222-1.c on moxie port.  But the problem can occur on other targets.  The patch actually implements the old reload approach for the test case. The patch was successfully tested and bootstrapped on x86-64, aarch64, and ppc64le. commit 51703ac3c722cd94011ab5b499921f6c9fe9fab5 Author: Vladimir N. Makarov Date: Thu Apr 20 10:02:13 2023 -0400 [LRA]: Exclude some hard regs for multi-reg inout reload pseudos used in asm in different mode See gcc.c-torture/execute/20030222-1.c. Consider the code for 32-bit (e.g. BE) target: int i, v; long x; x = v; asm ("" : "=r" (i) : "0" (x)); We generate the following RTL with reload insns: 1. subreg:si(x:di, 0) = 0; 2. subreg:si(x:di, 4) = v:si; 3. t:di = x:di, dead x; 4. asm ("" : "=r" (subreg:si(t:di,4)) : "0" (t:di)) 5. i:si = subreg:si(t:di,4); If we assign hard reg of x to t, dead code elimination will remove insn #2 and we will use unitialized hard reg. So exclude the hard reg of x for t. We could ignore this problem for non-empty asm using all x value but it is hard to check that the asm are expanded into insn realy using x and setting r. The old reload pass used the same approach. gcc/ChangeLog * lra-constraints.cc (match_reload): Exclude some hard regs for multi-reg inout reload pseudos used in asm in different mode. diff --git a/gcc/lra-constraints.cc b/gcc/lra-constraints.cc index b231cb60529..4dc2d70c402 100644 --- a/gcc/lra-constraints.cc +++ b/gcc/lra-constraints.cc @@ -1022,6 +1022,34 @@ match_reload (signed char out, signed char *ins, signed char *outs, are ordered. */ if (partial_subreg_p (outmode, inmode)) { + bool asm_p = asm_noperands (PATTERN (curr_insn)) >= 0; + int hr; + HARD_REG_SET temp_hard_reg_set; + + if (asm_p && (hr = get_hard_regno (out_rtx)) >= 0 + && hard_regno_nregs (hr, inmode) > 1) + { + /* See gcc.c-torture/execute/20030222-1.c. + Consider the code for 32-bit (e.g. BE) target: + int i, v; long x; x = v; asm ("" : "=r" (i) : "0" (x)); + We generate the following RTL with reload insns: + 1. subreg:si(x:di, 0) = 0; + 2. subreg:si(x:di, 4) = v:si; + 3. t:di = x:di, dead x; + 4. asm ("" : "=r" (subreg:si(t:di,4)) : "0" (t:di)) + 5. i:si = subreg:si(t:di,4); + If we assign hard reg of x to t, dead code elimination + will remove insn #2 and we will use unitialized hard reg. + So exclude the hard reg of x for t. We could ignore this + problem for non-empty asm using all x value but it is hard to + check that the asm are expanded into insn realy using x + and setting r. */ + CLEAR_HARD_REG_SET (temp_hard_reg_set); + if (exclude_start_hard_regs != NULL) + temp_hard_reg_set = *exclude_start_hard_regs; + SET_HARD_REG_BIT (temp_hard_reg_set, hr); + exclude_start_hard_regs = &temp_hard_reg_set; + } reg = new_in_reg = lra_create_new_reg_with_unique_value (inmode, in_rtx, goal_class, exclude_start_hard_regs,