public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH v2] RISC-V: Make xtheadcondmov-indirect tests robust against instruction reordering
@ 2023-10-12 13:06 Christoph Muellner
  2023-10-12 16:12 ` Jeff Law
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Muellner @ 2023-10-12 13:06 UTC (permalink / raw)
  To: gcc-patches, Kito Cheng, Jim Wilson, Palmer Dabbelt,
	Andrew Waterman, Philipp Tomsich, Jeff Law, Patrick O'Neill,
	Vineet Gupta
  Cc: Christoph Müllner

From: Christoph Müllner <christoph.muellner@vrull.eu>

Fixes: c1bc7513b1d7 ("RISC-V: const: hide mvconst splitter from IRA")

A recent change broke the xtheadcondmov-indirect tests, because the order of
emitted instructions changed. Since the test is too strict when testing for
a fixed instruction order, let's change the tests to simply count instruction,
like it is done for similar tests.

Reported-by: Patrick O'Neill <patrick@rivosinc.com>
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/xtheadcondmov-indirect.c: Make robust against
	instruction reordering.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
---
 .../gcc.target/riscv/xtheadcondmov-indirect.c | 89 ++++++-------------
 1 file changed, 29 insertions(+), 60 deletions(-)

diff --git a/gcc/testsuite/gcc.target/riscv/xtheadcondmov-indirect.c b/gcc/testsuite/gcc.target/riscv/xtheadcondmov-indirect.c
index c3253ba5239..427c9c1a41e 100644
--- a/gcc/testsuite/gcc.target/riscv/xtheadcondmov-indirect.c
+++ b/gcc/testsuite/gcc.target/riscv/xtheadcondmov-indirect.c
@@ -1,16 +1,11 @@
 /* { dg-do compile } */
-/* { dg-options "-march=rv32gc_xtheadcondmov -fno-sched-pressure" { target { rv32 } } } */
-/* { dg-options "-march=rv64gc_xtheadcondmov -fno-sched-pressure" { target { rv64 } } } */
+/* { dg-options "-march=rv32gc_xtheadcondmov" { target { rv32 } } } */
+/* { dg-options "-march=rv64gc_xtheadcondmov" { target { rv64 } } } */
 /* { dg-skip-if "" { *-*-* } {"-O0" "-Os" "-Og" "-Oz" "-flto" } } */
-/* { dg-final { check-function-bodies "**" "" } } */
 
-/*
-** ConEmv_imm_imm_reg:
-**	addi	a[0-9]+,a[0-9]+,-1000
-**	li	a[0-9]+,10
-**	th\.mvnez	a[0-9]+,a[0-9]+,a[0-9]+
-**	ret
-*/
+/* addi aX, aX, -1000
+   li aX, 10
+   th.mvnez aX, aX, aX  */
 int ConEmv_imm_imm_reg(int x, int y)
 {
   if (x == 1000)
@@ -18,13 +13,8 @@ int ConEmv_imm_imm_reg(int x, int y)
   return y;
 }
 
-/*
-** ConEmv_imm_reg_reg:
-**	addi	a[0-9]+,a[0-9]+,-1000
-**	th.mveqz	a[0-9]+,a[0-9]+,a[0-9]+
-**	mv	a[0-9]+,a[0-9]+
-**	ret
-*/
+/* addi	aX, aX, -1000
+   th.mveqz aX, aX, aX  */
 int ConEmv_imm_reg_reg(int x, int y, int z)
 {
   if (x == 1000)
@@ -32,13 +22,9 @@ int ConEmv_imm_reg_reg(int x, int y, int z)
   return z;
 }
 
-/*
-** ConEmv_reg_imm_reg:
-**	sub	a[0-9]+,a[0-9]+,a[0-9]+
-**	li	a[0-9]+,10
-**	th.mvnez	a[0-9]+,a[0-9]+,a[0-9]+
-**	ret
-*/
+/* sub aX, aX, aX
+   li aX, 10
+   th.mvnez aX, aX, aX  */
 int ConEmv_reg_imm_reg(int x, int y, int z)
 {
   if (x == y)
@@ -46,13 +32,8 @@ int ConEmv_reg_imm_reg(int x, int y, int z)
   return z;
 }
 
-/*
-** ConEmv_reg_reg_reg:
-**	sub	a[0-9]+,a[0-9]+,a[0-9]+
-**	th.mveqz	a[0-9]+,a[0-9]+,a[0-9]+
-**	mv	a[0-9]+,a[0-9]+
-**	ret
-*/
+/* sub aX, aX, aX
+   th.mveqz aX, aX, aX  */
 int ConEmv_reg_reg_reg(int x, int y, int z, int n)
 {
   if (x == y)
@@ -60,14 +41,10 @@ int ConEmv_reg_reg_reg(int x, int y, int z, int n)
   return n;
 }
 
-/*
-** ConNmv_imm_imm_reg:
-**	addi	a[0-9]+,a[0-9]+,-1000+
-**	li	a[0-9]+,9998336+
-**	addi	a[0-9]+,a[0-9]+,1664+
-**	th.mveqz	a[0-9]+,a[0-9]+,a[0-9]+
-**	ret
-*/
+/* addi aX, aX, -1000
+   li aX, 9998336
+   addi aX, aX, 1664
+   th.mveqz aX, aX, aX  */
 int ConNmv_imm_imm_reg(int x, int y)
 {
   if (x != 1000)
@@ -75,13 +52,8 @@ int ConNmv_imm_imm_reg(int x, int y)
   return y;
 }
 
-/*
-**ConNmv_imm_reg_reg:
-**	addi	a[0-9]+,a[0-9]+,-1000+
-**	th.mvnez	a[0-9]+,a[0-9]+,a[0-9]+
-**	mv	a[0-9]+,a[0-9]+
-**	ret
-*/
+/* addi aX, aX, 1000
+   th.mvnez aX, aX, aX  */
 int ConNmv_imm_reg_reg(int x, int y, int z)
 {
   if (x != 1000)
@@ -89,13 +61,9 @@ int ConNmv_imm_reg_reg(int x, int y, int z)
   return z;
 }
 
-/*
-**ConNmv_reg_imm_reg:
-**	sub	a[0-9]+,a[0-9]+,a[0-9]+
-**	li	a[0-9]+,10+
-**	th.mveqz	a[0-9]+,a[0-9]+,a[0-9]+
-**	ret
-*/
+/* sub aX, aX, aX
+   li aX, 10
+   th.mveqz aX, aX, aX  */
 int ConNmv_reg_imm_reg(int x, int y, int z)
 {
   if (x != y)
@@ -103,16 +71,17 @@ int ConNmv_reg_imm_reg(int x, int y, int z)
   return z;
 }
 
-/*
-**ConNmv_reg_reg_reg:
-**	sub	a[0-9]+,a[0-9]+,a[0-9]+
-**	th.mvnez	a[0-9]+,a[0-9]+,a[0-9]+
-**	mv	a[0-9]+,a[0-9]+
-**	ret
-*/
+/* sub aX, aX, aX
+   th.mvnez aX, aX, aX  */
 int ConNmv_reg_reg_reg(int x, int y, int z, int n)
 {
   if (x != y)
     return z;
   return n;
 }
+
+/* { dg-final { scan-assembler-times "addi\t" 5 } } */
+/* { dg-final { scan-assembler-times "li\t" 4 } } */
+/* { dg-final { scan-assembler-times "sub\t" 4 } } */
+/* { dg-final { scan-assembler-times "th.mveqz\t" 4 } } */
+/* { dg-final { scan-assembler-times "th.mvnez\t" 4 } } */
-- 
2.41.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] RISC-V: Make xtheadcondmov-indirect tests robust against instruction reordering
  2023-10-12 13:06 [PATCH v2] RISC-V: Make xtheadcondmov-indirect tests robust against instruction reordering Christoph Muellner
@ 2023-10-12 16:12 ` Jeff Law
  2023-10-12 18:28   ` Kito Cheng
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff Law @ 2023-10-12 16:12 UTC (permalink / raw)
  To: Christoph Muellner, gcc-patches, Kito Cheng, Jim Wilson,
	Palmer Dabbelt, Andrew Waterman, Philipp Tomsich,
	Patrick O'Neill, Vineet Gupta



On 10/12/23 07:06, Christoph Muellner wrote:
> From: Christoph Müllner <christoph.muellner@vrull.eu>
> 
> Fixes: c1bc7513b1d7 ("RISC-V: const: hide mvconst splitter from IRA")
> 
> A recent change broke the xtheadcondmov-indirect tests, because the order of
> emitted instructions changed. Since the test is too strict when testing for
> a fixed instruction order, let's change the tests to simply count instruction,
> like it is done for similar tests.
> 
> Reported-by: Patrick O'Neill <patrick@rivosinc.com>
> Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
> 
> gcc/testsuite/ChangeLog:
> 
> 	* gcc.target/riscv/xtheadcondmov-indirect.c: Make robust against
> 	instruction reordering.
OK for the trunk.

jeff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] RISC-V: Make xtheadcondmov-indirect tests robust against instruction reordering
  2023-10-12 16:12 ` Jeff Law
@ 2023-10-12 18:28   ` Kito Cheng
  2023-10-12 18:29     ` Kito Cheng
  2023-10-13 16:23     ` Jeff Law
  0 siblings, 2 replies; 5+ messages in thread
From: Kito Cheng @ 2023-10-12 18:28 UTC (permalink / raw)
  To: Jeff Law
  Cc: Christoph Muellner, gcc-patches, Jim Wilson, Palmer Dabbelt,
	Andrew Waterman, Philipp Tomsich, Patrick O'Neill,
	Vineet Gupta

Sorry for the late comment after Jeff say ok, but I guess we may
consider add "-fno-schedule-insns -fno-schedule-insns2" to avoid
disturbing from schedule like some of our test case in
gcc/testsuite/gcc.target/riscv/rvv?

On Thu, Oct 12, 2023 at 9:12 AM Jeff Law <jeffreyalaw@gmail.com> wrote:
>
>
>
> On 10/12/23 07:06, Christoph Muellner wrote:
> > From: Christoph Müllner <christoph.muellner@vrull.eu>
> >
> > Fixes: c1bc7513b1d7 ("RISC-V: const: hide mvconst splitter from IRA")
> >
> > A recent change broke the xtheadcondmov-indirect tests, because the order of
> > emitted instructions changed. Since the test is too strict when testing for
> > a fixed instruction order, let's change the tests to simply count instruction,
> > like it is done for similar tests.
> >
> > Reported-by: Patrick O'Neill <patrick@rivosinc.com>
> > Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
> >
> > gcc/testsuite/ChangeLog:
> >
> >       * gcc.target/riscv/xtheadcondmov-indirect.c: Make robust against
> >       instruction reordering.
> OK for the trunk.
>
> jeff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] RISC-V: Make xtheadcondmov-indirect tests robust against instruction reordering
  2023-10-12 18:28   ` Kito Cheng
@ 2023-10-12 18:29     ` Kito Cheng
  2023-10-13 16:23     ` Jeff Law
  1 sibling, 0 replies; 5+ messages in thread
From: Kito Cheng @ 2023-10-12 18:29 UTC (permalink / raw)
  To: Jeff Law
  Cc: Christoph Muellner, gcc-patches, Jim Wilson, Palmer Dabbelt,
	Andrew Waterman, Philipp Tomsich, Patrick O'Neill,
	Vineet Gupta

but anyway, I don't have a strong opinion for either way, just go
ahead no matter which one you choose.

On Thu, Oct 12, 2023 at 11:28 AM Kito Cheng <kito.cheng@sifive.com> wrote:
>
> Sorry for the late comment after Jeff say ok, but I guess we may
> consider add "-fno-schedule-insns -fno-schedule-insns2" to avoid
> disturbing from schedule like some of our test case in
> gcc/testsuite/gcc.target/riscv/rvv?
>
> On Thu, Oct 12, 2023 at 9:12 AM Jeff Law <jeffreyalaw@gmail.com> wrote:
> >
> >
> >
> > On 10/12/23 07:06, Christoph Muellner wrote:
> > > From: Christoph Müllner <christoph.muellner@vrull.eu>
> > >
> > > Fixes: c1bc7513b1d7 ("RISC-V: const: hide mvconst splitter from IRA")
> > >
> > > A recent change broke the xtheadcondmov-indirect tests, because the order of
> > > emitted instructions changed. Since the test is too strict when testing for
> > > a fixed instruction order, let's change the tests to simply count instruction,
> > > like it is done for similar tests.
> > >
> > > Reported-by: Patrick O'Neill <patrick@rivosinc.com>
> > > Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
> > >
> > > gcc/testsuite/ChangeLog:
> > >
> > >       * gcc.target/riscv/xtheadcondmov-indirect.c: Make robust against
> > >       instruction reordering.
> > OK for the trunk.
> >
> > jeff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] RISC-V: Make xtheadcondmov-indirect tests robust against instruction reordering
  2023-10-12 18:28   ` Kito Cheng
  2023-10-12 18:29     ` Kito Cheng
@ 2023-10-13 16:23     ` Jeff Law
  1 sibling, 0 replies; 5+ messages in thread
From: Jeff Law @ 2023-10-13 16:23 UTC (permalink / raw)
  To: Kito Cheng
  Cc: Christoph Muellner, gcc-patches, Jim Wilson, Palmer Dabbelt,
	Andrew Waterman, Philipp Tomsich, Patrick O'Neill,
	Vineet Gupta



On 10/12/23 12:28, Kito Cheng wrote:
> Sorry for the late comment after Jeff say ok, but I guess we may
> consider add "-fno-schedule-insns -fno-schedule-insns2" to avoid
> disturbing from schedule like some of our test case in
> gcc/testsuite/gcc.target/riscv/rvv?
It wouldn't be a bad idea to bring more stability, particularly to tests 
which are expecting instructions in a specific order.  THat feels like 
it's likely a distinct change though.

jeff

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-10-13 16:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-12 13:06 [PATCH v2] RISC-V: Make xtheadcondmov-indirect tests robust against instruction reordering Christoph Muellner
2023-10-12 16:12 ` Jeff Law
2023-10-12 18:28   ` Kito Cheng
2023-10-12 18:29     ` Kito Cheng
2023-10-13 16:23     ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).