From b7f08b83e430cf571c78bd48807b2a8e639c202c Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Sat, 25 Nov 2017 11:19:16 +0100 Subject: [PATCH] re PR target/82848 (ICE in expand_expr_real_2, at expr.c:8715) 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 | 6 ++++++ gcc/config/rs6000/rs6000.c | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.target/powerpc/pr82848.c | 13 +++++++++++++ 4 files changed, 30 insertions(+) create mode 100644 gcc/testsuite/gcc.target/powerpc/pr82848.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index dc52c16d6fb..5e8b5388b20 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-11-25 Jakub Jelinek + + 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 PR tree-optimization/71026 diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 7212cddc9a7..4df87ea7556 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0a8532ce703..545c39dccdd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-11-25 Jakub Jelinek + + PR target/82848 + * gcc.target/powerpc/pr82848.c: New test. + 2017-11-24 Jackson Woodruff 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 index 00000000000..80a0f8c83bc --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr82848.c @@ -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; +} -- 2.30.2