re PR target/82848 (ICE in expand_expr_real_2, at expr.c:8715)
authorJakub Jelinek <jakub@redhat.com>
Sat, 25 Nov 2017 10:19:16 +0000 (11:19 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sat, 25 Nov 2017 10:19:16 +0000 (11:19 +0100)
PR target/82848
* config/rs6000/rs6000.c (rs6000_gimple_fold_builtin): Don't fold
builtins not enabled in the currently selected ISA.

* gcc.target/powerpc/pr82848.c: New test.

From-SVN: r255148

gcc/ChangeLog
gcc/config/rs6000/rs6000.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/powerpc/pr82848.c [new file with mode: 0644]

index dc52c16d6fbc452504622bc124d969ed5797cdcc..5e8b5388b2022055b4cc0a9bee0ef94754d14c9c 100644 (file)
@@ -1,3 +1,9 @@
+2017-11-25  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/82848
+       * config/rs6000/rs6000.c (rs6000_gimple_fold_builtin): Don't fold
+       builtins not enabled in the currently selected ISA.
+
 2017-11-24  Jackson Woodruff  <jackson.woodruff@arm.com>
 
        PR tree-optimization/71026
index 7212cddc9a76e29bd9ca2d52d1b6247d0d97389f..4df87ea755659244db66f8dc1059701ab46c29f5 100644 (file)
@@ -16143,6 +16143,12 @@ rs6000_gimple_fold_builtin (gimple_stmt_iterator *gsi)
   if (!gimple_call_lhs (stmt) && !rs6000_builtin_valid_without_lhs (fn_code))
     return false;
 
+  /* Don't fold invalid builtins, let rs6000_expand_builtin diagnose it.  */
+  HOST_WIDE_INT mask = rs6000_builtin_info[uns_fncode].mask;
+  bool func_valid_p = (rs6000_builtin_mask & mask) == mask;
+  if (!func_valid_p)
+    return false;
+
   switch (fn_code)
     {
     /* Flavors of vec_add.  We deliberately don't expand
index 0a8532ce7038818dac74235342426155c8686575..545c39dccdd68a2d8131c854eb7dfe1277b87752 100644 (file)
@@ -1,3 +1,8 @@
+2017-11-25  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/82848
+       * gcc.target/powerpc/pr82848.c: New test.
+
 2017-11-24  Jackson Woodruff  <jackson.woodruff@arm.com>
 
        PR tree-optimization/71026
diff --git a/gcc/testsuite/gcc.target/powerpc/pr82848.c b/gcc/testsuite/gcc.target/powerpc/pr82848.c
new file mode 100644 (file)
index 0000000..80a0f8c
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR target/82848 */
+/* { dg-do compile } */
+/* { dg-options "-mno-altivec -mno-vsx -Wno-psabi" } */
+
+#define C 3.68249351546114573519399405666776E-44f
+#define vector __attribute__ ((altivec (vector__)))
+
+vector float
+foo (vector float a)
+{
+  vector float b = __builtin_vec_madd (b, a, (vector float) { C, C, C, C });   /* { dg-error "requires the '-maltivec' option" } */
+  return b;
+}