+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>
* config/rs6000/rs6000.md (*restore_gpregs_<mode>_r11,
{
tree op = gimple_call_arg (stmt, i);
basic_block bb = gimple_bb (stmt);
- tree base;
- /* Global invariants neve change. */
- if (is_gimple_min_invariant (op))
+ if (TREE_CODE (op) == WITH_SIZE_EXPR)
+ op = TREE_OPERAND (op, 0);
+
+ tree base = get_base_address (op);
+
+ /* Global invariants never change. */
+ if (is_gimple_min_invariant (base))
return 0;
+
/* 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 in a sibling loop of the call).
We do an conservative estimate: when call is executed N times more often
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;
if (!bb->frequency)
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;
else
- init_freq = gimple_bb (SSA_NAME_DEF_STMT (op))->frequency;
+ init_freq = gimple_bb (SSA_NAME_DEF_STMT (base))->frequency;
if (!init_freq)
init_freq = 1;
else
return REG_BR_PROB_BASE;
}
-
- base = get_base_address (op);
- if (base)
+ else
{
ao_ref refd;
int max;
else
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
--- /dev/null
+-- { dg-do compile }\r
+-- { dg-options "-O" }\r
+\r
+with Unchecked_Conversion;\r
+with System; use System;\r
+with Opt58_Pkg; use Opt58_Pkg;\r
+\r
+procedure Opt58 is\r
+\r
+ function Convert is new Unchecked_Conversion (Integer, Rec);\r
+\r
+ Dword : Integer := 0;\r
+ I : Small_Int := F1 (Convert (Dword));\r
+\r
+begin\r
+ if F2 (Null_Address, I = 0) then\r
+ null;\r
+ end if;\r
+end Opt58;\r
--- /dev/null
+with System; use System;\r
+\r
+package Opt58_Pkg is\r
+\r
+ pragma Pure (Opt58_Pkg);\r
+\r
+ type Small_Int is range 0 .. 255;\r
+\r
+ type Rec is record\r
+ D1, D2, D3, D4 : Small_Int;\r
+ end record;\r
+ pragma Pack (Rec);\r
+ for Rec'Size use 32;\r
+\r
+ function F1 (R : Rec) return Small_Int;\r
+\r
+ function F2 (A : Address; B : Boolean) return Boolean;\r
+\r
+end Opt58_Pkg;\r