Message ID | 20230228050036.30601-1-mynameisxiaou@gmail.com |
---|---|
State | Repeat Merge |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2816388wrd; Mon, 27 Feb 2023 21:01:31 -0800 (PST) X-Google-Smtp-Source: AK7set+nPLtEOafUodr5fyIsTwEWzt3d4EDSzlOM9X9zYj9efM4oQ6ESTE1wtKQQMjqylv5DqTFy X-Received: by 2002:a17:906:9b89:b0:88e:e498:109b with SMTP id dd9-20020a1709069b8900b0088ee498109bmr1435192ejc.5.1677560491033; Mon, 27 Feb 2023 21:01:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677560491; cv=none; d=google.com; s=arc-20160816; b=omElKt4mvv7Z6F8LGQ+FbLW+7lSaHuZsnmtSv5akV5gQs4FK4gYiDtA+VOODIv07TS QLuLwUK3etN54YAUNZr4sFSJ0Lhj4inRBcAp1lFGphqe3XLlmdI2y2X+Xr9f3rF0RXWB aCw9smOlCjU7ngxnTpIRDLlGQBHbEPmsVi1nEMFtnUVMVt1q0wMDWPFR7uY22LdWM5ym p8NkvFrG9g0NOxORRrUgK3q8+5LPLqitNduVk1H9jBtm+RyfwCASCN304hX/oddXVZ2D S8ArhFCNqzBVs6Z7NYsotclwsTuZGv7B74bLxedXZAGPnjWWiJLCxI20OI5eKhGH8HHc hSXQ== 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-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=I8ZyVVtmi76lWT32gi8HpQy5eG1Jerem/qm7cQucuvo=; b=jpdYNHzYrOA0zsT3ZqA9GhGLtS8Xd6zhDZDwgERvvStpCocYV5rJ4ZLPNTe2JZccQv dYA9leu4CqdLPuLvlwEofYkmiUs89SpWBXZ+quf+m3oVYXMDSkBYlfZkUK8d+K/0YGTP R8Bor+5mGlvFkwolyCcAVGxZeQMwSBJ22Y09V/fYX2NYUWBgYHgLBSiOE7BsSnGzknmb JRXAUCn08mPinjtAdfsljRbtI5UzPvUC5aagfsbQVI6mE9ko+RZttQY+9Xu+ElR3xEOf hpZlnlFI8V0v1sOy6UapnMdo6Pxs+aBsTAR3hcBQXmIMYzvixKQYzr09bFuIf5v7Id80 o0IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ct4f7cOe; 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 v25-20020a1709060b5900b008ec437119f4si304937ejg.332.2023.02.27.21.01.30 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 21:01:31 -0800 (PST) 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=ct4f7cOe; 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 C34163858407 for <ouuuleilei@gmail.com>; Tue, 28 Feb 2023 05:01:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C34163858407 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677560489; bh=I8ZyVVtmi76lWT32gi8HpQy5eG1Jerem/qm7cQucuvo=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=ct4f7cOeYS1rTB2Wnm0zJTLrZ5cA9Q6NloVTnwPVtjEsh5wvzVYdiv7xF39kAbiGt U0SwDcXK4yquMfIWLam4n2DXWolMzxLV/x6a1f7BtsOb4yzH/m1Yrtfj9BQFcfbls+ KcNG/YfRlU8Y0i8vpVrEajJp9P4npmd/RCrr+1qk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by sourceware.org (Postfix) with ESMTPS id 8D58C3858D39 for <gcc-patches@gcc.gnu.org>; Tue, 28 Feb 2023 05:00:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8D58C3858D39 Received: by mail-pj1-x1029.google.com with SMTP id u3-20020a17090a450300b00239db6d7d47so1315694pjg.4 for <gcc-patches@gcc.gnu.org>; Mon, 27 Feb 2023 21:00:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=I8ZyVVtmi76lWT32gi8HpQy5eG1Jerem/qm7cQucuvo=; b=AeRTJ85txGS1zkojSGjuXWnYE/u+aH3twD1a3QYzWMNns/HlrTlQqLRqyR9jIKSV+1 ToHVepW/d8Mz8mKsj+eEiaGpxWzy9xi7k663vwd8jFdB+KbOmLoIOKKlJSAMaWiQ6mZb 840U2VZgLyM4PDewiK+MSGaIf86S8euoZJ7drZWnQLo8FQrb5FsdYt2MSjNdle4gfy6a wBrLNw/dk2NKBHjuu3D7BnW9SRKLsyMoTFU5Hb4B/I0jZpVQlJClfngzUNPCJJEjwpdA nIma+xQq08llTYcECGY9RjzidQq7u7/TksLTb2OlYaCFLjUrt93WkSxHCbZ8hqe4g5R3 vzEw== X-Gm-Message-State: AO0yUKVdjxtm1vy1I7jJOMSQ68qJVJz4k36TzKj2N/opebXt7onWwY6Z vxBy8HXkLcUEOE+ZxYM4PGe6GXUh0T5ueJOjyhj5mA== X-Received: by 2002:a17:90a:7b8b:b0:234:289d:5e69 with SMTP id z11-20020a17090a7b8b00b00234289d5e69mr1352817pjc.2.1677560444263; Mon, 27 Feb 2023 21:00:44 -0800 (PST) Received: from localhost.localdomain ([47.246.101.59]) by smtp.gmail.com with ESMTPSA id g2-20020a170902868200b0019a5aa7eab0sm5418821plo.54.2023.02.27.21.00.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 21:00:43 -0800 (PST) To: gcc-patches@gcc.gnu.org Cc: philipp.tomsich@vrull.eu, kito.cheng@gmail.com, palmer@dabbelt.com, andrew@sifive.com, Lin Sinan <sinan.lin@linux.alibaba.com> Subject: [PATCH] RISC-V: Fix wrong partial subreg check for bsetidisi Date: Tue, 28 Feb 2023 13:00:36 +0800 Message-Id: <20230228050036.30601-1-mynameisxiaou@gmail.com> X-Mailer: git-send-email 2.36.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Lin Sinan via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Lin Sinan <mynameisxiaou@gmail.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759049669515457898?= X-GMAIL-MSGID: =?utf-8?q?1759049669515457898?= |
Series |
RISC-V: Fix wrong partial subreg check for bsetidisi
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | warning | Git am fail log |
Commit Message
Lin Sinan
Feb. 28, 2023, 5 a.m. UTC
From: Lin Sinan <sinan.lin@linux.alibaba.com>
The partial subreg check should be for subreg operand(operand 1) instead of
the immediate operand(operand 2). This change also fix pr68648.c in zbs.
gcc/ChangeLog:
* config/riscv/bitmanip.md: Fix wrong index in the check.
---
gcc/config/riscv/bitmanip.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
I encountered a miscompilation case with zbs, where bseti without sign extension emitted from bsetidisi pattern leads to wrong output. Take pr68648.c as an example, -march=rv64gc_zba_zbb_zbs -O3 did not generate sext.w in int bar (void) and led to a wrong value in a0. It seems that the partial subreg check is wrongly set to the immediate operand. int foo (void): li a0,123 ret int bar (void): addi sp,sp,-16 sd ra,8(sp) call foo # a0 123 li a5,248639488 # a0 123, a5 0xed1f000 addi a5,a5,11 # a0 123, a5 0xed1f00b slli a5,a5,14 # a0 123, a5 0x3b47c02c000 addi a5,a5,-8 # a0 123, a5 0x3b47c02bff8 ld ra,8(sp) or a0,a0,a5 # a0 0x3b47c02bffb, a5 0x3b47c02bff8 bseti a5,zero,32 # a0 0x3b47c02bffb, a5 0x100000000 addi a5,a5,-1 # a0 0x3b47c02bffb, a5 0x0ffffffff xor a0,a0,a5 # a0 0x3b483fd4004, a5 0x0ffffffff bseti a0,a0,0 # a0 0x3b483fd4005, a5 0x0ffffffff addi sp,sp,16 # sext.w a0,a0 is missing jr ra main: addi sp,sp,-16 sd ra,8(sp) call bar li a5,-2080555008 addi a5,a5,5 bne a0,a5,.L8 # a0 0x3b483fd4005, a5 0x83fd4005 ld ra,8(sp) li a0,0 addi sp,sp,16 jr ra .L8: call abort Lin Sinan <mynameisxiaou@gmail.com> 于2023年2月28日周二 13:00写道: > From: Lin Sinan <sinan.lin@linux.alibaba.com> > > The partial subreg check should be for subreg operand(operand 1) instead of > the immediate operand(operand 2). This change also fix pr68648.c in zbs. > > gcc/ChangeLog: > > * config/riscv/bitmanip.md: Fix wrong index in the check. > > --- > gcc/config/riscv/bitmanip.md | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/gcc/config/riscv/bitmanip.md b/gcc/config/riscv/bitmanip.md > index 14d18edbe62..58a86bd929f 100644 > --- a/gcc/config/riscv/bitmanip.md > +++ b/gcc/config/riscv/bitmanip.md > @@ -442,7 +442,7 @@ > (ior:DI (sign_extend:DI (match_operand:SI 1 "register_operand" > "r")) > (match_operand 2 "single_bit_mask_operand" "i")))] > "TARGET_ZBS && TARGET_64BIT > - && !partial_subreg_p (operands[2])" > + && !partial_subreg_p (operands[1])" > "bseti\t%0,%1,%S2" > [(set_attr "type" "bitmanip")]) > > -- > 2.34.1 > >
On Tue, 28 Feb 2023 at 06:00, Lin Sinan <mynameisxiaou@gmail.com> wrote: > > From: Lin Sinan <sinan.lin@linux.alibaba.com> > > The partial subreg check should be for subreg operand(operand 1) instead of > the immediate operand(operand 2). This change also fix pr68648.c in zbs. Good catch. Reviewed-by: <philipp.tomsich@vrull.eu>
Committed, thanks! On Tue, Feb 28, 2023 at 5:32 PM Philipp Tomsich <philipp.tomsich@vrull.eu> wrote: > > On Tue, 28 Feb 2023 at 06:00, Lin Sinan <mynameisxiaou@gmail.com> wrote: > > > > From: Lin Sinan <sinan.lin@linux.alibaba.com> > > > > The partial subreg check should be for subreg operand(operand 1) instead of > > the immediate operand(operand 2). This change also fix pr68648.c in zbs. > > Good catch. > Reviewed-by: <philipp.tomsich@vrull.eu>
diff --git a/gcc/config/riscv/bitmanip.md b/gcc/config/riscv/bitmanip.md index 14d18edbe62..58a86bd929f 100644 --- a/gcc/config/riscv/bitmanip.md +++ b/gcc/config/riscv/bitmanip.md @@ -442,7 +442,7 @@ (ior:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "r")) (match_operand 2 "single_bit_mask_operand" "i")))] "TARGET_ZBS && TARGET_64BIT - && !partial_subreg_p (operands[2])" + && !partial_subreg_p (operands[1])" "bseti\t%0,%1,%S2" [(set_attr "type" "bitmanip")])