[gcc r15-2225] report message for operator %a on unaddressible operand

2024-07-23 Thread Jiu Fu Guo via Gcc-cvs
https://gcc.gnu.org/g:472eab9ab1fdfd0ba3a555ea9eb50e20307c7052

commit r15-2225-g472eab9ab1fdfd0ba3a555ea9eb50e20307c7052
Author: Jiufu Guo 
Date:   Tue Jul 23 13:34:20 2024 +0800

report message for operator %a on unaddressible operand

Hi,

For PR96866, when printing asm code for modifier "%a", an addressable
operand is required.  While the constraint "X" allow any kind of
operand even which is hard to get the address directly. e.g. extern
symbol whose address is in TOC.
An error message would be reported to indicate the invalid asm operand.

Compare with previous version, test case is updated with -mno-pcrel.

Bootstrap®test pass on ppc64{,le}.
Is this ok for trunk?

BR,
Jeff(Jiufu Guo)

PR target/96866

gcc/ChangeLog:

* config/rs6000/rs6000.cc (print_operand_address): Emit message for
unsupported operand.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr96866-1.c: New test.
* gcc.target/powerpc/pr96866-2.c: New test.

Diff:
---
 gcc/config/rs6000/rs6000.cc  |  7 ++-
 gcc/testsuite/gcc.target/powerpc/pr96866-1.c | 18 ++
 gcc/testsuite/gcc.target/powerpc/pr96866-2.c | 13 +
 3 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index 85211565eb4c..0bcc6a2d0ab6 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -14706,7 +14706,12 @@ print_operand_address (FILE *file, rtx x)
fprintf (file, "@%s(%s)", SMALL_DATA_RELOC,
 reg_names[SMALL_DATA_REG]);
   else
-   gcc_assert (!TARGET_TOC);
+   {
+ /* Do not support getting address directly from TOC, emit error.
+No more work is needed for !TARGET_TOC. */
+ if (TARGET_TOC)
+   output_operand_lossage ("%%a requires an address of memory");
+   }
 }
   else if (GET_CODE (x) == PLUS && REG_P (XEXP (x, 0))
   && REG_P (XEXP (x, 1)))
diff --git a/gcc/testsuite/gcc.target/powerpc/pr96866-1.c 
b/gcc/testsuite/gcc.target/powerpc/pr96866-1.c
new file mode 100644
index ..72e59a19753a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr96866-1.c
@@ -0,0 +1,18 @@
+/* The "%a" modifier can't get the address of extern symbol directly from TOC
+   with -fPIC, even the symbol is propagated for "X" constraint under -O2. */
+/* { dg-options "-fPIC -O2 -mno-pcrel" } */
+
+/* It's to verify no ICE here, ignore error messages about invalid 'asm'.  */
+/* { dg-excess-errors "pr96866-1.c" } */
+
+int x[2];
+
+int __attribute__ ((noipa))
+f1 (void)
+{
+  int n;
+  int *p = x;
+  *p++;
+  __asm__ volatile("ld %0, %a1" : "=r"(n) : "X"(p));
+  return n;
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/pr96866-2.c 
b/gcc/testsuite/gcc.target/powerpc/pr96866-2.c
new file mode 100644
index ..72bb15fa04f4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr96866-2.c
@@ -0,0 +1,13 @@
+/* The "%a" modifier can't get the address of extern symbol directly from TOC
+   with -fPIC. */
+/* { dg-options "-fPIC -O2 -mno-pcrel" } */
+
+/* It's to verify no ICE here, ignore error messages about invalid 'asm'.  */
+/* { dg-excess-errors "pr96866-2.c" } */
+
+void
+f (void)
+{
+  extern int x;
+  __asm__ volatile("#%a0" ::"X"(&x));
+}


[gcc r15-14] s390: avoid peeking eof after __vector

2024-04-27 Thread Jiu Fu Guo via Gcc-cvs
https://gcc.gnu.org/g:83bc41e8364360b63eaa59c88e2fb499a6751233

commit r15-14-g83bc41e8364360b63eaa59c88e2fb499a6751233
Author: Jiufu Guo 
Date:   Wed Mar 27 14:15:40 2024 +0800

s390: avoid peeking eof after __vector

Same like PR101168, it is need for s390 to
avoid peeking eof after vector keyword.
And similar test case is also ok for s390.

PR target/95782

gcc/ChangeLog:

* config/s390/s390-c.cc (s390_macro_to_expand): Avoid empty 
identifier.

gcc/testsuite/ChangeLog:

* g++.target/s390/pr95782.C: New test.

Diff:
---
 gcc/config/s390/s390-c.cc   | 4 +++-
 gcc/testsuite/g++.target/s390/pr95782.C | 5 +
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/gcc/config/s390/s390-c.cc b/gcc/config/s390/s390-c.cc
index 1bb6e810766..4521a86f048 100644
--- a/gcc/config/s390/s390-c.cc
+++ b/gcc/config/s390/s390-c.cc
@@ -275,7 +275,9 @@ s390_macro_to_expand (cpp_reader *pfile, const cpp_token 
*tok)
   /* __vector long __bool a; */
   if (ident == C_CPP_HASHNODE (__bool_keyword))
expand_bool_p = true;
-  else
+
+  /* If there are more tokens to check.  */
+  else if (ident)
{
  /* Triggered with: __vector long long __bool a; */
  do
diff --git a/gcc/testsuite/g++.target/s390/pr95782.C 
b/gcc/testsuite/g++.target/s390/pr95782.C
new file mode 100644
index 000..daf887fc6fe
--- /dev/null
+++ b/gcc/testsuite/g++.target/s390/pr95782.C
@@ -0,0 +1,5 @@
+// { dg-do compile }
+// { dg-options "-march=z14 -mzvector" }
+
+using vdbl =  __vector double;
+#define BREAK 1


[gcc r15-790] missing require target has_arch_ppc64 for pr106550.c

2024-05-23 Thread Jiu Fu Guo via Gcc-cvs
https://gcc.gnu.org/g:4efa7ec85a85c6024d0907a0e735ad5df7fca952

commit r15-790-g4efa7ec85a85c6024d0907a0e735ad5df7fca952
Author: Jiufu Guo 
Date:   Wed May 22 10:33:11 2024 +0800

missing require target has_arch_ppc64 for pr106550.c

Hi,

Case pr106550.c is testing constant building for 64bit
register. It fails with -m32 without having the expected rldimi.
So, this case requires target of has_arch_ppc64.

Bootstrap and regtest pass on ppc64{,le}.
Is this ok for trunk?

BR,
Jeff(Jiufu) Guo

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr106550.c: Adjust by requiring has_arch_ppc64
effective target. And remove power10_ok.

Diff:
---
 gcc/testsuite/gcc.target/powerpc/pr106550.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.target/powerpc/pr106550.c 
b/gcc/testsuite/gcc.target/powerpc/pr106550.c
index 74e395331ab..92b76ac8811 100644
--- a/gcc/testsuite/gcc.target/powerpc/pr106550.c
+++ b/gcc/testsuite/gcc.target/powerpc/pr106550.c
@@ -1,6 +1,6 @@
 /* PR target/106550 */
 /* { dg-options "-O2 -mdejagnu-cpu=power10" } */
-/* { dg-require-effective-target power10_ok } */
+/* { dg-require-effective-target has_arch_ppc64 } */
 
 void
 foo (unsigned long long *a)