From: juewang <[email protected]>

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

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" } } */
-- 
2.34.1

Reply via email to