diff mbox

[2/3] Const parameters are always unmodified

Message ID 20160512160844.GJ5580@virgil.suse.cz
State New
Headers show

Commit Message

Martin Jambor May 12, 2016, 4:08 p.m. UTC
Hi,

this patch simply makes parm_preserved_before_stmt_p consider all
const PARM_DECLs constant and does not invoke AA walking on them
(really the DECLs themselves, not the memory they might point to).

Bootstrapped and lto-bootstrapped and tested on x86_64-linux.  OK for
trunk?

Thanks,

Martin


2016-05-10  Martin Jambor  <mjambor@suse.cz>

	* ipa-prop.c (parm_preserved_before_stmt_p): Return true for loads
	from TREE_READONLY parameters.
---
 gcc/ipa-prop.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Jeff Law May 16, 2016, 7:15 p.m. UTC | #1
On 05/12/2016 10:08 AM, Martin Jambor wrote:
> Hi,
>
> this patch simply makes parm_preserved_before_stmt_p consider all
> const PARM_DECLs constant and does not invoke AA walking on them
> (really the DECLs themselves, not the memory they might point to).
>
> Bootstrapped and lto-bootstrapped and tested on x86_64-linux.  OK for
> trunk?
>
> Thanks,
>
> Martin
>
>
> 2016-05-10  Martin Jambor  <mjambor@suse.cz>
>
> 	* ipa-prop.c (parm_preserved_before_stmt_p): Return true for loads
> 	from TREE_READONLY parameters.
Seems like a good idea irrespective of the other patches in this series.

OK for the trunk.  Is this related to 69708, if so you might want to add 
that marker to the ChangeLog entry.


jeff
diff mbox

Patch

diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index afbc32b..7d869ed 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -803,6 +803,11 @@  parm_preserved_before_stmt_p (struct ipa_func_body_info *fbi, int index,
   bool modified = false;
   ao_ref refd;
 
+  tree base = get_base_address (parm_load);
+  gcc_assert (TREE_CODE (base) == PARM_DECL);
+  if (TREE_READONLY (base))
+    return true;
+
   /* FIXME: FBI can be NULL if we are being called from outside
      ipa_node_analysis or ipcp_transform_function, which currently happens
      during inlining analysis.  It would be great to extend fbi's lifetime and