RISC-V: testsuite: Fix strcmp-run.c test.

Message ID 76c97d30-6c37-4f90-95f7-4e6231dd4331@gmail.com
State Committed
Headers
Series RISC-V: testsuite: Fix strcmp-run.c test. |

Checks

Context Check Description
rivoscibot/toolchain-ci-rivos-lint success Lint passed
rivoscibot/toolchain-ci-rivos-apply-patch success Patch applied
linaro-tcwg-bot/tcwg_gcc_build--master-arm warning Patch is already merged
rivoscibot/toolchain-ci-rivos-build--newlib-rv64gc-lp64d-multilib success Build passed
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 warning Patch is already merged
rivoscibot/toolchain-ci-rivos-build--linux-rv64gc_zba_zbb_zbc_zbs-lp64d-non-multilib success Build passed
rivoscibot/toolchain-ci-rivos-build--linux-rv32gc_zba_zbb_zbc_zbs-ilp32d-non-multilib success Build passed
rivoscibot/toolchain-ci-rivos-build--newlib-rv64gcv-lp64d-multilib success Build passed
rivoscibot/toolchain-ci-rivos-build--linux-rv64gcv-lp64d-multilib success Build passed
rivoscibot/toolchain-ci-rivos-test fail Testing failed

Commit Message

Robin Dapp Dec. 11, 2023, 1:40 p.m. UTC
  Hi,

this fixes expectations in the strcmp-run test which would sometimes
fail with newlib.  The test expects libc strcmp return values and
asserts the vectorized result is similar to those.  Therefore hard-code
the expected results instead of relying on a strcmp call.

Pan has already tested in a lot of configurations and doesn't see
failures anymore.

I'd argue it's obvious enough to push it if nobody complains :)

Regards
 Robin

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/builtin/strcmp-run.c: Adjust test
	expectation.
---
 .../riscv/rvv/autovec/builtin/strcmp-run.c    | 23 ++++++++++---------
 1 file changed, 12 insertions(+), 11 deletions(-)
  

Patch

diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/builtin/strcmp-run.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/builtin/strcmp-run.c
index 6dec7da91c1..adbe022e0ee 100644
--- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/builtin/strcmp-run.c
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/builtin/strcmp-run.c
@@ -1,8 +1,6 @@ 
 /* { dg-do run } */
 /* { dg-additional-options "-O3 -minline-strcmp" } */
 
-#include <string.h>
-
 int
 __attribute__ ((noipa))
 foo (const char *s, const char *t)
@@ -10,23 +8,26 @@  foo (const char *s, const char *t)
   return __builtin_strcmp (s, t);
 }
 
-int
-__attribute__ ((noipa, optimize ("0")))
-foo2 (const char *s, const char *t)
-{
-  return strcmp (s, t);
-}
-
 #define SZ 10
 
-int main ()
+int
+main ()
 {
   const char *s[SZ]
     = {"",  "asdf", "0", "\0", "!@#$%***m1123fdnmoi43",
        "a", "z",    "1", "9",  "12345678901234567889012345678901234567890"};
 
+  const int ref[SZ * SZ]
+    = {0,   -97, -48, 0,   -33, -97, -122, -49, -57, -49, 97,  0,   49,	 97, 64,
+       115, -25, 48,  40,  48,	48,  -49,  0,	48,  15,  -49, -74, -1,	 -9, -1,
+       0,   -97, -48, 0,   -33, -97, -122, -49, -57, -49, 33,  -64, -15, 33, 0,
+       -64, -89, -16, -24, -16, 97,  -115, 49,	97,  64,  0,   -25, 48,	 40, 48,
+       122, 25,	 74,  122, 89,	25,  0,	   73,	65,  73,  49,  -48, 1,	 49, 16,
+       -48, -73, 0,   -8,  -50, 57,  -40,  9,	57,  24,  -40, -65, 8,	 0,  8,
+       49,  -48, 1,   49,  16,	-48, -73,  50,	-8,  0};
+
   for (int i = 0; i < SZ; i++)
     for (int j = 0; j < SZ; j++)
-      if (foo (s[i], s[j]) != foo2 (s[i], s[j]))
+      if (foo (s[i], s[j]) != ref [i * SZ + j])
         __builtin_abort ();
 }