tree-optimization/112444 - avoid bougs PHI value-numbering
With .DEFERRED_INIT ssa_undefined_value_p () can return true for values we did not visit (because they proved unreachable) but are not .VN_TOP. Avoid using those as value which, because they are not visited, are assumed to be defined outside of the region. PR tree-optimization/112444 * tree-ssa-sccvn.cc (visit_phi): Avoid using not visited defs as undefined vals. * gcc.dg/torture/pr112444.c: New testcase.
This commit is contained in:
parent
a0273d257c
commit
8ebcea91e2
2 changed files with 79 additions and 2 deletions
65
gcc/testsuite/gcc.dg/torture/pr112444.c
Normal file
65
gcc/testsuite/gcc.dg/torture/pr112444.c
Normal file
|
@ -0,0 +1,65 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-additional-options "-ftrivial-auto-var-init=zero" } */
|
||||
|
||||
int qmi_message_pbm_get_all_capabilities_output_capability_basic_information_get_printable_message_offset,
|
||||
qmi_message_pbm_get_all_capabilities_output_capability_basic_information_get_printable_message_init_offset,
|
||||
qmi_message_pbm_get_all_capabilities_output_capability_basic_information_get_printable_message_error,
|
||||
qmi_message_pbm_get_all_capabilities_output_capability_basic_information_get_printable_message_phonebooks_i;
|
||||
|
||||
int g_string_new(), g_string_append_len(), qmi_message_tlv_read_guint8();
|
||||
|
||||
void qmi_message_pbm_get_all_capabilities_output_capability_basic_information_get_printable_message() {
|
||||
int printable = g_string_new();
|
||||
for (;;) {
|
||||
{
|
||||
if (__builtin_expect(({
|
||||
int _g_boolean_var_4;
|
||||
if (printable)
|
||||
_g_boolean_var_4 = 1;
|
||||
else
|
||||
_g_boolean_var_4 = 0;
|
||||
_g_boolean_var_4;
|
||||
}),
|
||||
0))
|
||||
g_string_append_len();
|
||||
}
|
||||
unsigned char tmp;
|
||||
qmi_message_tlv_read_guint8(
|
||||
qmi_message_pbm_get_all_capabilities_output_capability_basic_information_get_printable_message_init_offset,
|
||||
qmi_message_pbm_get_all_capabilities_output_capability_basic_information_get_printable_message_offset,
|
||||
tmp,
|
||||
qmi_message_pbm_get_all_capabilities_output_capability_basic_information_get_printable_message_error);
|
||||
{
|
||||
{
|
||||
if (__builtin_expect(({
|
||||
int _g_boolean_var_4;
|
||||
if (printable)
|
||||
_g_boolean_var_4 = 1;
|
||||
else
|
||||
_g_boolean_var_4 = 0;
|
||||
_g_boolean_var_4;
|
||||
}),
|
||||
0))
|
||||
g_string_append_len();
|
||||
}
|
||||
}
|
||||
for (
|
||||
;
|
||||
qmi_message_pbm_get_all_capabilities_output_capability_basic_information_get_printable_message_phonebooks_i;) {
|
||||
unsigned char tmp;
|
||||
qmi_message_tlv_read_guint8(&tmp);
|
||||
{
|
||||
if (__builtin_expect(({
|
||||
int _g_boolean_var_4;
|
||||
if (printable)
|
||||
_g_boolean_var_4 = 1;
|
||||
else
|
||||
_g_boolean_var_4 = 0;
|
||||
_g_boolean_var_4;
|
||||
}),
|
||||
0))
|
||||
g_string_append_len();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5911,6 +5911,7 @@ static bool
|
|||
visit_phi (gimple *phi, bool *inserted, bool backedges_varying_p)
|
||||
{
|
||||
tree result, sameval = VN_TOP, seen_undef = NULL_TREE;
|
||||
bool seen_undef_visited = false;
|
||||
tree backedge_val = NULL_TREE;
|
||||
bool seen_non_backedge = false;
|
||||
tree sameval_base = NULL_TREE;
|
||||
|
@ -5941,10 +5942,12 @@ visit_phi (gimple *phi, bool *inserted, bool backedges_varying_p)
|
|||
if (def == PHI_RESULT (phi))
|
||||
continue;
|
||||
++n_executable;
|
||||
bool visited = true;
|
||||
if (TREE_CODE (def) == SSA_NAME)
|
||||
{
|
||||
tree val = SSA_VAL (def, &visited);
|
||||
if (!backedges_varying_p || !(e->flags & EDGE_DFS_BACK))
|
||||
def = SSA_VAL (def);
|
||||
def = val;
|
||||
if (e->flags & EDGE_DFS_BACK)
|
||||
backedge_val = def;
|
||||
}
|
||||
|
@ -5956,7 +5959,16 @@ visit_phi (gimple *phi, bool *inserted, bool backedges_varying_p)
|
|||
else if (TREE_CODE (def) == SSA_NAME
|
||||
&& ! virtual_operand_p (def)
|
||||
&& ssa_undefined_value_p (def, false))
|
||||
seen_undef = def;
|
||||
{
|
||||
if (!seen_undef
|
||||
/* Avoid having not visited undefined defs if we also have
|
||||
a visited one. */
|
||||
|| (!seen_undef_visited && visited))
|
||||
{
|
||||
seen_undef = def;
|
||||
seen_undef_visited = visited;
|
||||
}
|
||||
}
|
||||
else if (sameval == VN_TOP)
|
||||
{
|
||||
sameval = def;
|
||||
|
|
Loading…
Add table
Reference in a new issue