From 24d5b351b1bb9d2fd66202cbf76857c404e06e85 Mon Sep 17 00:00:00 2001 From: Bill Schmidt Date: Tue, 24 Apr 2012 15:51:58 +0000 Subject: [PATCH] re PR target/47197 (ICE in gimplify_expr, at gimplify.c:7153 on AltiVec code (vec_dst)) gcc: 2012-04-24 Bill Schmidt PR target/47197 * config/rs6000/rs6000-c.c (fully_fold_convert): New function. (altivec_build_resolved_builtin): Call fully_fold_convert. gcc/testsuite: 2012-04-24 Bill Schmidt PR target/47197 * gcc.target/powerpc/pr47197.c: New test. From-SVN: r186771 --- gcc/ChangeLog | 6 +++++ gcc/config/rs6000/rs6000-c.c | 28 +++++++++++++++++----- gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/gcc.target/powerpc/pr47197.c | 12 ++++++++++ 4 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/pr47197.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9d55ef06477..5eb9411fc13 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2012-04-24 Bill Schmidt + + PR target/47197 + * config/rs6000/rs6000-c.c (fully_fold_convert): New function. + (altivec_build_resolved_builtin): Call fully_fold_convert. + 2012-04-24 Georg-Johann Lay PR target/53065 diff --git a/gcc/config/rs6000/rs6000-c.c b/gcc/config/rs6000/rs6000-c.c index 76a21463ec3..0717b91b2bc 100644 --- a/gcc/config/rs6000/rs6000-c.c +++ b/gcc/config/rs6000/rs6000-c.c @@ -3421,6 +3421,22 @@ rs6000_builtin_type_compatible (tree t, int id) } +/* In addition to calling fold_convert for EXPR of type TYPE, also + call c_fully_fold to remove any C_MAYBE_CONST_EXPRs that could be + hiding there (PR47197). */ + +static tree +fully_fold_convert (tree type, tree expr) +{ + tree result = fold_convert (type, expr); + bool maybe_const = true; + + if (!c_dialect_cxx ()) + result = c_fully_fold (result, false, &maybe_const); + + return result; +} + /* Build a tree for a function call to an Altivec non-overloaded builtin. The overloaded builtin that matched the types and args is described by DESC. The N arguments are given in ARGS, respectively. @@ -3470,18 +3486,18 @@ altivec_build_resolved_builtin (tree *args, int n, break; case 1: call = build_call_expr (impl_fndecl, 1, - fold_convert (arg_type[0], args[0])); + fully_fold_convert (arg_type[0], args[0])); break; case 2: call = build_call_expr (impl_fndecl, 2, - fold_convert (arg_type[0], args[0]), - fold_convert (arg_type[1], args[1])); + fully_fold_convert (arg_type[0], args[0]), + fully_fold_convert (arg_type[1], args[1])); break; case 3: call = build_call_expr (impl_fndecl, 3, - fold_convert (arg_type[0], args[0]), - fold_convert (arg_type[1], args[1]), - fold_convert (arg_type[2], args[2])); + fully_fold_convert (arg_type[0], args[0]), + fully_fold_convert (arg_type[1], args[1]), + fully_fold_convert (arg_type[2], args[2])); break; default: gcc_unreachable (); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 646a150f134..0a4d974ef08 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-04-24 Bill Schmidt + + PR target/47197 + * gcc.target/powerpc/pr47197.c: New test. + 2012-04-24 Richard Guenther PR tree-optimization/53085 diff --git a/gcc/testsuite/gcc.target/powerpc/pr47197.c b/gcc/testsuite/gcc.target/powerpc/pr47197.c new file mode 100644 index 00000000000..729dcfb364a --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr47197.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-maltivec" } */ + +/* Compile-only test to ensure that expressions can be passed to + Altivec builtins without error. */ + +#include + +void func(unsigned char *buf, unsigned len) +{ + vec_dst(buf, (len >= 256 ? 0 : len) | 512, 2); +} -- 2.30.2