Hello. Briefly described in the PR, running ICF (without any optimization level) can create a thunk call that does not use an SSA_NAME which is a default def of an argument of the caller:
c (complex float b) { complex float arg.1; float retval.0; <bb 2> [100.00%]: arg.1_2 = b; retval.0_4 = a (arg.1_2); [tail call] return retval.0_4; } The "arg" variable creation was introduced by Jason in r207301. As complex type is passed as invisible reference, we need to find address of the argument. Thus I'm suggesting to find it alternatively via SSA_NAME_DEF_STMT. Patch can bootstrap on ppc64le-redhat-linux and survives regression tests. And fixes the ICE on s390x cross compiler. Ready to be installed? Martin
>From 6624f7b292d174b5c0c1a276c1ed919c9930dca4 Mon Sep 17 00:00:00 2001 From: marxin <mli...@suse.cz> Date: Thu, 23 Mar 2017 16:03:04 +0100 Subject: [PATCH] Fix calls.c for a _complex type (PR ipa/80104). gcc/ChangeLog: 2017-03-23 Martin Liska <mli...@suse.cz> PR ipa/80104 * calls.c (initialize_argument_information): Find real argument of a gimple call (of thunk) in order to find address of the argument. gcc/testsuite/ChangeLog: 2017-03-23 Martin Liska <mli...@suse.cz> * gcc.dg/ipa/pr80104.c: New test. --- gcc/calls.c | 11 +++++++++-- gcc/testsuite/gcc.dg/ipa/pr80104.c | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/ipa/pr80104.c diff --git a/gcc/calls.c b/gcc/calls.c index 61caf4ca752..0ee21d9e951 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -1745,8 +1745,15 @@ initialize_argument_information (int num_actuals ATTRIBUTE_UNUSED, address. */ if (TREE_CODE (args[i].tree_value) == SSA_NAME) { - gcc_assert (SSA_NAME_IS_DEFAULT_DEF (args[i].tree_value)); - args[i].tree_value = SSA_NAME_VAR (args[i].tree_value); + if (SSA_NAME_IS_DEFAULT_DEF (args[i].tree_value)) + args[i].tree_value = SSA_NAME_VAR (args[i].tree_value); + else + { + gimple *g = SSA_NAME_DEF_STMT (args[i].tree_value); + if (gimple_assign_single_p (g)) + args[i].tree_value = gimple_assign_rhs1 (g); + } + gcc_assert (TREE_CODE (args[i].tree_value) == PARM_DECL); } /* Argument setup code may have copied the value to register. We diff --git a/gcc/testsuite/gcc.dg/ipa/pr80104.c b/gcc/testsuite/gcc.dg/ipa/pr80104.c new file mode 100644 index 00000000000..7e75c9907e7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/pr80104.c @@ -0,0 +1,15 @@ +/* PR ipa/80104 */ +/* { dg-do compile } */ +/* { dg-options "-fipa-icf" } */ + +float +a (_Complex float b) +{ + return *&b; +} + +float +c (_Complex float b) +{ + return (&b)[0]; +} -- 2.12.0