https://gcc.gnu.org/g:0696af74b3392e2178215607337b116d1bb53e34

commit r15-6960-g0696af74b3392e2178215607337b116d1bb53e34
Author: Peter Bergner <berg...@linux.ibm.com>
Date:   Thu Jan 16 10:53:27 2025 -0600

    rs6000: Fix ICE for invalid constants in built-in functions
    
    For invalid constant operand values used in built-in functions, return
    const0_rtx to signify an error occurred during expansion.
    
    2025-01-16  Peter Bergner  <berg...@linux.ibm.com>
    
    gcc/
            * config/rs6000/rs6000-builtin.cc (rs6000_expand_builtin): Return
            const0_rtx when there is an error.
    
    gcc/testsuite/
            * gcc.target/powerpc/mma-builtin-error.c: New test.

Diff:
---
 gcc/config/rs6000/rs6000-builtin.cc                  |  8 ++++----
 gcc/testsuite/gcc.target/powerpc/mma-builtin-error.c | 11 +++++++++++
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/gcc/config/rs6000/rs6000-builtin.cc 
b/gcc/config/rs6000/rs6000-builtin.cc
index 0251a240b1a1..111802381acb 100644
--- a/gcc/config/rs6000/rs6000-builtin.cc
+++ b/gcc/config/rs6000/rs6000-builtin.cc
@@ -3459,7 +3459,7 @@ rs6000_expand_builtin (tree exp, rtx target, rtx /* 
subtarget */,
                error ("argument %d must be a literal between 0 and %d,"
                       " inclusive",
                       bifaddr->restr_opnd[i], p);
-               return CONST0_RTX (mode[0]);
+               return const0_rtx;
              }
            break;
          }
@@ -3476,7 +3476,7 @@ rs6000_expand_builtin (tree exp, rtx target, rtx /* 
subtarget */,
                       " inclusive",
                       bifaddr->restr_opnd[i], bifaddr->restr_val1[i],
                       bifaddr->restr_val2[i]);
-               return CONST0_RTX (mode[0]);
+               return const0_rtx;
              }
            break;
          }
@@ -3493,7 +3493,7 @@ rs6000_expand_builtin (tree exp, rtx target, rtx /* 
subtarget */,
                       "between %d and %d, inclusive",
                       bifaddr->restr_opnd[i], bifaddr->restr_val1[i],
                       bifaddr->restr_val2[i]);
-               return CONST0_RTX (mode[0]);
+               return const0_rtx;
              }
            break;
          }
@@ -3509,7 +3509,7 @@ rs6000_expand_builtin (tree exp, rtx target, rtx /* 
subtarget */,
                       "literal %d",
                       bifaddr->restr_opnd[i], bifaddr->restr_val1[i],
                       bifaddr->restr_val2[i]);
-               return CONST0_RTX (mode[0]);
+               return const0_rtx;
              }
            break;
          }
diff --git a/gcc/testsuite/gcc.target/powerpc/mma-builtin-error.c 
b/gcc/testsuite/gcc.target/powerpc/mma-builtin-error.c
new file mode 100644
index 000000000000..a87a15709255
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/mma-builtin-error.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target power10_ok } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+typedef unsigned char vec_t __attribute__((vector_size(16)));
+
+void
+foo (__vector_quad *dst, vec_t vec0, vec_t vec1) /* { dg-error "argument 5 
must be a literal between 0 and 15, inclusive" } */
+{
+  __builtin_mma_pmxvi8ger4 (dst, vec0, vec1, 15, 15, -1);
+}

Reply via email to