public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r10-10983] rs6000: Don't ICE when we disassemble an MMA variable [PR101322]
@ 2022-09-13 22:26 Peter Bergner
  0 siblings, 0 replies; only message in thread
From: Peter Bergner @ 2022-09-13 22:26 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:8301b8e84d833467b435b33592e0aa599d2db582

commit r10-10983-g8301b8e84d833467b435b33592e0aa599d2db582
Author: Peter Bergner <bergner@linux.ibm.com>
Date:   Wed Aug 31 21:14:36 2022 -0500

    rs6000: Don't ICE when we disassemble an MMA variable [PR101322]
    
    When we expand an MMA disassemble built-in with C++ using a pointer that
    is cast to a valid MMA type, the type isn't passed down to the expand
    machinery and we end up using the base type of the pointer which leads to
    an ICE.  This patch enforces we always use the correct MMA type regardless
    of the pointer type being used.
    
    2022-08-31  Peter Bergner  <bergner@linux.ibm.com>
    
    gcc/
            PR target/101322
            * config/rs6000/rs6000-call.c (rs6000_gimple_fold_mma_builtin):
            Enforce the use of a valid MMA pointer type.
    
    gcc/testsuite/
            PR target/101322
            * g++.target/powerpc/pr101322.C: New test.
    
    (cherry picked from commit 2985049049f12b0aa3366ca244d387820385b9e8)

Diff:
---
 gcc/config/rs6000/rs6000-call.c             |  7 ++++++-
 gcc/testsuite/g++.target/powerpc/pr101322.C | 17 +++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/gcc/config/rs6000/rs6000-call.c b/gcc/config/rs6000/rs6000-call.c
index 6a47389d564..c910ee5c71a 100644
--- a/gcc/config/rs6000/rs6000-call.c
+++ b/gcc/config/rs6000/rs6000-call.c
@@ -10855,7 +10855,12 @@ rs6000_gimple_fold_mma_builtin (gimple_stmt_iterator *gsi)
       push_gimplify_context (true);
       tree dst_ptr = gimple_call_arg (stmt, 0);
       tree src_ptr = gimple_call_arg (stmt, 1);
-      tree src_type = TREE_TYPE (src_ptr);
+      tree src_type = (fncode == MMA_BUILTIN_DISASSEMBLE_ACC)
+		      ? build_pointer_type (vector_quad_type_node)
+		      : build_pointer_type (vector_pair_type_node);
+      if (TREE_TYPE (src_ptr) != src_type)
+	src_ptr = build1 (NOP_EXPR, src_type, src_ptr);
+
       tree src = create_tmp_reg_or_ssa_name (TREE_TYPE (src_type));
       gimplify_assign (src, build_simple_mem_ref (src_ptr), &new_seq);
 
diff --git a/gcc/testsuite/g++.target/powerpc/pr101322.C b/gcc/testsuite/g++.target/powerpc/pr101322.C
new file mode 100644
index 00000000000..43eaf3afcd4
--- /dev/null
+++ b/gcc/testsuite/g++.target/powerpc/pr101322.C
@@ -0,0 +1,17 @@
+/* PR target/101322 */
+/* { dg-require-effective-target power10_ok } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Verify we don't ICE on the following test cases.  */
+
+void
+foo (char *resp, char *vpp)
+{
+  __builtin_vsx_disassemble_pair (resp, (__vector_pair *) vpp);
+}
+
+void
+bar (char *resp, char *vpp)
+{
+  __builtin_mma_disassemble_acc (resp, (__vector_quad *)vpp);
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-09-13 22:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-13 22:26 [gcc r10-10983] rs6000: Don't ICE when we disassemble an MMA variable [PR101322] Peter Bergner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).