Commit 0a6b0523 by Eric Botcazou Committed by Eric Botcazou

ipa-inline-analysis.c (param_change_prob): Get to the base object first in all cases.

	* ipa-inline-analysis.c (param_change_prob): Get to the base object
	first in all cases.

From-SVN: r239943
parent d87a85c6
2016-09-01 Eric Botcazou <ebotcazou@adacore.com>
* ipa-inline-analysis.c (param_change_prob): Get to the base object
first in all cases.
2016-09-01 Segher Boessenkool <segher@kernel.crashing.org> 2016-09-01 Segher Boessenkool <segher@kernel.crashing.org>
* config/rs6000/rs6000.md (*restore_gpregs_<mode>_r11, * config/rs6000/rs6000.md (*restore_gpregs_<mode>_r11,
......
...@@ -2183,28 +2183,33 @@ param_change_prob (gimple *stmt, int i) ...@@ -2183,28 +2183,33 @@ param_change_prob (gimple *stmt, int i)
{ {
tree op = gimple_call_arg (stmt, i); tree op = gimple_call_arg (stmt, i);
basic_block bb = gimple_bb (stmt); basic_block bb = gimple_bb (stmt);
tree base;
/* Global invariants neve change. */ if (TREE_CODE (op) == WITH_SIZE_EXPR)
if (is_gimple_min_invariant (op)) op = TREE_OPERAND (op, 0);
tree base = get_base_address (op);
/* Global invariants never change. */
if (is_gimple_min_invariant (base))
return 0; return 0;
/* We would have to do non-trivial analysis to really work out what /* We would have to do non-trivial analysis to really work out what
is the probability of value to change (i.e. when init statement is the probability of value to change (i.e. when init statement
is in a sibling loop of the call). is in a sibling loop of the call).
We do an conservative estimate: when call is executed N times more often We do an conservative estimate: when call is executed N times more often
than the statement defining value, we take the frequency 1/N. */ than the statement defining value, we take the frequency 1/N. */
if (TREE_CODE (op) == SSA_NAME) if (TREE_CODE (base) == SSA_NAME)
{ {
int init_freq; int init_freq;
if (!bb->frequency) if (!bb->frequency)
return REG_BR_PROB_BASE; return REG_BR_PROB_BASE;
if (SSA_NAME_IS_DEFAULT_DEF (op)) if (SSA_NAME_IS_DEFAULT_DEF (base))
init_freq = ENTRY_BLOCK_PTR_FOR_FN (cfun)->frequency; init_freq = ENTRY_BLOCK_PTR_FOR_FN (cfun)->frequency;
else else
init_freq = gimple_bb (SSA_NAME_DEF_STMT (op))->frequency; init_freq = gimple_bb (SSA_NAME_DEF_STMT (base))->frequency;
if (!init_freq) if (!init_freq)
init_freq = 1; init_freq = 1;
...@@ -2213,9 +2218,7 @@ param_change_prob (gimple *stmt, int i) ...@@ -2213,9 +2218,7 @@ param_change_prob (gimple *stmt, int i)
else else
return REG_BR_PROB_BASE; return REG_BR_PROB_BASE;
} }
else
base = get_base_address (op);
if (base)
{ {
ao_ref refd; ao_ref refd;
int max; int max;
...@@ -2256,7 +2259,6 @@ param_change_prob (gimple *stmt, int i) ...@@ -2256,7 +2259,6 @@ param_change_prob (gimple *stmt, int i)
else else
return REG_BR_PROB_BASE; return REG_BR_PROB_BASE;
} }
return REG_BR_PROB_BASE;
} }
/* Find whether a basic block BB is the final block of a (half) diamond CFG /* Find whether a basic block BB is the final block of a (half) diamond CFG
......
2016-09-01 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/opt58.adb: New test.
* gnat.dg/opt58_pkg.ads: New helper.
2016-09-01 Richard Biener <rguenther@suse.de> 2016-09-01 Richard Biener <rguenther@suse.de>
PR middle-end/77436 PR middle-end/77436
......
-- { dg-do compile }
-- { dg-options "-O" }
with Unchecked_Conversion;
with System; use System;
with Opt58_Pkg; use Opt58_Pkg;
procedure Opt58 is
function Convert is new Unchecked_Conversion (Integer, Rec);
Dword : Integer := 0;
I : Small_Int := F1 (Convert (Dword));
begin
if F2 (Null_Address, I = 0) then
null;
end if;
end Opt58;
with System; use System;
package Opt58_Pkg is
pragma Pure (Opt58_Pkg);
type Small_Int is range 0 .. 255;
type Rec is record
D1, D2, D3, D4 : Small_Int;
end record;
pragma Pack (Rec);
for Rec'Size use 32;
function F1 (R : Rec) return Small_Int;
function F2 (A : Address; B : Boolean) return Boolean;
end Opt58_Pkg;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment