The __builtin_scalar_byte_in_set() built-in emits the cmpeqb instruction
which produces undefined results when run in 32-bit mode.  The current
selector [power9-64] enables the built-in when using -m32 -mpowerpc64.
Use the  no32bit attribute to fully disable it for all -m32 compiles.

This was bootstrapped and regtested on powerpc64-linux with running the
testsuite in both 32-bit and 64-bit modes with no regressions.  I then
reran the test case with both -m32 -mno-powerpc64 and -m32 -mpowerpc64
and we get PASSes for both compiles.

Ok for trunk and the release branches after some trunk burn-in time?

Peter


gcc/
        PR target/119629
        * config/rs6000/rs6000-logue.cc (__builtin_scalar_byte_in_set): Use
        the no32bit attribute.

gcc/testsuite/
        PR target/119629
        * gcc.target/powerpc/byte-in-set-2.c (dg-error): Update acceptable
        error messages.


diff --git a/gcc/config/rs6000/rs6000-builtins.def 
b/gcc/config/rs6000/rs6000-builtins.def
index 555d7d58950..56b3a544b7d 100644
--- a/gcc/config/rs6000/rs6000-builtins.def
+++ b/gcc/config/rs6000/rs6000-builtins.def
@@ -2650,7 +2650,7 @@
     STXVL stxvl {}
 
   const signed int __builtin_scalar_byte_in_set (signed int, signed long long);
-    CMPEQB cmpeqb {}
+    CMPEQB cmpeqb {no32bit}
 
   pure vsc __builtin_vsx_lxvl (const void *, signed long);
     LXVL lxvl {}
diff --git a/gcc/testsuite/gcc.target/powerpc/byte-in-set-2.c 
b/gcc/testsuite/gcc.target/powerpc/byte-in-set-2.c
index e7cdebe533d..cf16ca421e2 100644
--- a/gcc/testsuite/gcc.target/powerpc/byte-in-set-2.c
+++ b/gcc/testsuite/gcc.target/powerpc/byte-in-set-2.c
@@ -10,5 +10,8 @@
 int
 test_byte_in_set (unsigned char b, unsigned long long set_members)
 {
-  return __builtin_byte_in_set (b, set_members); /* { dg-error 
"'__builtin_scalar_byte_in_set' requires the" } */
+  /* The built-in machinery gives us two different error messages depending
+     on if -m32 -mno-powerpc64 or -m32 -mpowerpc64 was used to compile this
+     test case.  Accept both error messages.  */
+  return __builtin_byte_in_set (b, set_members); /* { dg-error 
"'__builtin_scalar_byte_in_set' (requires the|is not supported)" } */
 }

Reply via email to