aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorHans-Peter Nilsson <hp@axis.com>2020-02-10 17:34:23 +0100
committerHans-Peter Nilsson <hp@axis.com>2020-02-10 17:34:23 +0100
commit991c1376b8f5a1e40d4a602701b50329cb627853 (patch)
treebfa18c10c896591c1dfd7b24baa5fcccf40cb157 /gcc
parentd12f1b914cc10d8d28f8838eb9d9fc33114ef0db (diff)
downloadgcc-991c1376b8f5a1e40d4a602701b50329cb627853.zip
gcc-991c1376b8f5a1e40d4a602701b50329cb627853.tar.gz
gcc-991c1376b8f5a1e40d4a602701b50329cb627853.tar.bz2
gcc.target/cris/pr93372-2.c, -5.c, -8.c: New tests.
* gcc.target/cris/pr93372-2.c, gcc.target/cris/pr93372-5.c, gcc.target/cris/pr93372-8.c: New tests. These tests fails miserably both at being an example of cc0 eliminating compare instructions, and post-cc0-CRIS at showing a significant improvement. They're here to track suboptimal comparison code for CRIS.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog2
-rw-r--r--gcc/testsuite/gcc.target/cris/pr93372-2.c19
-rw-r--r--gcc/testsuite/gcc.target/cris/pr93372-5.c19
-rw-r--r--gcc/testsuite/gcc.target/cris/pr93372-8.c16
4 files changed, 56 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b418065..d2fd6aa 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -3,6 +3,8 @@
* gcc.target/cris/cris.exp (check_effective_target_cc0): New.
* gcc.target/cris/pr93372-1.c: New test.
+ * gcc.target/cris/pr93372-2.c, gcc.target/cris/pr93372-5.c,
+ gcc.target/cris/pr93372-8.c: New tests.
2020-02-10 Jakub Jelinek <jakub@redhat.com>
diff --git a/gcc/testsuite/gcc.target/cris/pr93372-2.c b/gcc/testsuite/gcc.target/cris/pr93372-2.c
new file mode 100644
index 0000000..912069c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/pr93372-2.c
@@ -0,0 +1,19 @@
+/* Check that eliminable compare-instructions are eliminated. */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler-not "\tcmp|\ttest" { xfail *-*-* } } } */
+/* { dg-final { scan-assembler-not "\tnot" { xfail cc0 } } } */
+/* { dg-final { scan-assembler-not "\tlsr" { xfail cc0 } } } */
+
+int f(int a, int b, int *d)
+{
+ int c = a - b;
+
+ /* Whoops! We get a cmp.d with the original operands here. */
+ *d = (c == 0);
+
+ /* Whoops! While we don't get a test.d for the result here for cc0,
+ we get a sequence of insns: a move, a "not" and a shift of the
+ subtraction-result, where a simple "spl" would have done. */
+ return c >= 0;
+}
diff --git a/gcc/testsuite/gcc.target/cris/pr93372-5.c b/gcc/testsuite/gcc.target/cris/pr93372-5.c
new file mode 100644
index 0000000..351764c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/pr93372-5.c
@@ -0,0 +1,19 @@
+/* Check that eliminable compare-instructions are eliminated. */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler-not "\tcmp|\ttest|\tor" { xfail *-*-* } } } */
+/* { dg-final { scan-assembler-not "\tnot" { xfail cc0 } } } */
+/* { dg-final { scan-assembler-not "\tlsr" { xfail cc0 } } } */
+
+int f(long long int a, long long int b, int *d)
+{
+ long long int c = a - b;
+
+ *d = (c == 0LL);
+
+ /* See pr93372-2.c; we have the same problem for DImode, but it's
+ worsened by the generic double-word "optimizations"; or:ing
+ together the DI parts and then testing the result for the equality
+ test. */
+ return c >= 0LL;
+}
diff --git a/gcc/testsuite/gcc.target/cris/pr93372-8.c b/gcc/testsuite/gcc.target/cris/pr93372-8.c
new file mode 100644
index 0000000..95abc4b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/pr93372-8.c
@@ -0,0 +1,16 @@
+/* Check that eliminable compare-instructions are eliminated. */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* See pr93372-5.c regarding the xfails. */
+/* { dg-final { scan-assembler-not "\tcmp|\ttest|\tor" { xfail *-*-* } } } */
+/* { dg-final { scan-assembler-not "\tnot" { xfail cc0 } } } */
+/* { dg-final { scan-assembler-not "\tlsr" { xfail cc0 } } } */
+
+int f(long long int a, long long int b, int *d)
+{
+ long long int c = a + b;
+
+ *d = (c == 0);
+
+ return c >= 0;
+}