diff mbox series

testsuite: Add tests for parallel noce sequence costing

Message ID 20260903015504.76910-1-juewang@linux.alibaba.com
State New
Headers show
Series testsuite: Add tests for parallel noce sequence costing | expand

Commit Message

wangjue Sept. 3, 2026, 1:55 a.m. UTC
From: juewang <juewang@linux.alibaba.com>

Test both sides of the issue-rate adjustment at a branch cost of three.
The xt-c9501fdvt tuning model makes three independent pointer selections
profitable, while the generic model retains the branch.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/ifcvt-parallel-cost-1.c: New test.
	* gcc.target/riscv/ifcvt-parallel-cost-2.c: New test.
---
 .../gcc.target/riscv/ifcvt-parallel-cost-1.c  | 27 +++++++++++++++++
 .../gcc.target/riscv/ifcvt-parallel-cost-2.c  | 30 +++++++++++++++++++
 2 files changed, 57 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/riscv/ifcvt-parallel-cost-1.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/ifcvt-parallel-cost-2.c

Comments

Robin Dapp Sept. 3, 2026, 6:59 a.m. UTC | #1
> From: juewang <juewang@linux.alibaba.com>
>
> Test both sides of the issue-rate adjustment at a branch cost of three.
> The xt-c9501fdvt tuning model makes three independent pointer selections
> profitable, while the generic model retains the branch.

Here and for other patches: Please follow GCC's AI policy and add an 
Assisted-By tag whenever an LLM (or similar) was used in any way for 
preparing a patch.

> diff --git a/gcc/testsuite/gcc.target/riscv/ifcvt-parallel-cost-1.c 
> b/gcc/testsuite/gcc.target/riscv/ifcvt-parallel-cost-1.c
> new file mode 100644
> index 00000000000..c9ac7f48b4f
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/riscv/ifcvt-parallel-cost-1.c
> @@ -0,0 +1,27 @@
> +/* { dg-do compile } */
> +/* { dg-require-effective-target rv64 } */

Why did you add dg-require-effective-target?
wangjue Sept. 3, 2026, 10:01 a.m. UTC | #2
Hi  Robin

> Here and for other patches: Please follow GCC's AI policy and add an 
> Assisted-By tag whenever an LLM (or similar) was used in any way for 
> preparing a patch.

Thanks for the reminder.  I will add the appropriate Assisted-by tag in
the next revision.

> Why did you add dg-require-effective-target?

I will remove it and  fix the m68k regression in the next revision.


Best regards,
Wang Jue
diff mbox series

Patch

diff --git a/gcc/testsuite/gcc.target/riscv/ifcvt-parallel-cost-1.c b/gcc/testsuite/gcc.target/riscv/ifcvt-parallel-cost-1.c
new file mode 100644
index 00000000000..c9ac7f48b4f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/ifcvt-parallel-cost-1.c
@@ -0,0 +1,27 @@ 
+/* { dg-do compile } */
+/* { dg-require-effective-target rv64 } */
+/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */
+/* { dg-options "-O2 -march=rv64gc_zicond -mabi=lp64d -mtune=xt-c9501fdvt -mbranch-cost=3" } */
+
+extern void consume (void *, void *, void *);
+
+__attribute__ ((noinline, noclone))
+void
+select_three_pointers (long x, long y,
+		       void *a0, void *a1,
+		       void *b0, void *b1,
+		       void *c0, void *c1)
+{
+  if (x > y)
+    {
+      a0 = a1;
+      b0 = b1;
+      c0 = c1;
+    }
+
+  consume (a0, b0, c0);
+}
+
+/* { dg-final { scan-assembler-times "\\sczero\\.eqz\\s" 3 } } */
+/* { dg-final { scan-assembler-times "\\sczero\\.nez\\s" 3 } } */
+/* { dg-final { scan-assembler-not "\\s(?:bge|bgt|ble|blt)\\s" } } */
diff --git a/gcc/testsuite/gcc.target/riscv/ifcvt-parallel-cost-2.c b/gcc/testsuite/gcc.target/riscv/ifcvt-parallel-cost-2.c
new file mode 100644
index 00000000000..178ab54dc2d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/ifcvt-parallel-cost-2.c
@@ -0,0 +1,30 @@ 
+/* { dg-do compile } */
+/* { dg-require-effective-target rv64 } */
+/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */
+/* { dg-options "-O2 -march=rv64gc_zicond -mabi=lp64d -mtune=generic -mbranch-cost=3" } */
+
+extern void consume (void *, void *, void *);
+
+__attribute__ ((noinline, noclone))
+void
+select_three_pointers_generic (long x, long y,
+			       void *a0, void *a1,
+			       void *b0, void *b1,
+			       void *c0, void *c1)
+{
+  if (x >= y)
+    {
+      a0 = a1;
+      b0 = b1;
+      c0 = c1;
+    }
+
+  consume (a0, b0, c0);
+}
+
+/* The generic tuning model has an issue rate of one, so the three pointer
+   selections are not profitable at a branch cost of three.  */
+
+/* { dg-final { scan-assembler-times "\\sbge\\s" 1 } } */
+/* { dg-final { scan-assembler-not "\\sczero\\.eqz\\s" } } */
+/* { dg-final { scan-assembler-not "\\sczero\\.nez\\s" } } */