Message ID | 1635241448-15298-1-git-send-email-apinski@marvell.com |
---|---|
State | Committed |
Commit | 997130f778c56466a825627644e510960585521b |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 506123858426 for <patchwork@sourceware.org>; Tue, 26 Oct 2021 09:45:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 506123858426 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1635241521; bh=o5qiFWz6AAEKa9rN/eWir59FtPtxhnVTL3AGigicZkc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=Iw6FGWtRKtvyZnTQdsMKLbKTmHLJAc1hKa4OMcvEudeMHBhz6mMZ6NPAHrla8scrV qK6T8lZG4TKQwz85akz9FywBaPmX3WaTVl13cz6xfRxQ8Fun8mxdsFI9EjrD4P5B3e Z77YQwSBiteSndae+X/hpwE9VwTd01WBVW4JyTTQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by sourceware.org (Postfix) with ESMTPS id 0E9083857C74 for <gcc-patches@gcc.gnu.org>; Tue, 26 Oct 2021 09:44:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0E9083857C74 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19Q5tmdn012639 for <gcc-patches@gcc.gnu.org>; Tue, 26 Oct 2021 02:44:20 -0700 Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com with ESMTP id 3bx4dx2brq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for <gcc-patches@gcc.gnu.org>; Tue, 26 Oct 2021 02:44:20 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 26 Oct 2021 02:44:18 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Tue, 26 Oct 2021 02:44:18 -0700 Received: from linux.wrightpinski.org.com (unknown [10.69.242.198]) by maili.marvell.com (Postfix) with ESMTP id 446933F709F; Tue, 26 Oct 2021 02:44:18 -0700 (PDT) To: <gcc-patches@gcc.gnu.org> Subject: [PATCH] target: [PR102941] Fix inline-asm flags with non-REG_P output Date: Tue, 26 Oct 2021 02:44:08 -0700 Message-ID: <1635241448-15298-1-git-send-email-apinski@marvell.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-GUID: 9J3U9gcHr4FNDyfIXGzK-MRB_j_f1wQb X-Proofpoint-ORIG-GUID: 9J3U9gcHr4FNDyfIXGzK-MRB_j_f1wQb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-10-26_02,2021-10-26_01,2020-04-07_01 X-Spam-Status: No, score=-14.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: apinski--- via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: apinski@marvell.com Cc: Andrew Pinski <apinski@marvell.com> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
target: [PR102941] Fix inline-asm flags with non-REG_P output
|
|
Commit Message
Li, Pan2 via Gcc-patches
Oct. 26, 2021, 9:44 a.m. UTC
From: Andrew Pinski <apinski@marvell.com>
So the problem here is that arm_md_asm_adjust would
just create a set directly to the output memory which is wrong.
It needs to output to a temp register first and then do a
move.
OK? Bootstrapped and tested on aarch64-linux-gnu with no regressions.
I have no way to test on arm even though this touches common code.
PR target/102941
gcc/ChangeLog:
* config/arm/aarch-common.c (arm_md_asm_adjust):
Use a temp if !REG_P.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/asm-flag-7.c: New test.
* gcc.target/arm/asm-flag-7.c: New test.
---
gcc/config/arm/aarch-common.c | 2 +-
gcc/testsuite/gcc.target/aarch64/asm-flag-7.c | 22 ++++++++++++++++++
gcc/testsuite/gcc.target/arm/asm-flag-7.c | 23 +++++++++++++++++++
3 files changed, 46 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.target/aarch64/asm-flag-7.c
create mode 100644 gcc/testsuite/gcc.target/arm/asm-flag-7.c
Comments
On Tue, Oct 26, 2021 at 2:45 AM apinski--- via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > From: Andrew Pinski <apinski@marvell.com> > > So the problem here is that arm_md_asm_adjust would > just create a set directly to the output memory which is wrong. > It needs to output to a temp register first and then do a > move. > > OK? Bootstrapped and tested on aarch64-linux-gnu with no regressions. > I have no way to test on arm even though this touches common code. Ping? > > PR target/102941 > > gcc/ChangeLog: > > * config/arm/aarch-common.c (arm_md_asm_adjust): > Use a temp if !REG_P. > > gcc/testsuite/ChangeLog: > > * gcc.target/aarch64/asm-flag-7.c: New test. > * gcc.target/arm/asm-flag-7.c: New test. > --- > gcc/config/arm/aarch-common.c | 2 +- > gcc/testsuite/gcc.target/aarch64/asm-flag-7.c | 22 ++++++++++++++++++ > gcc/testsuite/gcc.target/arm/asm-flag-7.c | 23 +++++++++++++++++++ > 3 files changed, 46 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gcc.target/aarch64/asm-flag-7.c > create mode 100644 gcc/testsuite/gcc.target/arm/asm-flag-7.c > > diff --git a/gcc/config/arm/aarch-common.c b/gcc/config/arm/aarch-common.c > index 67343fe4025..60b3516c1df 100644 > --- a/gcc/config/arm/aarch-common.c > +++ b/gcc/config/arm/aarch-common.c > @@ -641,7 +641,7 @@ arm_md_asm_adjust (vec<rtx> &outputs, vec<rtx> & /*inputs*/, > rtx x = gen_rtx_REG (mode, CC_REGNUM); > x = gen_rtx_fmt_ee (code, word_mode, x, const0_rtx); > > - if (dest_mode == word_mode) > + if (dest_mode == word_mode && REG_P (dest)) > emit_insn (gen_rtx_SET (dest, x)); > else > { > diff --git a/gcc/testsuite/gcc.target/aarch64/asm-flag-7.c b/gcc/testsuite/gcc.target/aarch64/asm-flag-7.c > new file mode 100644 > index 00000000000..6c31b854b0b > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/asm-flag-7.c > @@ -0,0 +1,22 @@ > +/* Test that "=@cc*" works with MEM_P RTX */ > +/* PR target/102941 */ > +/* { dg-do compile } */ > +/* { dg-options "-O" } */ > + > +#ifndef __GCC_ASM_FLAG_OUTPUTS__ > +#error "missing preprocessor define" > +#endif > +int test_cmpu_x; > + > +void f(long *); > +long > +test_cmpu_y() { > + long le; > + f(&le); > + __asm__("cmp %" > + "[x], %" > + "[y]" > + : "=@ccls"(le) > + : [x] ""(test_cmpu_x), [y] ""(test_cmpu_y)); > + return le; > +} > diff --git a/gcc/testsuite/gcc.target/arm/asm-flag-7.c b/gcc/testsuite/gcc.target/arm/asm-flag-7.c > new file mode 100644 > index 00000000000..ac11da0a3a8 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/arm/asm-flag-7.c > @@ -0,0 +1,23 @@ > +/* Test that "=@cc*" works with MEM_P RTX */ > +/* PR target/102941 */ > +/* { dg-do compile } */ > +/* { dg-options "-O" } */ > +/* { dg-skip-if "" { arm_thumb1 } } */ > + > +#ifndef __GCC_ASM_FLAG_OUTPUTS__ > +#error "missing preprocessor define" > +#endif > +int test_cmpu_x; > + > +void f(long *); > +long > +test_cmpu_y() { > + long le; > + f(&le); > + __asm__("cmp %" > + "[x], %" > + "[y]" > + : "=@ccls"(le) > + : [x] ""(test_cmpu_x), [y] ""(test_cmpu_y)); > + return le; > +} > -- > 2.17.1 >
On Thu, Dec 2, 2021 at 2:16 PM Andrew Pinski <pinskia@gmail.com> wrote: > > On Tue, Oct 26, 2021 at 2:45 AM apinski--- via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: > > > > From: Andrew Pinski <apinski@marvell.com> > > > > So the problem here is that arm_md_asm_adjust would > > just create a set directly to the output memory which is wrong. > > It needs to output to a temp register first and then do a > > move. > > > > OK? Bootstrapped and tested on aarch64-linux-gnu with no regressions. > > I have no way to test on arm even though this touches common code. > > Ping? Ping? Thanks, Andrew Pinski > > > > > PR target/102941 > > > > gcc/ChangeLog: > > > > * config/arm/aarch-common.c (arm_md_asm_adjust): > > Use a temp if !REG_P. > > > > gcc/testsuite/ChangeLog: > > > > * gcc.target/aarch64/asm-flag-7.c: New test. > > * gcc.target/arm/asm-flag-7.c: New test. > > --- > > gcc/config/arm/aarch-common.c | 2 +- > > gcc/testsuite/gcc.target/aarch64/asm-flag-7.c | 22 ++++++++++++++++++ > > gcc/testsuite/gcc.target/arm/asm-flag-7.c | 23 +++++++++++++++++++ > > 3 files changed, 46 insertions(+), 1 deletion(-) > > create mode 100644 gcc/testsuite/gcc.target/aarch64/asm-flag-7.c > > create mode 100644 gcc/testsuite/gcc.target/arm/asm-flag-7.c > > > > diff --git a/gcc/config/arm/aarch-common.c b/gcc/config/arm/aarch-common.c > > index 67343fe4025..60b3516c1df 100644 > > --- a/gcc/config/arm/aarch-common.c > > +++ b/gcc/config/arm/aarch-common.c > > @@ -641,7 +641,7 @@ arm_md_asm_adjust (vec<rtx> &outputs, vec<rtx> & /*inputs*/, > > rtx x = gen_rtx_REG (mode, CC_REGNUM); > > x = gen_rtx_fmt_ee (code, word_mode, x, const0_rtx); > > > > - if (dest_mode == word_mode) > > + if (dest_mode == word_mode && REG_P (dest)) > > emit_insn (gen_rtx_SET (dest, x)); > > else > > { > > diff --git a/gcc/testsuite/gcc.target/aarch64/asm-flag-7.c b/gcc/testsuite/gcc.target/aarch64/asm-flag-7.c > > new file mode 100644 > > index 00000000000..6c31b854b0b > > --- /dev/null > > +++ b/gcc/testsuite/gcc.target/aarch64/asm-flag-7.c > > @@ -0,0 +1,22 @@ > > +/* Test that "=@cc*" works with MEM_P RTX */ > > +/* PR target/102941 */ > > +/* { dg-do compile } */ > > +/* { dg-options "-O" } */ > > + > > +#ifndef __GCC_ASM_FLAG_OUTPUTS__ > > +#error "missing preprocessor define" > > +#endif > > +int test_cmpu_x; > > + > > +void f(long *); > > +long > > +test_cmpu_y() { > > + long le; > > + f(&le); > > + __asm__("cmp %" > > + "[x], %" > > + "[y]" > > + : "=@ccls"(le) > > + : [x] ""(test_cmpu_x), [y] ""(test_cmpu_y)); > > + return le; > > +} > > diff --git a/gcc/testsuite/gcc.target/arm/asm-flag-7.c b/gcc/testsuite/gcc.target/arm/asm-flag-7.c > > new file mode 100644 > > index 00000000000..ac11da0a3a8 > > --- /dev/null > > +++ b/gcc/testsuite/gcc.target/arm/asm-flag-7.c > > @@ -0,0 +1,23 @@ > > +/* Test that "=@cc*" works with MEM_P RTX */ > > +/* PR target/102941 */ > > +/* { dg-do compile } */ > > +/* { dg-options "-O" } */ > > +/* { dg-skip-if "" { arm_thumb1 } } */ > > + > > +#ifndef __GCC_ASM_FLAG_OUTPUTS__ > > +#error "missing preprocessor define" > > +#endif > > +int test_cmpu_x; > > + > > +void f(long *); > > +long > > +test_cmpu_y() { > > + long le; > > + f(&le); > > + __asm__("cmp %" > > + "[x], %" > > + "[y]" > > + : "=@ccls"(le) > > + : [x] ""(test_cmpu_x), [y] ""(test_cmpu_y)); > > + return le; > > +} > > -- > > 2.17.1 > >
apinski--- via Gcc-patches <gcc-patches@gcc.gnu.org> writes: > From: Andrew Pinski <apinski@marvell.com> > > So the problem here is that arm_md_asm_adjust would > just create a set directly to the output memory which is wrong. > It needs to output to a temp register first and then do a > move. > > OK? Bootstrapped and tested on aarch64-linux-gnu with no regressions. > I have no way to test on arm even though this touches common code. > > PR target/102941 > > gcc/ChangeLog: > > * config/arm/aarch-common.c (arm_md_asm_adjust): > Use a temp if !REG_P. > > gcc/testsuite/ChangeLog: > > * gcc.target/aarch64/asm-flag-7.c: New test. > * gcc.target/arm/asm-flag-7.c: New test. OK, thanks, and sorry for the delay. Richard > --- > gcc/config/arm/aarch-common.c | 2 +- > gcc/testsuite/gcc.target/aarch64/asm-flag-7.c | 22 ++++++++++++++++++ > gcc/testsuite/gcc.target/arm/asm-flag-7.c | 23 +++++++++++++++++++ > 3 files changed, 46 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gcc.target/aarch64/asm-flag-7.c > create mode 100644 gcc/testsuite/gcc.target/arm/asm-flag-7.c > > diff --git a/gcc/config/arm/aarch-common.c b/gcc/config/arm/aarch-common.c > index 67343fe4025..60b3516c1df 100644 > --- a/gcc/config/arm/aarch-common.c > +++ b/gcc/config/arm/aarch-common.c > @@ -641,7 +641,7 @@ arm_md_asm_adjust (vec<rtx> &outputs, vec<rtx> & /*inputs*/, > rtx x = gen_rtx_REG (mode, CC_REGNUM); > x = gen_rtx_fmt_ee (code, word_mode, x, const0_rtx); > > - if (dest_mode == word_mode) > + if (dest_mode == word_mode && REG_P (dest)) > emit_insn (gen_rtx_SET (dest, x)); > else > { > diff --git a/gcc/testsuite/gcc.target/aarch64/asm-flag-7.c b/gcc/testsuite/gcc.target/aarch64/asm-flag-7.c > new file mode 100644 > index 00000000000..6c31b854b0b > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/asm-flag-7.c > @@ -0,0 +1,22 @@ > +/* Test that "=@cc*" works with MEM_P RTX */ > +/* PR target/102941 */ > +/* { dg-do compile } */ > +/* { dg-options "-O" } */ > + > +#ifndef __GCC_ASM_FLAG_OUTPUTS__ > +#error "missing preprocessor define" > +#endif > +int test_cmpu_x; > + > +void f(long *); > +long > +test_cmpu_y() { > + long le; > + f(&le); > + __asm__("cmp %" > + "[x], %" > + "[y]" > + : "=@ccls"(le) > + : [x] ""(test_cmpu_x), [y] ""(test_cmpu_y)); > + return le; > +} > diff --git a/gcc/testsuite/gcc.target/arm/asm-flag-7.c b/gcc/testsuite/gcc.target/arm/asm-flag-7.c > new file mode 100644 > index 00000000000..ac11da0a3a8 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/arm/asm-flag-7.c > @@ -0,0 +1,23 @@ > +/* Test that "=@cc*" works with MEM_P RTX */ > +/* PR target/102941 */ > +/* { dg-do compile } */ > +/* { dg-options "-O" } */ > +/* { dg-skip-if "" { arm_thumb1 } } */ > + > +#ifndef __GCC_ASM_FLAG_OUTPUTS__ > +#error "missing preprocessor define" > +#endif > +int test_cmpu_x; > + > +void f(long *); > +long > +test_cmpu_y() { > + long le; > + f(&le); > + __asm__("cmp %" > + "[x], %" > + "[y]" > + : "=@ccls"(le) > + : [x] ""(test_cmpu_x), [y] ""(test_cmpu_y)); > + return le; > +}
diff --git a/gcc/config/arm/aarch-common.c b/gcc/config/arm/aarch-common.c index 67343fe4025..60b3516c1df 100644 --- a/gcc/config/arm/aarch-common.c +++ b/gcc/config/arm/aarch-common.c @@ -641,7 +641,7 @@ arm_md_asm_adjust (vec<rtx> &outputs, vec<rtx> & /*inputs*/, rtx x = gen_rtx_REG (mode, CC_REGNUM); x = gen_rtx_fmt_ee (code, word_mode, x, const0_rtx); - if (dest_mode == word_mode) + if (dest_mode == word_mode && REG_P (dest)) emit_insn (gen_rtx_SET (dest, x)); else { diff --git a/gcc/testsuite/gcc.target/aarch64/asm-flag-7.c b/gcc/testsuite/gcc.target/aarch64/asm-flag-7.c new file mode 100644 index 00000000000..6c31b854b0b --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/asm-flag-7.c @@ -0,0 +1,22 @@ +/* Test that "=@cc*" works with MEM_P RTX */ +/* PR target/102941 */ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +#ifndef __GCC_ASM_FLAG_OUTPUTS__ +#error "missing preprocessor define" +#endif +int test_cmpu_x; + +void f(long *); +long +test_cmpu_y() { + long le; + f(&le); + __asm__("cmp %" + "[x], %" + "[y]" + : "=@ccls"(le) + : [x] ""(test_cmpu_x), [y] ""(test_cmpu_y)); + return le; +} diff --git a/gcc/testsuite/gcc.target/arm/asm-flag-7.c b/gcc/testsuite/gcc.target/arm/asm-flag-7.c new file mode 100644 index 00000000000..ac11da0a3a8 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/asm-flag-7.c @@ -0,0 +1,23 @@ +/* Test that "=@cc*" works with MEM_P RTX */ +/* PR target/102941 */ +/* { dg-do compile } */ +/* { dg-options "-O" } */ +/* { dg-skip-if "" { arm_thumb1 } } */ + +#ifndef __GCC_ASM_FLAG_OUTPUTS__ +#error "missing preprocessor define" +#endif +int test_cmpu_x; + +void f(long *); +long +test_cmpu_y() { + long le; + f(&le); + __asm__("cmp %" + "[x], %" + "[y]" + : "=@ccls"(le) + : [x] ""(test_cmpu_x), [y] ""(test_cmpu_y)); + return le; +}