aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@embecosm.com>2023-11-22 01:18:30 +0000
committerMaciej W. Rozycki <macro@embecosm.com>2023-11-22 01:18:30 +0000
commit2278c6443aa6aaa12b3682afb8ad0774575ae1b4 (patch)
tree2ba68dbb6ad62540b6183e83c994295ea257c53e
parent9d02897e885e547ac7af11883717b1539154db61 (diff)
downloadgcc-2278c6443aa6aaa12b3682afb8ad0774575ae1b4.zip
gcc-2278c6443aa6aaa12b3682afb8ad0774575ae1b4.tar.gz
gcc-2278c6443aa6aaa12b3682afb8ad0774575ae1b4.tar.bz2
RISC-V/testsuite: Add branched cases for generic FP cond adds
Verify, for generic floating-point conditional-add operations that have a corresponding conditional-set machine instruction, that if-conversion does *not* trigger at `-mbranch-cost=2' setting, which makes original branched code sequences cheaper than their branchless equivalents if-conversion would emit. Cover all the relevant floating-point relational operations to make sure no corner case escapes. gcc/testsuite/ * gcc.target/riscv/adddibfeq.c: New test. * gcc.target/riscv/adddibfge.c: New test. * gcc.target/riscv/adddibfgt.c: New test. * gcc.target/riscv/adddibfle.c: New test. * gcc.target/riscv/adddibflt.c: New test. * gcc.target/riscv/addsibfeq.c: New test. * gcc.target/riscv/addsibfge.c: New test. * gcc.target/riscv/addsibfgt.c: New test. * gcc.target/riscv/addsibfle.c: New test. * gcc.target/riscv/addsibflt.c: New test.
-rw-r--r--gcc/testsuite/gcc.target/riscv/adddibfeq.c26
-rw-r--r--gcc/testsuite/gcc.target/riscv/adddibfge.c26
-rw-r--r--gcc/testsuite/gcc.target/riscv/adddibfgt.c26
-rw-r--r--gcc/testsuite/gcc.target/riscv/adddibfle.c26
-rw-r--r--gcc/testsuite/gcc.target/riscv/adddibflt.c26
-rw-r--r--gcc/testsuite/gcc.target/riscv/addsibfeq.c26
-rw-r--r--gcc/testsuite/gcc.target/riscv/addsibfge.c26
-rw-r--r--gcc/testsuite/gcc.target/riscv/addsibfgt.c26
-rw-r--r--gcc/testsuite/gcc.target/riscv/addsibfle.c26
-rw-r--r--gcc/testsuite/gcc.target/riscv/addsibflt.c26
10 files changed, 260 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/riscv/adddibfeq.c b/gcc/testsuite/gcc.target/riscv/adddibfeq.c
new file mode 100644
index 0000000..403200f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/adddibfeq.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target rv64 } */
+/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */
+/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=2 -mmovcc -fdump-rtl-ce1" } */
+
+typedef int __attribute__ ((mode (DI))) int_t;
+
+int_t
+adddifeq (double w, double x, int_t y, int_t z)
+{
+ return w == x ? y + z : y;
+}
+
+/* Expect branched assembly like:
+
+ feq.d a5,fa0,fa1
+ beq a5,zero,.L2
+ add a0,a0,a1
+.L2:
+ */
+
+/* { dg-final { scan-rtl-dump-not "Conversion succeeded on pass \[0-9\]+\\." "ce1" } } */
+/* { dg-final { scan-rtl-dump-not "if-conversion succeeded through" "ce1" } } */
+/* { dg-final { scan-assembler-times "\\sfeq\\.d\\s" 1 } } */
+/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s" 1 } } */
+/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */
diff --git a/gcc/testsuite/gcc.target/riscv/adddibfge.c b/gcc/testsuite/gcc.target/riscv/adddibfge.c
new file mode 100644
index 0000000..82fce9c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/adddibfge.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target rv64 } */
+/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */
+/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=2 -mmovcc -ffinite-math-only -fdump-rtl-ce1" } */
+
+typedef int __attribute__ ((mode (DI))) int_t;
+
+int_t
+adddifge (double w, double x, int_t y, int_t z)
+{
+ return w >= x ? y + z : y;
+}
+
+/* Expect branched assembly like:
+
+ fge.d a5,fa0,fa1
+ beq a5,zero,.L2
+ add a0,a0,a1
+.L2:
+ */
+
+/* { dg-final { scan-rtl-dump-not "Conversion succeeded on pass \[0-9\]+\\." "ce1" } } */
+/* { dg-final { scan-rtl-dump-not "if-conversion succeeded through" "ce1" } } */
+/* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fgt\\.d|fle\\.d|flt\\.d)\\s" 1 } } */
+/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s" 1 } } */
+/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */
diff --git a/gcc/testsuite/gcc.target/riscv/adddibfgt.c b/gcc/testsuite/gcc.target/riscv/adddibfgt.c
new file mode 100644
index 0000000..0263154
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/adddibfgt.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target rv64 } */
+/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */
+/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=2 -mmovcc -ffinite-math-only -fdump-rtl-ce1" } */
+
+typedef int __attribute__ ((mode (DI))) int_t;
+
+int_t
+adddifgt (double w, double x, int_t y, int_t z)
+{
+ return w > x ? y + z : y;
+}
+
+/* Expect branched assembly like:
+
+ fgt.d a5,fa0,fa1
+ beq a5,zero,.L2
+ add a0,a0,a1
+.L2:
+ */
+
+/* { dg-final { scan-rtl-dump-not "Conversion succeeded on pass \[0-9\]+\\." "ce1" } } */
+/* { dg-final { scan-rtl-dump-not "if-conversion succeeded through" "ce1" } } */
+/* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fgt\\.d|fle\\.d|flt\\.d)\\s" 1 } } */
+/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s" 1 } } */
+/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */
diff --git a/gcc/testsuite/gcc.target/riscv/adddibfle.c b/gcc/testsuite/gcc.target/riscv/adddibfle.c
new file mode 100644
index 0000000..6fd65f1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/adddibfle.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target rv64 } */
+/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */
+/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=2 -mmovcc -ffinite-math-only -fdump-rtl-ce1" } */
+
+typedef int __attribute__ ((mode (DI))) int_t;
+
+int_t
+adddifle (double w, double x, int_t y, int_t z)
+{
+ return w <= x ? y + z : y;
+}
+
+/* Expect branched assembly like:
+
+ fle.d a5,fa0,fa1
+ beq a5,zero,.L2
+ add a0,a0,a1
+.L2:
+ */
+
+/* { dg-final { scan-rtl-dump-not "Conversion succeeded on pass \[0-9\]+\\." "ce1" } } */
+/* { dg-final { scan-rtl-dump-not "if-conversion succeeded through" "ce1" } } */
+/* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fgt\\.d|fle\\.d|flt\\.d)\\s" 1 } } */
+/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s" 1 } } */
+/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */
diff --git a/gcc/testsuite/gcc.target/riscv/adddibflt.c b/gcc/testsuite/gcc.target/riscv/adddibflt.c
new file mode 100644
index 0000000..bfee522
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/adddibflt.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target rv64 } */
+/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */
+/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=2 -mmovcc -ffinite-math-only -fdump-rtl-ce1" } */
+
+typedef int __attribute__ ((mode (DI))) int_t;
+
+int_t
+adddiflt (double w, double x, int_t y, int_t z)
+{
+ return w < x ? y + z : y;
+}
+
+/* Expect branched assembly like:
+
+ flt.d a5,fa0,fa1
+ beq a5,zero,.L2
+ add a0,a0,a1
+.L2:
+ */
+
+/* { dg-final { scan-rtl-dump-not "Conversion succeeded on pass \[0-9\]+\\." "ce1" } } */
+/* { dg-final { scan-rtl-dump-not "if-conversion succeeded through" "ce1" } } */
+/* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fgt\\.d|fle\\.d|flt\\.d)\\s" 1 } } */
+/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s" 1 } } */
+/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */
diff --git a/gcc/testsuite/gcc.target/riscv/addsibfeq.c b/gcc/testsuite/gcc.target/riscv/addsibfeq.c
new file mode 100644
index 0000000..27d13a0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/addsibfeq.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */
+/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=2 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */
+/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=2 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */
+
+typedef int __attribute__ ((mode (SI))) int_t;
+
+int_t
+addsifeq (double w, double x, int_t y, int_t z)
+{
+ return w == x ? y + z : y;
+}
+
+/* Expect branched assembly like:
+
+ feq.d a5,fa0,fa1
+ beq a5,zero,.L2
+ add[w] a0,a0,a1
+.L2:
+ */
+
+/* { dg-final { scan-rtl-dump-not "Conversion succeeded on pass \[0-9\]+\\." "ce1" } } */
+/* { dg-final { scan-rtl-dump-not "if-conversion succeeded through" "ce1" } } */
+/* { dg-final { scan-assembler-times "\\sfeq\\.d\\s" 1 } } */
+/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s" 1 } } */
+/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */
diff --git a/gcc/testsuite/gcc.target/riscv/addsibfge.c b/gcc/testsuite/gcc.target/riscv/addsibfge.c
new file mode 100644
index 0000000..501f756
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/addsibfge.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */
+/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=2 -mmovcc -ffinite-math-only -fdump-rtl-ce1" { target { rv32 } } } */
+/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=2 -mmovcc -ffinite-math-only -fdump-rtl-ce1" { target { rv64 } } } */
+
+typedef int __attribute__ ((mode (SI))) int_t;
+
+int_t
+addsifge (double w, double x, int_t y, int_t z)
+{
+ return w >= x ? y + z : y;
+}
+
+/* Expect branched assembly like:
+
+ fge.d a5,fa0,fa1
+ beq a5,zero,.L2
+ add[w] a0,a0,a1
+.L2:
+ */
+
+/* { /* { dg-final { scan-rtl-dump-not "Conversion succeeded on pass \[0-9\]+\\." "ce1" } } */
+/* { dg-final { scan-rtl-dump-not "if-conversion succeeded through" "ce1" } } */
+/* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fgt\\.d|fle\\.d|flt\\.d)\\s" 1 } } */
+/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s" 1 } } */
+/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */
diff --git a/gcc/testsuite/gcc.target/riscv/addsibfgt.c b/gcc/testsuite/gcc.target/riscv/addsibfgt.c
new file mode 100644
index 0000000..fff809b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/addsibfgt.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */
+/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=2 -mmovcc -ffinite-math-only -fdump-rtl-ce1" { target { rv32 } } } */
+/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=2 -mmovcc -ffinite-math-only -fdump-rtl-ce1" { target { rv64 } } } */
+
+typedef int __attribute__ ((mode (SI))) int_t;
+
+int_t
+addsifgt (double w, double x, int_t y, int_t z)
+{
+ return w > x ? y + z : y;
+}
+
+/* Expect branched assembly like:
+
+ fgt.d a5,fa0,fa1
+ beq a5,zero,.L2
+ add[w] a0,a0,a1
+.L2:
+ */
+
+/* { /* { dg-final { scan-rtl-dump-not "Conversion succeeded on pass \[0-9\]+\\." "ce1" } } */
+/* { dg-final { scan-rtl-dump-not "if-conversion succeeded through" "ce1" } } */
+/* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fgt\\.d|fle\\.d|flt\\.d)\\s" 1 } } */
+/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s" 1 } } */
+/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */
diff --git a/gcc/testsuite/gcc.target/riscv/addsibfle.c b/gcc/testsuite/gcc.target/riscv/addsibfle.c
new file mode 100644
index 0000000..abcad61
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/addsibfle.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */
+/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=2 -mmovcc -ffinite-math-only -fdump-rtl-ce1" { target { rv32 } } } */
+/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=2 -mmovcc -ffinite-math-only -fdump-rtl-ce1" { target { rv64 } } } */
+
+typedef int __attribute__ ((mode (SI))) int_t;
+
+int_t
+addsifle (double w, double x, int_t y, int_t z)
+{
+ return w <= x ? y + z : y;
+}
+
+/* Expect branched assembly like:
+
+ fle.d a5,fa0,fa1
+ beq a5,zero,.L2
+ addw a0,a0,a1
+.L2:
+ */
+
+/* { /* { dg-final { scan-rtl-dump-not "Conversion succeeded on pass \[0-9\]+\\." "ce1" } } */
+/* { dg-final { scan-rtl-dump-not "if-conversion succeeded through" "ce1" } } */
+/* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fgt\\.d|fle\\.d|flt\\.d)\\s" 1 } } */
+/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s" 1 } } */
+/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */
diff --git a/gcc/testsuite/gcc.target/riscv/addsibflt.c b/gcc/testsuite/gcc.target/riscv/addsibflt.c
new file mode 100644
index 0000000..2a82c28
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/addsibflt.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */
+/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=2 -mmovcc -ffinite-math-only -fdump-rtl-ce1" { target { rv32 } } } */
+/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=2 -mmovcc -ffinite-math-only -fdump-rtl-ce1" { target { rv64 } } } */
+
+typedef int __attribute__ ((mode (SI))) int_t;
+
+int_t
+addsiflt (double w, double x, int_t y, int_t z)
+{
+ return w < x ? y + z : y;
+}
+
+/* Expect branched assembly like:
+
+ flt.d a5,fa0,fa1
+ beq a5,zero,.L2
+ addw a0,a0,a1
+.L2:
+ */
+
+/* { /* { dg-final { scan-rtl-dump-not "Conversion succeeded on pass \[0-9\]+\\." "ce1" } } */
+/* { dg-final { scan-rtl-dump-not "if-conversion succeeded through" "ce1" } } */
+/* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fgt\\.d|fle\\.d|flt\\.d)\\s" 1 } } */
+/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s" 1 } } */
+/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */