rs6000: Fix ICE in decompose_normal_address. [PR93974]
authorPeter Bergner <bergner@linux.ibm.com>
Fri, 17 Apr 2020 04:26:41 +0000 (23:26 -0500)
committerPeter Bergner <bergner@linux.ibm.com>
Fri, 17 Apr 2020 04:26:41 +0000 (23:26 -0500)
Fix an ICE in decompose_normal_address(), which cannot handle Altivec AND:
addresses, by disallowing them via implementing the target hook
rs6000_cannot_substitute_mem_equiv_p.

gcc/
PR rtl-optimization/93974
* config/rs6000/rs6000.c (TARGET_CANNOT_SUBSTITUTE_MEM_EQUIV_P): Define.
(rs6000_cannot_substitute_mem_equiv_p): New function.

gcc/testsuite/
PR rtl-optimization/93974
* g++.dg/pr93974.C: New test.

gcc/ChangeLog
gcc/config/rs6000/rs6000.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/pr93974.C [new file with mode: 0644]

index 5fd869a92393ed6ba6328fb3ff71eb1350025691..53413e7b9437dd9eeac83ab7272d2a7436ae81a5 100644 (file)
@@ -1,3 +1,9 @@
+2020-04-16  Peter Bergner  <bergner@linux.ibm.com>
+
+       PR rtl-optimization/93974
+       * config/rs6000/rs6000.c (TARGET_CANNOT_SUBSTITUTE_MEM_EQUIV_P): Define.
+       (rs6000_cannot_substitute_mem_equiv_p): New function.
+
 2020-04-16  Martin Jambor  <mjambor@suse.cz>
 
        PR ipa/93621
index 4defc1ab52be141ad7a42685a3548c42c6d4c868..a2992e682c8f35a3c7e9c1a266bcd3735e7d5e09 100644 (file)
@@ -1734,6 +1734,10 @@ static const struct attribute_spec rs6000_attribute_table[] =
 
 #undef TARGET_MANGLE_DECL_ASSEMBLER_NAME
 #define TARGET_MANGLE_DECL_ASSEMBLER_NAME rs6000_mangle_decl_assembler_name
+
+#undef TARGET_CANNOT_SUBSTITUTE_MEM_EQUIV_P
+#define TARGET_CANNOT_SUBSTITUTE_MEM_EQUIV_P \
+  rs6000_cannot_substitute_mem_equiv_p
 \f
 
 /* Processor table.  */
@@ -26375,6 +26379,22 @@ rs6000_predict_doloop_p (struct loop *loop)
   return true;
 }
 
+/* Implement TARGET_CANNOT_SUBSTITUTE_MEM_EQUIV_P.  */
+
+static bool
+rs6000_cannot_substitute_mem_equiv_p (rtx mem)
+{
+  gcc_assert (MEM_P (mem));
+
+  /* curr_insn_transform()'s handling of subregs cannot handle altivec AND:
+     type addresses, so don't allow MEMs with those address types to be
+     substituted as an equivalent expression.  See PR93974 for details.  */
+  if (GET_CODE (XEXP (mem, 0)) == AND)
+    return true;
+
+  return false;
+}
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-rs6000.h"
index d862567ce4fa4d7b25c577a5ccdbbef35906bd4b..e10dc694e412d71afe95bd5435f9ddd7e0955608 100644 (file)
@@ -1,3 +1,8 @@
+2020-04-16  Peter Bergner  <bergner@linux.ibm.com>
+
+       PR rtl-optimization/93974
+       * g++.dg/pr93974.C: New test.
+
 2020-04-16  Iain Sandoe  <iain@sandoe.co.uk>
 
        * g++.dg/cpp0x/lambda/pr94426-2.C: Adjust scan-asms to test
diff --git a/gcc/testsuite/g++.dg/pr93974.C b/gcc/testsuite/g++.dg/pr93974.C
new file mode 100644 (file)
index 0000000..562de0a
--- /dev/null
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_p8vector_ok } */
+/* { dg-options "-mdejagnu-cpu=power8 -O3 -fstack-protector-strong" } */
+
+class a {
+  double b[2];
+public:
+  a();
+};
+
+class c {
+public:
+  typedef a d;
+  d m_fn1() {
+    a e;
+    return e;
+  }
+};
+template <typename f> void operator+(f, typename f::d);
+void g() {
+  c connector;
+  for (;;) {
+    c cut;
+    a h = cut.m_fn1();
+    connector + h;
+  }
+}