[Bug ipa/69708] ipa inline not working for function reference in static const struct

2016-05-18 Thread jamborm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69708

Martin Jambor  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #8 from Martin Jambor  ---
We should now be inlining as desired in the testcase.

[Bug ipa/69708] ipa inline not working for function reference in static const struct

2016-05-18 Thread jamborm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69708

--- Comment #7 from Martin Jambor  ---
Author: jamborm
Date: Wed May 18 16:44:08 2016
New Revision: 236418

URL: https://gcc.gnu.org/viewcvs?rev=236418=gcc=rev
Log:
Allow constant global VAR_DECLs in constant jump functions

2016-05-18  Martin Jambor  

PR ipa/69708
* ipa-cp.c (ipa_get_jf_pass_through_result): Allow non-ip constant
input for NOP_EXPR pass-through functions.
* ipa-prop.c (ipa_compute_jump_functions_for_edge): Allow
aggregate global constant VAR_DECLs in constant jump functions.

testsuite/
* gcc.dg/ipa/iinline-cstagg-2.c: New test.
* gcc.dg/ipa/ipcp-cstagg-5.c: Likewise.
* gcc.dg/ipa/ipcp-cstagg-6.c: Likewise.
* gcc.dg/ipa/ipcp-cstagg-7.c: Likewise.


Added:
trunk/gcc/testsuite/gcc.dg/ipa/iinline-cstagg-2.c
trunk/gcc/testsuite/gcc.dg/ipa/ipcp-cstagg-5.c
trunk/gcc/testsuite/gcc.dg/ipa/ipcp-cstagg-6.c
trunk/gcc/testsuite/gcc.dg/ipa/ipcp-cstagg-7.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/ipa-cp.c
trunk/gcc/ipa-prop.c
trunk/gcc/testsuite/ChangeLog

[Bug ipa/69708] ipa inline not working for function reference in static const struct

2016-05-18 Thread jamborm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69708

--- Comment #6 from Martin Jambor  ---
Author: jamborm
Date: Wed May 18 16:41:19 2016
New Revision: 236417

URL: https://gcc.gnu.org/viewcvs?rev=236417=gcc=rev
Log:
Const parameters are always unmodified

2016-05-18  Martin Jambor  

PR ipa/69708
* ipa-prop.c (parm_preserved_before_stmt_p): Return true for loads
from TREE_READONLY parameters.


Modified:
trunk/gcc/ChangeLog
trunk/gcc/ipa-prop.c

[Bug ipa/69708] ipa inline not working for function reference in static const struct

2016-05-18 Thread jamborm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69708

--- Comment #5 from Martin Jambor  ---
Author: jamborm
Date: Wed May 18 16:38:56 2016
New Revision: 236416

URL: https://gcc.gnu.org/viewcvs?rev=236416=gcc=rev
Log:
Indirect inlining of targets from references of global constants

2016-05-18  Martin Jambor  

PR ipa/69708
* cgraph.h (cgraph_indirect_call_info): New field
guaranteed_unmodified.
* ipa-cp.c (ipa_get_indirect_edge_target_1): Also pass parameter value
to ipa_find_agg_cst_for_param, check guaranteed_unmodified when
appropriate.
* ipa-inline-analysis.c (evaluate_conditions_for_known_args): Also
pass the parameter value to ipa_find_agg_cst_for_param.
* ipa-prop.c (ipa_load_from_parm_agg): New parameter
guaranteed_unmodified, store AA results there instead of bailing out
if present.
(ipa_note_param_call): Also initialize guaranteed_unmodified flag.
(ipa_analyze_indirect_call_uses): Also set guaranteed_unmodified flag.
(find_constructor_constant_at_offset): New function.
(ipa_find_agg_cst_from_init): Likewise.
(ipa_find_agg_cst_for_param): Also seearch for aggregate values in
static initializers of contants, report back through a new paameter
from_global_constant if that was the case.
(try_make_edge_direct_simple_call): Also pass parameter value to
ipa_find_agg_cst_for_param, check guaranteed_unmodified when
appropriate.
(ipa_write_indirect_edge_info): Stream new flag guaranteed_unmodified.
(ipa_read_indirect_edge_info): Likewise.
* ipa-prop.h (ipa_find_agg_cst_for_param): Update declaration.
(ipa_load_from_parm_agg): Likewise.

testsuite/
* gcc.dg/ipa/iinline-cstagg-1.c: New test.
* gcc.dg/ipa/ipcp-cstagg-1.c: Likewise.
* gcc.dg/ipa/ipcp-cstagg-2.c: Likewise.
* gcc.dg/ipa/ipcp-cstagg-3.c: Likewise.
* gcc.dg/ipa/ipcp-cstagg-4.c: Likewise.


Added:
trunk/gcc/testsuite/gcc.dg/ipa/iinline-cstagg-1.c
trunk/gcc/testsuite/gcc.dg/ipa/ipcp-cstagg-1.c
trunk/gcc/testsuite/gcc.dg/ipa/ipcp-cstagg-2.c
trunk/gcc/testsuite/gcc.dg/ipa/ipcp-cstagg-3.c
trunk/gcc/testsuite/gcc.dg/ipa/ipcp-cstagg-4.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/cgraph.h
trunk/gcc/ipa-cp.c
trunk/gcc/ipa-inline-analysis.c
trunk/gcc/ipa-prop.c
trunk/gcc/ipa-prop.h
trunk/gcc/testsuite/ChangeLog

[Bug ipa/69708] ipa inline not working for function reference in static const struct

2016-03-10 Thread jamborm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69708

--- Comment #4 from Martin Jambor  ---
I've posted one possible implementation of this feature to the mailing
list along with an explanation why it makes sense to actually do it
better and how :-)

https://gcc.gnu.org/ml/gcc-patches/2016-03/msg00649.html

[Bug ipa/69708] ipa inline not working for function reference in static const struct

2016-02-13 Thread kugan at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69708

--- Comment #3 from kugan at gcc dot gnu.org ---
Created attachment 37685
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37685=edit
possible fix

Attached patch fixes the testcase.

[Bug ipa/69708] ipa inline not working for function reference in static const struct

2016-02-11 Thread kugan at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69708

kugan at gcc dot gnu.org changed:

   What|Removed |Added

 CC||kugan at gcc dot gnu.org

--- Comment #2 from kugan at gcc dot gnu.org ---
In ipa-prop.c, function ipa_compute_jump_functions_for_edge called from
determine_locally_known_aggregate_parts doesn't compute jump functions for
aggregates when they are initialized during definition.

If I change the testcase to following, it works.

typedef struct F {
int (*call)(int);
} F;

static int g(F f, int x) {
x = f.call(x);
x = f.call(x);
x = f.call(x);
x = f.call(x);
x = f.call(x);
x = f.call(x);
x = f.call(x);
x = f.call(x);
return x;
}

static int sq(int x) {
return x * x;
}

static F f = {sq};
//static const F f = {sq};

void dosomething(int);

int h(int x) {
f.call = sq;
dosomething(g(f, x));
dosomething(g((F){sq}, x));
}

I guess, for the varpool_node corresponding to static const F f = {sq};, we
have to check hat the initialization are constant and create the jump function.

I still haven't figured out how I can get the initialization list for the
structure. Any pointers?

varpool_node *node = varpool_node::get (arg); should get me to the varpool
node.

[Bug ipa/69708] ipa inline not working for function reference in static const struct

2016-02-08 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69708

Richard Biener  changed:

   What|Removed |Added

   Keywords||missed-optimization
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2016-02-08
 CC||hubicka at gcc dot gnu.org,
   ||jamborm at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #1 from Richard Biener  ---
Confirmed.