]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Adjust rx movsicc tests
authorJeff Law <jlaw@ventanamicro>
Sat, 22 Apr 2023 16:43:35 +0000 (10:43 -0600)
committerJeff Law <jlaw@ventanamicro>
Sat, 22 Apr 2023 16:43:35 +0000 (10:43 -0600)
The rx port has target specific test movsicc which is naturally meant to verify
that if-conversion is happening on the expected cases.

Unfortunately the test is poorly written.  The core problem is there are 8
distinct tests and each of those tests is expected to generate a specific
sequence.  Unfortunately, various generic bits might turn an equality test
into an inequality test or make other similar changes.

The net result is the assembly matching patterns may find a particular sequence,
but it may be for a different function than was originally intended.  ie,
test1's output may match the expected assembly for test5.  Ugh!

This patch breaks the movsicc test down into 8 distinct tests and adjusts the
patterns they match.  The nice thing is all these tests are supposed to have
branches that use a bCC 1f form.  So we can make them a bit more robust by
ignoring the actual condition code used.  So if we change eq to ne, as long
as we match the movsicc pattern, we're OK.  And the 1f style is only used by
the movsicc pattern.

With the tests broken down it's a lot easier to diagnose why one test fails
after the recent changes to if-conversion.  movsicc-3 fails because of the
profitability test.  It's more expensive than the other cases because of its
use of (const_int 10) rather than (const_int 0).  (const_int 0) naturally has
a smaller cost.

It looks to me like in this context (const_int 10) should have the same cost
 as (const_int 0).  But I'm nowhere near well versed in the cost model for the
rx port.  So I'm just leaving the test as xfailed.  If someone cares enough,
they can dig into it further.

gcc/testsuite
* gcc.target/rx/movsicc.c: Broken down into ...
* gcc.target/rx/movsicc-1.c: Here.
* gcc.target/rx/movsicc-2.c: Here.
* gcc.target/rx/movsicc-3.c: Here.  xfail one test.
* gcc.target/rx/movsicc-4.c: Here.
* gcc.target/rx/movsicc-5.c: Here.
* gcc.target/rx/movsicc-6.c: Here.
* gcc.target/rx/movsicc-7.c: Here.
* gcc.target/rx/movsicc-8.c: Here.

gcc/testsuite/gcc.target/rx/movsicc-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/rx/movsicc-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/rx/movsicc-3.c [new file with mode: 0644]
gcc/testsuite/gcc.target/rx/movsicc-4.c [new file with mode: 0644]
gcc/testsuite/gcc.target/rx/movsicc-5.c [new file with mode: 0644]
gcc/testsuite/gcc.target/rx/movsicc-6.c [new file with mode: 0644]
gcc/testsuite/gcc.target/rx/movsicc-7.c [new file with mode: 0644]
gcc/testsuite/gcc.target/rx/movsicc-8.c [new file with mode: 0644]
gcc/testsuite/gcc.target/rx/movsicc.c [deleted file]

diff --git a/gcc/testsuite/gcc.target/rx/movsicc-1.c b/gcc/testsuite/gcc.target/rx/movsicc-1.c
new file mode 100644 (file)
index 0000000..09234ea
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-Os" } */
+
+typedef unsigned char u8;
+typedef unsigned short u16;
+signed int Xa, Xb;
+
+signed int stzreg_beq(int i, int a, int b)
+{
+  signed int x;
+  x = a;
+  if (i)
+    x = b;
+  return x;
+}
+
+/* { dg-final { scan-assembler "b.. 1f" } } */
+
diff --git a/gcc/testsuite/gcc.target/rx/movsicc-2.c b/gcc/testsuite/gcc.target/rx/movsicc-2.c
new file mode 100644 (file)
index 0000000..7d730c4
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-Os" } */
+
+typedef unsigned char u8;
+typedef unsigned short u16;
+signed int Xa, Xb;
+
+signed int stzreg_bge(int i, int a, int b, int c)
+{
+  signed int x;
+  x = a;
+  if (i<c)
+    x = b;
+  return x;
+}
+
+/* { dg-final { scan-assembler "b.. 1f" } } */
+
diff --git a/gcc/testsuite/gcc.target/rx/movsicc-3.c b/gcc/testsuite/gcc.target/rx/movsicc-3.c
new file mode 100644 (file)
index 0000000..84a56e2
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-Os" } */
+
+typedef unsigned char u8;
+typedef unsigned short u16;
+signed int Xa, Xb;
+
+signed int stzreg_bgt(int i, int a, int b)
+{
+  signed int x;
+  x = a;
+  if (i<10)
+    x = b;
+  return x;
+}
+
+/* { dg-final { scan-assembler "b.. 1f" } } */
+
diff --git a/gcc/testsuite/gcc.target/rx/movsicc-4.c b/gcc/testsuite/gcc.target/rx/movsicc-4.c
new file mode 100644 (file)
index 0000000..fef30cf
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-Os" } */
+
+typedef unsigned char u8;
+typedef unsigned short u16;
+signed int Xa, Xb;
+
+signed int stzreg_ble(int i, int a, int b)
+{
+  signed int x;
+  x = a;
+  if (i>0)
+    x = b;
+  return x;
+}
+
+/* { dg-final { scan-assembler "b.. 1f" } } */
+
diff --git a/gcc/testsuite/gcc.target/rx/movsicc-5.c b/gcc/testsuite/gcc.target/rx/movsicc-5.c
new file mode 100644 (file)
index 0000000..0febb68
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-Os" } */
+
+typedef unsigned char u8;
+typedef unsigned short u16;
+signed int Xa, Xb;
+
+signed int stzreg_blt(int i, int a, int b)
+{
+  signed int x;
+  x = a;
+  if (i<0)
+    x = b;
+  return x;
+}
+
+/* { dg-final { scan-assembler "b.. 1f" } } */
+
diff --git a/gcc/testsuite/gcc.target/rx/movsicc-6.c b/gcc/testsuite/gcc.target/rx/movsicc-6.c
new file mode 100644 (file)
index 0000000..69f312e
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-Os" } */
+
+typedef unsigned char u8;
+typedef unsigned short u16;
+signed int Xa, Xb;
+
+signed int stzreg_bne(int i, int a, int b)
+{
+  signed int x;
+  x = a;
+  if (!i)
+    x = b;
+  return x;
+}
+
+/* { dg-final { scan-assembler "b.. 1f" } } */
+
diff --git a/gcc/testsuite/gcc.target/rx/movsicc-7.c b/gcc/testsuite/gcc.target/rx/movsicc-7.c
new file mode 100644 (file)
index 0000000..a1a22e2
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-Os" } */
+
+typedef unsigned char u8;
+typedef unsigned short u16;
+signed int Xa, Xb;
+
+signed int stzimm_le( int i, int a )
+{
+  signed int x;
+  x = a;
+  if (i>0)
+    x = 5;
+  return x;
+}
+
+/* { dg-final { scan-assembler "b.. 1f" } } */
diff --git a/gcc/testsuite/gcc.target/rx/movsicc-8.c b/gcc/testsuite/gcc.target/rx/movsicc-8.c
new file mode 100644 (file)
index 0000000..be59e64
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-Os" } */
+
+typedef unsigned char u8;
+typedef unsigned short u16;
+signed int Xa, Xb;
+
+signed int stzimm_le_r( int i, int a )
+{
+  signed int x;
+  x = a;
+  if (i<0)
+    x = 5;
+  return x;
+}
+
+/* { dg-final { scan-assembler "b.. 1f" } } */
diff --git a/gcc/testsuite/gcc.target/rx/movsicc.c b/gcc/testsuite/gcc.target/rx/movsicc.c
deleted file mode 100644 (file)
index d8e6bcc..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/* { dg-do compile } */
-/* { dg-options "-Os" } */
-
-typedef unsigned char u8;
-typedef unsigned short u16;
-signed int Xa, Xb;
-
-signed int stzreg_beq(int i, int a, int b)
-{
-  signed int x;
-  x = a;
-  if (i)
-    x = b;
-  return x;
-}
-
-/* { dg-final { scan-assembler "bne 1f" } } */
-
-signed int stzreg_bge(int i, int a, int b, int c)
-{
-  signed int x;
-  x = a;
-  if (i<c)
-    x = b;
-  return x;
-}
-
-/* { dg-final { scan-assembler "blt 1f" } } */
-
-signed int stzreg_bgt(int i, int a, int b)
-{
-  signed int x;
-  x = a;
-  if (i<10)
-    x = b;
-  return x;
-}
-
-/* { dg-final { scan-assembler "ble 1f" } } */
-
-signed int stzreg_ble(int i, int a, int b)
-{
-  signed int x;
-  x = a;
-  if (i>0)
-    x = b;
-  return x;
-}
-
-/* { dg-final { scan-assembler "bgt 1f" } } */
-
-signed int stzreg_blt(int i, int a, int b)
-{
-  signed int x;
-  x = a;
-  if (i<0)
-    x = b;
-  return x;
-}
-
-/* { dg-final { scan-assembler "blt 1f" } } */
-
-signed int stzreg_bne(int i, int a, int b)
-{
-  signed int x;
-  x = a;
-  if (!i)
-    x = b;
-  return x;
-}
-
-/* { dg-final { scan-assembler "beq 1f" } } */
-
-signed int stzimm_le( int i, int a )
-{
-  signed int x;
-  x = a;
-  if (i>0)
-    x = 5;
-  return x;
-}
-
-/* { dg-final { scan-assembler "ble 1f" } } */
-
-signed int stzimm_le_r( int i, int a )
-{
-  signed int x;
-  x = a;
-  if (i<0)
-    x = 5;
-  return x;
-}
-
-/* { dg-final { scan-assembler "bge 1f" } } */