summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Oblock <gary@amperecomputing.com>2020-11-03 13:44:36 -0800
committerGary Oblock <gary@amperecomputing.com>2020-11-03 13:44:36 -0800
commitf71d6026bd7e3f071f39e6779a5c6b333eca34d5 (patch)
tree7e47a945018012bd588f092c783c6a2de207fbd5
parent8e7fbfc3cb9ce35bd8fd06cc20fd22b579d26e93 (diff)
Last changes form v3.
-rw-r--r--gcc/ipa-str-reorg-instance-interleave.c317
-rw-r--r--gcc/ipa-structure-reorg.c328
-rw-r--r--gcc/ipa-structure-reorg.h4
3 files changed, 368 insertions, 281 deletions
diff --git a/gcc/ipa-str-reorg-instance-interleave.c b/gcc/ipa-str-reorg-instance-interleave.c
index cf66de55fb6..e2e0b710b49 100644
--- a/gcc/ipa-str-reorg-instance-interleave.c
+++ b/gcc/ipa-str-reorg-instance-interleave.c
@@ -357,111 +357,11 @@ str_reorg_instance_interleave_trans ( Info *info)
case ReorgT_ElemAssign:
{
DEBUG_L("ReorgT_ElemAssign: ");
- //DEBUG_F( print_gimple_stmt, stderr, stmt, 0);
- //INDENT(2);
+ DEBUG_F( print_gimple_stmt, stderr, stmt, 0);
+ INDENT(2);
- #if 1
element_assign_transformation (stmt, ri, info);
- #else
- gimple_stmt_iterator gsi = gsi_for_stmt( stmt);
-
- // Needed for helloworld
- tree lhs = gimple_assign_lhs( stmt);
- tree rhs = gimple_assign_rhs1( stmt);
- bool ro_on_left = tree_contains_a_reorgtype_p ( lhs, info);
-
- tree ro_side = ro_on_left ? lhs : rhs;
- tree nonro_side = ro_on_left ? rhs : lhs;
-
- switch ( recognize_op ( ro_side, true, info) ) // "a->f"
- {
- case ReorgOpT_Indirect:
- {
- tree ref_expr;
- tree field_val_temp;
- gimple_seq ref_seq = NULL;
-
- make_transformed_ref ( ro_side, ri, &ref_expr, &ref_seq, &field_val_temp, info);
-
- gimple *temp_set;
- gimple *final_set;
-
- if ( ro_on_left )
- {
- // With: a->f = rhs
- // Generate:
-
- // temp = rhs
- temp_set = gimple_build_assign( field_val_temp, rhs);
- SSA_NAME_DEF_STMT ( field_val_temp) = temp_set;
-
- //// field_array[index] = temp
- //tree elem_to_set =
- // build4 ( ARRAY_REF, field_type, field_arry_addr, index,
- // NULL_TREE, NULL_TREE);
- //final_set =
- // gimple_build_assign( elem_to_set, field_val_temp);
-
- // *field_addr = temp
- tree lhs_ref = ref_expr;
-
- final_set =
- gimple_build_assign( lhs_ref, field_val_temp);
- }
- else
- {
- // With: lhs = a->f
- // Generate:
-
- tree rhs_ref = ref_expr;
-
- // If these will actually print then things are likely sane
- //DEBUG_L("rhs_ref: ");
- //DEBUG_F(print_generic_expr, stderr, rhs_ref, (dump_flags_t)0);
- //DEBUG("\n");
-
- // These are here for debugging
- tree op0 = TREE_OPERAND ( rhs_ref, 0);
- tree op1 = TREE_OPERAND ( rhs_ref, 1);
- tree op1type = TYPE_MAIN_VARIANT (TREE_TYPE (op1));
- tree op1type_type = TREE_TYPE ( op1type);
-
- temp_set =
- gimple_build_assign( field_val_temp, rhs_ref);
- SSA_NAME_DEF_STMT ( field_val_temp) = temp_set;
-
- // lhs = temp
- final_set = gimple_build_assign( lhs, field_val_temp);
- SSA_NAME_DEF_STMT ( lhs) = final_set;
- }
-
- //DEBUG_L("temp_set: ");
- //DEBUG_F( print_gimple_stmt, stderr, temp_set, 0);
- //DEBUG("\n");
-
- //DEBUG_L("final_set: ");
- //DEBUG_F( print_gimple_stmt, stderr, final_set, 0);
- //DEBUG("\n");
-
- gsi_insert_seq_before ( &gsi, ref_seq, GSI_SAME_STMT);
- gsi_insert_before( &gsi, temp_set, GSI_SAME_STMT);
- gsi_insert_before( &gsi, final_set, GSI_SAME_STMT);
-
- //delete stmt
- gsi_remove ( &gsi, true);
- } // end ReorgOpT_Indirect case
- break;
- case ReorgOpT_AryDir: // "x[i].f"
- // Not implemented in single pool
- internal_error ( "ReorgOpT_AryDir not possible");
- default:
- internal_error (
- "Reached tree operand default for "
- "ReorgT_ElemAssign");
-
- } // end recognize_op ( rhs, info) switch
- #endif
//INDENT(-2);
} // end ReorgT_ElemAssign case
break;
@@ -2127,9 +2027,9 @@ str_reorg_instance_interleave_trans ( Info *info)
pop_cfun ();
}
- //DEBUG_L("after bulk of transformations\n");
+ DEBUG_L("After bulk of transformations\n");
- //DEBUG_F( print_program, info->reorg_dump_file, PRINT_FORMAT, 4, info);
+ DEBUG_F( print_program, info->reorg_dump_file, PRINT_FORMAT, 4, info);
//DEBUG ("INTERNALS PRINT\n");
//DEBUG_F (apply_to_all_gimple, print_internals, true, (void *)info);
@@ -2143,7 +2043,7 @@ str_reorg_instance_interleave_trans ( Info *info)
std::vector <tree> ssa_to_delete;
- //DEBUG_L("Mini-Pass on Function %s:\n", lang_hooks.decl_printable_name ( func->decl, 2));
+ DEBUG_L("Mini-Pass on Function %s:\n", lang_hooks.decl_printable_name ( func->decl, 2));
//DEBUG_L("\n");
//DEBUG_F( wolf_fence, info);
@@ -2175,21 +2075,19 @@ str_reorg_instance_interleave_trans ( Info *info)
// of many functions mapping onto one declaration (which I
// even doubt is possible in thi case) can't be a problem.
- //DEBUG_L("Dangling Types for Function Params (default defs).\n");
- //INDENT(4);
+ DEBUG_L("Dangling Types for Function Params (default defs).\n");
+ INDENT(4);
tree parm;
for ( parm = DECL_ARGUMENTS ( func->decl);
parm;
parm = DECL_CHAIN ( parm) )
{
- //DEBUG_A("param: ");
- //DEBUG_F( print_generic_decl, stderr, parm, (dump_flags_t)0);
- //DEBUG("\n");
- //INDENT(2);
+ DEBUG_A("param: ");
+ DEBUG_F( flexible_print, stderr, parm, 1, (dump_flags_t)0);
+ INDENT(2);
tree old_default_def = ssa_default_def ( func, parm);
- //DEBUG_A("old_default_def: ");
- //DEBUG_F( print_generic_expr, stderr, old_default_def, (dump_flags_t)0);
- //DEBUG("\n");
+ DEBUG_A("old_default_def: ");
+ DEBUG_F( flexible_print, stderr, old_default_def, 1, (dump_flags_t)0);
tree new_default_def;
// Modify prameter and do the default def stuff
@@ -2199,9 +2097,8 @@ str_reorg_instance_interleave_trans ( Info *info)
if ( modify_decl_core ( &parm, info) )
{
- //DEBUG_A("double check new param: ");
- //DEBUG_F( print_generic_decl, stderr, parm, (dump_flags_t)0);
- //DEBUG("\n");
+ DEBUG_A("double check new param: ");
+ DEBUG_F( flexible_print, stderr, parm, 1, (dump_flags_t)0);
// New default def here
@@ -2228,11 +2125,10 @@ str_reorg_instance_interleave_trans ( Info *info)
new_default_def = make_ssa_name_fn ( func, parm, gimple_build_nop ());
set_ssa_default_def ( func, parm, new_default_def);
- //DEBUG_A("new_default_def: ");
- //DEBUG_F(print_generic_expr, stderr, new_default_def, (dump_flags_t)0);
- //DEBUG(", TYPE: ");
- //DEBUG_F(print_generic_expr, stderr, TREE_TYPE(new_default_def), (dump_flags_t)0);
- //DEBUG("\n");
+ DEBUG_A("new_default_def: ");
+ DEBUG_F(flexible_print, stderr, new_default_def, 0, (dump_flags_t)0);
+ DEBUG(", TYPE: ");
+ DEBUG_F(flexible_print, stderr, TREE_TYPE(new_default_def), 1, (dump_flags_t)0);
// TBD REMOVE DUPLICATE!
// Replace old one (not really totally hence the
@@ -2256,14 +2152,13 @@ str_reorg_instance_interleave_trans ( Info *info)
{
if ( use_p == NULL ) continue;
tree use = USE_FROM_PTR (use_p);
- //DEBUG_A("use to replace: ");
- //DEBUG_F( print_generic_expr, stderr, use, (dump_flags_t)0);
- //DEBUG("\n");
+ DEBUG_A("use to replace: ");
+ DEBUG_F( flexible_print, stderr, use, 1, (dump_flags_t)0);
if (use == old_default_def)
SET_USE ( use_p, new_default_def);
}
- //DEBUG_A("after: ");
- //DEBUG_F ( print_gimple_stmt, stderr, stmt, 0);
+ DEBUG_A("after: ");
+ DEBUG_F ( print_gimple_stmt, stderr, stmt, 0);
}
// Get rid of the old default def because it confuses
//
@@ -2272,12 +2167,12 @@ str_reorg_instance_interleave_trans ( Info *info)
release_ssa_name_fn ( func, old_default_def);
}
}
- //INDENT(-2);
+ INDENT(-2);
}
- //INDENT(-4);
+ INDENT(-4);
- //DEBUG_L("Dangling Types for Function Local (default defs).\n");
- //INDENT(4);
+ DEBUG_L("Dangling Types for Function Local (default defs).\n");
+ INDENT(4);
//DEBUG_L("\n");
//DEBUG_F( wolf_fence, info);
@@ -2292,9 +2187,9 @@ str_reorg_instance_interleave_trans ( Info *info)
tree decl;
FOR_EACH_LOCAL_DECL ( func, i, decl)
{
- //DEBUG_A("local: ");
- //DEBUG_F( print_generic_decl, stderr, decl, (dump_flags_t)0);
- //DEBUG("\n");
+ DEBUG_A("local: ");
+ DEBUG_F( flexible_print, stderr, decl, 1, (dump_flags_t)0);
+
tree old_default_def = ssa_default_def ( func, decl);
tree new_default_def;
@@ -2337,25 +2232,25 @@ str_reorg_instance_interleave_trans ( Info *info)
//INDENT(-4);
// Normal ssa name case
- //DEBUG_L("Dangling Types for Normal SSA Names:\n");
+ DEBUG_L("Dangling Types for Normal SSA Names:\n");
//DEBUG_L("\n");
//DEBUG_F( wolf_fence, info);
- //INDENT(4);
+ INDENT(4);
// We use len instead of using func->length() in the for loop test
// because new ssa names are created in the loop body and we
// shouldn't process them.
unsigned int len = SSANAMES ( func)->length ();
- //DEBUG_L("len = %d\n",len);
+ DEBUG_L("len = %d\n",len);
for ( unsigned int i = 0; i < len; i++)
{
- //DEBUG_L("SSANAMES(func)[%d]\n",i);
+ DEBUG_L("SSANAMES(func)[%d]\n",i);
tree ssa_name = (*SSANAMES ( func))[i];
if( ssa_name == NULL )
{
- //DEBUG_L("Skip, ssa_name == NULL\n");
+ DEBUG_L("Skip, ssa_name == NULL\n");
continue;
}
@@ -2366,48 +2261,48 @@ str_reorg_instance_interleave_trans ( Info *info)
tree type = TREE_TYPE ( ssa_name);
tree bottom_type = base_type_of ( type);
ReorgType_t *ri = get_reorgtype_info ( bottom_type, info);
- //DEBUG_L("ssa_name = ");
- //DEBUG_F(print_generic_expr, stderr, ssa_name, (dump_flags_t)0);
- //DEBUG(" %s", a_default_def ? "is default_def" : "");
- //DEBUG(" %s", no_defining_stmt ? "has no defining stmt" : "");
- //DEBUG(" %s", defined_by_nop ? "defined by a nop" : "");
- //DEBUG(", type = ");
- //DEBUG_F(print_generic_expr, stderr, type, (dump_flags_t)0);
- //DEBUG(", bottom_type = ");
- //DEBUG_F(print_generic_expr, stderr, bottom_type, (dump_flags_t)0);
- //DEBUG(", ri = %p\n",ri);
+ DEBUG_L("ssa_name = ");
+ DEBUG_F(print_generic_expr, stderr, ssa_name, (dump_flags_t)0);
+ DEBUG(" %s", a_default_def ? "is default_def" : "");
+ DEBUG(" %s", no_defining_stmt ? "has no defining stmt" : "");
+ DEBUG(" %s", defined_by_nop ? "defined by a nop" : "");
+ DEBUG(", type = ");
+ DEBUG_F(print_generic_expr, stderr, type, (dump_flags_t)0);
+ DEBUG(", bottom_type = ");
+ DEBUG_F(print_generic_expr, stderr, bottom_type, (dump_flags_t)0);
+ DEBUG(", ri = %p\n",ri);
// If it's not a dangling type we don't care
if ( ri == NULL )
{
- //DEBUG_L("Skip, ri == NULL\n");
+ DEBUG_L("Skip, ri == NULL\n");
continue;
}
// A default def is processed seperately
if ( a_default_def )
{
- //DEBUG_L("Skip default_def\n");
+ DEBUG_L("Skip default_def\n");
continue;
}
gcc_assert ( !no_defining_stmt);
gcc_assert ( !defined_by_nop);
- //DEBUG_L("Defining stmt: ");
- //DEBUG_F ( print_gimple_stmt, stderr, defining_stmt, 0);
+ DEBUG_L("Defining stmt: ");
+ DEBUG_F ( print_gimple_stmt, stderr, defining_stmt, 0);
tree new_type = ri->pointer_rep;
tree new_ssa_name = make_temp_ssa_name( new_type, NULL, "dedangled");
- //DEBUG_L("new_ssa_name = ");
- //DEBUG_F(print_generic_expr, stderr, new_ssa_name, (dump_flags_t)0);
- //DEBUG("\n");
+ DEBUG_L("new_ssa_name = ");
+ DEBUG_F(print_generic_expr, stderr, new_ssa_name, (dump_flags_t)0);
+ DEBUG("\n");
#if DEBUGGING
for ( unsigned int j = 0; j < SSANAMES ( func)->length (); j++)
{
if ( (*SSANAMES ( func))[j] == new_ssa_name )
{
- //DEBUG_L("new name at j = %d\n",j);
+ DEBUG_L("new name at j = %d\n",j);
break;
}
}
@@ -2417,8 +2312,8 @@ str_reorg_instance_interleave_trans ( Info *info)
imm_use_iterator iter;
FOR_EACH_IMM_USE_STMT ( use_stmt, iter, ssa_name)
{
- //DEBUG_L("use_stmt before: ");
- //DEBUG_F ( print_gimple_stmt, stderr, use_stmt, 0);
+ DEBUG_L("use_stmt before: ");
+ DEBUG_F ( print_gimple_stmt, stderr, use_stmt, 0);
// Deal with the uses
use_operand_p use_p;
@@ -2427,14 +2322,14 @@ str_reorg_instance_interleave_trans ( Info *info)
//FOR_EACH_SSA_USE_OPERAND( use_p, use_stmt, ssa_iter, SSA_OP_USE )
FOR_EACH_PHI_OR_STMT_USE ( use_p, use_stmt, ssa_iter, SSA_OP_USE )
{
- //DEBUG_L("use_p = %p\n",use_p);
+ DEBUG_L("use_p = %p\n",use_p);
if ( use_p == NULL ) continue;
tree use = USE_FROM_PTR (use_p);
if (use == ssa_name)
SET_USE ( use_p, new_ssa_name);
}
- //DEBUG_L("use_stmt after: ");
- //DEBUG_F ( print_gimple_stmt, stderr, use_stmt, 0);
+ DEBUG_L("use_stmt after: ");
+ DEBUG_F ( print_gimple_stmt, stderr, use_stmt, 0);
// Should update_stmt be called here?
// It does not seem either harm or help so I'll
@@ -2443,14 +2338,40 @@ str_reorg_instance_interleave_trans ( Info *info)
}
// Modify the LHS too
// TBD This code needs to be more general.
- //DEBUG_L("What is ssa_name? ");
- //DEBUG_F(flexible_print, stderr, ssa_name, 1, (dump_flags_t)0);
+ DEBUG_L("What is ssa_name? ");
+ DEBUG_F(flexible_print, stderr, ssa_name, 1, (dump_flags_t)0);
gimple *def = SSA_NAME_DEF_STMT ( ssa_name);
- //DEBUG_L("def: ");
- //DEBUG_F ( print_gimple_stmt, stderr, def, 0);
-
- set_lhs_for ( def, new_ssa_name);
+ DEBUG_L("def: ");
+ DEBUG_F ( print_gimple_stmt, stderr, def, 0);
+
+ // If necessary change the operation to deal with sizetype
+ // instead of pointers.
+ gassign *gass = static_cast <gassign *> (def);
+ bool rebuild =
+ gimple_code ( def) == GIMPLE_ASSIGN
+ && POINTER_TYPE_P ( TREE_TYPE ( gimple_assign_lhs ( def)))
+ && !POINTER_TYPE_P ( new_type)
+ && get_gimple_rhs_class ((enum tree_code)gass->subcode) == GIMPLE_BINARY_RHS
+ && gimple_assign_rhs_code (def) == POINTER_PLUS_EXPR;
+
+ if ( rebuild )
+ {
+ tree op0 = gimple_assign_rhs1 ( def);
+ tree op1 = gimple_assign_rhs2 ( def);
+
+ gimple *rebuilt =
+ gimple_build_assign ( new_ssa_name, PLUS_EXPR, op0, op1);
+ SSA_NAME_DEF_STMT ( new_ssa_name) = rebuilt;
+
+ gimple_stmt_iterator gsi_def = gsi_for_stmt( def);
+ gsi_insert_before( &gsi_def, rebuilt, GSI_SAME_STMT);
+ gsi_remove ( &gsi_def, true);
+ }
+ else
+ {
+ set_lhs_for ( def, new_ssa_name);
+ }
update_stmt ( def);
@@ -2458,7 +2379,7 @@ str_reorg_instance_interleave_trans ( Info *info)
release_ssa_name_fn ( func, ssa_name);
}
- //INDENT(-4);
+ INDENT(-4);
// Might be a bad idea.
#if 0
@@ -2492,19 +2413,26 @@ element_assign_transformation ( gimple *stmt, ReorgType_t *ri, Info_t *info)
{
gimple_stmt_iterator gsi = gsi_for_stmt( stmt);
- //DEBUG_L("element_assign_transformation: ");
- //DEBUG_F( print_gimple_stmt, stderr, stmt, 0);
- //INDENT(2);
+ DEBUG_L("element_assign_transformation: ");
+ DEBUG_F( print_gimple_stmt, stderr, stmt, 0);
+ INDENT(2);
// Needed for helloworld
tree lhs = gimple_assign_lhs( stmt);
tree rhs = gimple_assign_rhs1( stmt);
-
- bool ro_on_left = tree_contains_a_reorgtype_p ( lhs, info);
+
+ // Just looking at the type is insufficient because
+ // the field itself can be a reorg type. Instead
+ // look at it's shape.
+ //bool ro_on_left = tree_contains_a_reorgtype_p ( lhs, info);
+ bool ro_on_left = find_deepest_comp_ref ( lhs) != NULL;
tree ro_side = ro_on_left ? lhs : rhs;
tree nonro_side = ro_on_left ? rhs : lhs;
-
- switch ( recognize_op ( ro_side, true, info) ) // "a->f"
+
+ DEBUG_A("ro_side = ");
+ DEBUG_F(flexible_print, stderr, ro_side, 1, (dump_flags_t)0);
+ enum ReorgOpTrans optype = recognize_op ( ro_side, true, info);
+ switch ( optype ) // "a->f"
{
case ReorgOpT_Indirect:
{
@@ -2547,9 +2475,9 @@ element_assign_transformation ( gimple *stmt, ReorgType_t *ri, Info_t *info)
tree rhs_ref = ref_expr;
// If these will actually print then things are likely sane
- //DEBUG_L("rhs_ref: ");
- //DEBUG_F(print_generic_expr, stderr, rhs_ref, (dump_flags_t)0);
- //DEBUG("\n");
+ DEBUG_L("rhs_ref: ");
+ DEBUG_F(print_generic_expr, stderr, rhs_ref, (dump_flags_t)0);
+ DEBUG("\n");
// These are here for debugging
tree op0 = TREE_OPERAND ( rhs_ref, 0);
@@ -2566,13 +2494,13 @@ element_assign_transformation ( gimple *stmt, ReorgType_t *ri, Info_t *info)
SSA_NAME_DEF_STMT ( lhs) = final_set;
}
- //DEBUG_L("temp_set: ");
- //DEBUG_F( print_gimple_stmt, stderr, temp_set, 0);
- //DEBUG("\n");
+ DEBUG_L("temp_set: ");
+ DEBUG_F( print_gimple_stmt, stderr, temp_set, 0);
+ DEBUG("\n");
- //DEBUG_L("final_set: ");
- //DEBUG_F( print_gimple_stmt, stderr, final_set, 0);
- //DEBUG("\n");
+ DEBUG_L("final_set: ");
+ DEBUG_F( print_gimple_stmt, stderr, final_set, 0);
+ DEBUG("\n");
gsi_insert_seq_before ( &gsi, ref_seq, GSI_SAME_STMT);
gsi_insert_before( &gsi, temp_set, GSI_SAME_STMT);
@@ -2588,11 +2516,11 @@ element_assign_transformation ( gimple *stmt, ReorgType_t *ri, Info_t *info)
default:
internal_error (
"Reached tree operand default for "
- "ReorgT_ElemAssign");
+ "ReorgT_ElemAssign (%s)", optrans_to_str ( optype));
} // end recognize_op ( rhs, info) switch
- //INDENT(-2);
+ INDENT(-2);
}
// For ref_in which is a ReorgOpT_Indirect, create gimple
@@ -2608,6 +2536,7 @@ make_transformed_ref ( tree ref_in,
// For deeply nested case we need the lowest.
tree lowest_comp_ref = find_deepest_comp_ref ( ref_in);
+ gcc_assert ( lowest_comp_ref);
tree orig_field = TREE_OPERAND ( lowest_comp_ref, 1);
tree field_type = TREE_TYPE ( orig_field);
@@ -2666,9 +2595,15 @@ make_transformed_ref ( tree ref_in,
// Note base_field_type is a pointer and we want the size of what's
// pointed to.
tree size_of_field = TYPE_SIZE_UNIT ( field_type);
-
+
+ // I'm pretty sure this is not necessary... revert it
+ #if 0
+ tree unsigned_long_type = TYPE_MAIN_VARIANT ( pointer_sized_int_node);
+ tree offset = make_temp_ssa_name( unsigned_long_type, NULL, "offset");
+ #else
gcc_assert ( sizetype);
tree offset = make_temp_ssa_name( sizetype, NULL, "offset");
+ #endif
gimple *get_offset = gimple_build_assign ( offset, MULT_EXPR, index, size_of_field);
SSA_NAME_DEF_STMT ( offset) = get_offset;
@@ -2693,6 +2628,10 @@ make_transformed_ref ( tree ref_in,
static tree
find_deepest_comp_ref ( tree comp_ref_expr )
{
+ //DEBUG_A("find_deepest_comp_ref of ");
+ //DEBUG_F(flexible_print, stderr, comp_ref_expr, 2, (dump_flags_t)0);
+ //DEBUG_A("tree coded of %s\n", code_str( TREE_CODE(comp_ref_expr)));
+ if ( TREE_CODE(comp_ref_expr) == SSA_NAME ) return NULL;
tree inner_op0 = TREE_OPERAND( comp_ref_expr, 0);
enum tree_code inner_op0_code = TREE_CODE ( inner_op0);
if ( inner_op0_code == COMPONENT_REF )
@@ -2703,7 +2642,7 @@ find_deepest_comp_ref ( tree comp_ref_expr )
{
return comp_ref_expr;
}
- gcc_assert (0);
+ return NULL;
}
static tree
diff --git a/gcc/ipa-structure-reorg.c b/gcc/ipa-structure-reorg.c
index 155b5b4fe68..a01feda3d4c 100644
--- a/gcc/ipa-structure-reorg.c
+++ b/gcc/ipa-structure-reorg.c
@@ -267,7 +267,6 @@ final_debug_info ( Info *info)
static unsigned int
reorg_analysis ( Info *info)
{
-
struct cgraph_node *node;
find_decls_and_types ( info);
@@ -1663,6 +1662,18 @@ undelete_reorgtype ( ReorgType_t *rt, Info *info )
}
}
+#define REORG_RECOG_RET_ACT(rt) reorg_recognize_ret_action(rt,__LINE__)
+
+static ReorgTransformation
+reorg_recognize_ret_action( ReorgTransformation val, unsigned ln)
+{
+ #if DEBUGGING
+ fprintf ( stderr, "L# %4d: %*s returns %s\n",
+ ln, debug_indenting, "", reorgtrans_to_str (val));
+ #endif
+ return val;
+}
+
ReorgTransformation
reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info )
{
@@ -1694,18 +1705,31 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info )
{
if ( integer_zerop ( rhs) )
{
- return ReorgT_Ptr2Zero;
+ return REORG_RECOG_RET_ACT ( ReorgT_Ptr2Zero);
}
// If we get here this is clearly really odd code
// so we need to bail out.
- return Not_Supported;
+ #if 1
+ // If seems that this code occurrs in "nature"... sigh...
+ return REORG_RECOG_RET_ACT ( ReorgT_Ignore);
+ #else
+ return REORG_RECOG_RET_ACT ( Not_Supported);
+ #endif
}
case ReorgOpT_Temp: // t
- return ReorgT_ElemAssign;
+ return REORG_RECOG_RET_ACT ( ReorgT_ElemAssign);
case ReorgOpT_Address: // "&x[i]"
- return ReorgT_Adr2Ptr;
+ return REORG_RECOG_RET_ACT ( ReorgT_Adr2Ptr);
+ //--
+ case ReorgOpT_Pointer:
+ return REORG_RECOG_RET_ACT ( ReorgT_Ignore);
+ //--
+ case ReorgOpT_Cst0:
+ return REORG_RECOG_RET_ACT ( ReorgT_Ptr2Zero);
+ case ReorgOpT_Indirect:
+ return REORG_RECOG_RET_ACT ( ReorgT_ElemAssign);
default:
- return Not_Supported;
+ return REORG_RECOG_RET_ACT ( Not_Supported);
}
case ReorgOpT_Struct: // "s"
DEBUG_L("case ReorgOpT_Struct\n");
@@ -1720,9 +1744,9 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info )
// With the case commented out test_09_23
// exposes a bug.
case ReorgOpT_Struct: // "s"
- return ReorgT_StrAssign;
+ return REORG_RECOG_RET_ACT ( ReorgT_StrAssign);
default:
- return Not_Supported;
+ return REORG_RECOG_RET_ACT ( Not_Supported);
}
case ReorgOpT_Deref: // "*a"
DEBUG_L("case ReorgOpT_Deref\n");
@@ -1732,9 +1756,9 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info )
case ReorgOpT_Deref: // "*a"
case ReorgOpT_Struct: // "s"
case ReorgOpT_Array: // "x[i]"
- return ReorgT_StrAssign;
+ return REORG_RECOG_RET_ACT ( ReorgT_StrAssign);
default:
- return Not_Supported;
+ return REORG_RECOG_RET_ACT ( Not_Supported);
}
case ReorgOpT_Array: // "x[i]"
DEBUG_L("case ReorgOpT_Array\n");
@@ -1744,9 +1768,9 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info )
case ReorgOpT_Struct: // "s"
case ReorgOpT_Deref: // "*a"
case ReorgOpT_Array: // "x[i]"
- return ReorgT_StrAssign;
+ return REORG_RECOG_RET_ACT ( ReorgT_StrAssign);
default:
- return Not_Supported;
+ return REORG_RECOG_RET_ACT ( Not_Supported);
}
case ReorgOpT_Temp: // t
case ReorgOpT_Scalar: // "z"
@@ -1757,12 +1781,19 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info )
{
case ReorgOpT_Scalar: // "z"
case ReorgOpT_Temp: // "t"
- return ReorgT_Ignore;
+ //-- provisional
+ // The type on the lhs is that of the rhs (by
+ // definition) so its moving a pointer to a pointer.
+ case ReorgOpT_Pointer: // p
+ //--
+ case ReorgOpT_Clobber:
+ case ReorgOpT_Cst0:
+ return REORG_RECOG_RET_ACT ( ReorgT_Ignore);
case ReorgOpT_Indirect: // "a->f"
case ReorgOpT_AryDir: // "x[i].f"
- return ReorgT_ElemAssign;
+ return REORG_RECOG_RET_ACT ( ReorgT_ElemAssign);
default:
- return Not_Supported;
+ return REORG_RECOG_RET_ACT ( Not_Supported);
}
}
case ReorgOpT_Indirect: // "a->f"
@@ -1777,24 +1808,25 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info )
case ReorgOpT_Scalar: // "z"
case ReorgOpT_Indirect: // "a->f"
case ReorgOpT_AryDir: // "x[i].f"
- return ReorgT_ElemAssign;
+ case ReorgOpT_Pointer: // "a"
+ return REORG_RECOG_RET_ACT ( ReorgT_ElemAssign);
case ReorgOpT_Cst0:
{
if ( is_reorg_type ( TREE_TYPE (lhs), info) )
{
- return ReorgT_Ptr2Zero;
+ return REORG_RECOG_RET_ACT ( ReorgT_Ptr2Zero);
}
else
{
- return ReorgT_ElemAssign;
+ return REORG_RECOG_RET_ACT ( ReorgT_ElemAssign);
}
}
default:
- return Not_Supported;
+ return REORG_RECOG_RET_ACT ( Not_Supported);
}
}
default:
- return Not_Supported;
+ return REORG_RECOG_RET_ACT ( Not_Supported);
} // switch ( recognize_op ( lhs, true, info) )
} else {
DEBUG_L("gimple_assign_single_p() = false\n");
@@ -1808,14 +1840,14 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info )
{
DEBUG_L("CONVERT_EXPR_CODE_P (...)\n");
INDENT(-4);
- return ReorgT_Convert;
+ return REORG_RECOG_RET_ACT ( ReorgT_Convert);
}
if ( gimple_assign_rhs3 ( stmt) != NULL )
{
DEBUG_L("gimple_assign_rhs3 ( stmt) != NULL\n");
INDENT(-4);
- return Not_Supported;
+ return REORG_RECOG_RET_ACT ( Not_Supported);
}
// TBD The parenthesis where a disaster here in the HL Design so
@@ -1829,23 +1861,23 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info )
switch ( rhs_code )
{
case POINTER_PLUS_EXPR:
- return ReorgT_PtrPlusInt;
+ return REORG_RECOG_RET_ACT ( ReorgT_PtrPlusInt);
case POINTER_DIFF_EXPR:
- return ReorgT_PtrDiff;
+ return REORG_RECOG_RET_ACT ( ReorgT_PtrDiff);
case EQ_EXPR:
- return zero_case ? ReorgT_PtrNull : ReorgT_PtrEQ;
+ return REORG_RECOG_RET_ACT ( zero_case ? ReorgT_PtrNull : ReorgT_PtrEQ);
case NE_EXPR:
- return zero_case ? ReorgT_PtrNotNull : ReorgT_PtrNE;
+ return REORG_RECOG_RET_ACT ( zero_case ? ReorgT_PtrNotNull : ReorgT_PtrNE);
case LE_EXPR:
- return ReorgT_PtrLE;
+ return REORG_RECOG_RET_ACT ( ReorgT_PtrLE);
case LT_EXPR:
- return ReorgT_PtrLT;
+ return REORG_RECOG_RET_ACT ( ReorgT_PtrLT);
case GE_EXPR:
- return ReorgT_PtrGE;
+ return REORG_RECOG_RET_ACT ( ReorgT_PtrGE);
case GT_EXPR:
- return ReorgT_PtrGT;
+ return REORG_RECOG_RET_ACT ( ReorgT_PtrGT);
default:
- return Not_Supported;
+ return REORG_RECOG_RET_ACT ( Not_Supported);
}
} // } else {
}
@@ -1866,19 +1898,19 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info )
switch ( cond_code )
{
case EQ_EXPR:
- return zero_case ? ReorgT_If_Null : ReorgT_IfPtrEQ;
+ return REORG_RECOG_RET_ACT ( zero_case ? ReorgT_If_Null : ReorgT_IfPtrEQ);
case NE_EXPR:
- return zero_case ? ReorgT_If_NotNull : ReorgT_IfPtrNE;
+ return REORG_RECOG_RET_ACT ( zero_case ? ReorgT_If_NotNull : ReorgT_IfPtrNE);
case LE_EXPR:
- return ReorgT_IfPtrLE;
+ return REORG_RECOG_RET_ACT ( ReorgT_IfPtrLE);
case LT_EXPR:
- return ReorgT_IfPtrLT;
+ return REORG_RECOG_RET_ACT ( ReorgT_IfPtrLT);
case GE_EXPR:
- return ReorgT_IfPtrGE;
+ return REORG_RECOG_RET_ACT ( ReorgT_IfPtrGE);
case GT_EXPR:
- return ReorgT_IfPtrGT;
+ return REORG_RECOG_RET_ACT ( ReorgT_IfPtrGT);
default:
- return Not_Supported;
+ return REORG_RECOG_RET_ACT ( Not_Supported);
}
}
case GIMPLE_CALL:
@@ -1894,10 +1926,10 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info )
edge->callee->get_partitioning_class() == SYMBOL_EXTERNAL ? "true" : "false");
INDENT(-2);
- if ( gimple_call_builtin_p( stmt, BUILT_IN_CALLOC ) ) return ReorgT_Calloc;
- if ( gimple_call_builtin_p( stmt, BUILT_IN_MALLOC ) ) return ReorgT_Malloc;
- if ( gimple_call_builtin_p( stmt, BUILT_IN_REALLOC) ) return ReorgT_Realloc;
- if ( gimple_call_builtin_p( stmt, BUILT_IN_FREE ) ) return ReorgT_Free;
+ if ( gimple_call_builtin_p( stmt, BUILT_IN_CALLOC ) ) return REORG_RECOG_RET_ACT ( ReorgT_Calloc);
+ if ( gimple_call_builtin_p( stmt, BUILT_IN_MALLOC ) ) return REORG_RECOG_RET_ACT ( ReorgT_Malloc);
+ if ( gimple_call_builtin_p( stmt, BUILT_IN_REALLOC) ) return REORG_RECOG_RET_ACT ( ReorgT_Realloc);
+ if ( gimple_call_builtin_p( stmt, BUILT_IN_FREE ) ) return REORG_RECOG_RET_ACT ( ReorgT_Free);
// Instead of just returning Not_Supported we need to
// determine if it's a user defined function in which case the
@@ -1907,7 +1939,7 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info )
if ( is_user_function ( stmt, node, info) )
{
DEBUG_A(" ReorgT_UserFunc\n");
- return ReorgT_UserFunc;
+ return REORG_RECOG_RET_ACT ( ReorgT_UserFunc);
}
//DEBUG_A(" Not_supported\n");
// TBD Why is this commented out?
@@ -1917,14 +1949,14 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info )
case GIMPLE_RETURN:
DEBUG_L("GIMPLE_RETURN:\n");
INDENT(-2);
- return ReorgT_Return;
+ return REORG_RECOG_RET_ACT ( ReorgT_Return);
break;
default:
DEBUG_L ( "didn't support: ");
DEBUG_F ( print_gimple_stmt, stderr, stmt, 0);
DEBUG( "\n");
INDENT(-2);
- return Not_Supported;
+ return REORG_RECOG_RET_ACT ( Not_Supported);
}
}
@@ -2043,12 +2075,6 @@ recognize_op ( tree op, bool lie, Info *info)
DEBUG_A("opcode = %s\n", code_str( op_code));
switch ( op_code )
{
- case SSA_NAME:
- // We tried returning ReorgOpT_Scalar.
- // It caused an assertion failue because
- // it was incorrectly triggering the ReorgT_Ptr2Zero
- // case with a bogus RHS.
- return recognize_op_ret_action ( ReorgOpT_Temp);
case INTEGER_CST:
if ( integer_zerop ( op) )
{
@@ -2058,11 +2084,18 @@ recognize_op ( tree op, bool lie, Info *info)
case FIXED_CST:
case STRING_CST:
case COMPLEX_CST:
- case CONSTRUCTOR:
case VECTOR_CST:
{
return recognize_op_ret_action ( ReorgOpT_Cst);
}
+ case CONSTRUCTOR:
+ {
+ return recognize_op_ret_action ( ReorgOpT_Clobber);
+ }
+ default:
+ // Just drop through because we were simply picking
+ // the low hanging fruit here.
+ ;
}
tree type = TREE_TYPE ( op);
@@ -2088,35 +2121,57 @@ recognize_op ( tree op, bool lie, Info *info)
}
}
#endif
+ // From the ifdefed off code above it's probably
+ // reasonable to retain the check for a reorg type
+ bool a_reorg = is_reorg_type ( type, info);
+
+ if ( op_code == SSA_NAME )
+ {
+ if ( POINTER_TYPE_P (type) )
+ {
+ tree lower_type = TREE_TYPE ( type);
+ if ( TREE_CODE ( lower_type) == RECORD_TYPE
+ && is_reorg_type ( lower_type, info))
+ {
+ return recognize_op_ret_action ( ReorgOpT_Pointer);
+ }
+ }
+ // We tried returning ReorgOpT_Scalar.
+ // It caused an assertion failue because
+ // it was incorrectly triggering the ReorgT_Ptr2Zero
+ // case with a bogus RHS.
+ return recognize_op_ret_action ( ReorgOpT_Temp);
+ }
+
// This might not occur in practice
if ( op_code == RECORD_TYPE )
- {
- // The assumption here is that this
- // is a reorg type.
- return recognize_op_ret_action ( ReorgOpT_Struct);
- }
+ {
+ // The assumption here is that this
+ // is a reorg type.
+ return recognize_op_ret_action ( ReorgOpT_Struct);
+ }
if ( op_code == VAR_DECL )
- {
- tree type = TREE_TYPE ( op);
- gcc_assert ( type != NULL );
- if ( POINTER_TYPE_P (type) )
- {
- bool a_reorg = is_reorg_type ( type, info);
- if ( a_reorg || !lie )
- {
- return recognize_op_ret_action ( ReorgOpT_Pointer);
- }
- else
- {
- // This would be for when the field of a struct
- // element is a pointer that's not a reorg
- // pointer. I.e. ReorgT_ElemAssign. That is
- // this is while lie for a good purpose.
- return recognize_op_ret_action ( ReorgOpT_Scalar);
- }
- }
- return recognize_op_ret_action ( ReorgOpT_Scalar);
- }
+ {
+ //tree type = TREE_TYPE ( op);
+ gcc_assert ( type != NULL );
+ if ( POINTER_TYPE_P (type) )
+ {
+ //bool a_reorg = is_reorg_type ( type, info);
+ if ( a_reorg || !lie )
+ {
+ return recognize_op_ret_action ( ReorgOpT_Pointer);
+ }
+ else
+ {
+ // This would be for when the field of a struct
+ // element is a pointer that's not a reorg
+ // pointer. I.e. ReorgT_ElemAssign. That is
+ // this is while lie for a good purpose.
+ return recognize_op_ret_action ( ReorgOpT_Scalar);
+ }
+ }
+ return recognize_op_ret_action ( ReorgOpT_Scalar);
+ }
tree inner_op0 = TREE_OPERAND( op, 0);
tree inner_op0_type = TREE_TYPE ( inner_op0);
enum tree_code inner_op0_code = TREE_CODE ( inner_op0);
@@ -2128,10 +2183,10 @@ recognize_op ( tree op, bool lie, Info *info)
if ( inner_op0_code == ARRAY_REF )
{
bool a_reorg = is_reorg_type ( inner_op0, info);
- if ( a_reorg || !lie )
- {
- return recognize_op_ret_action ( ReorgOpT_Address);
- }
+ if ( a_reorg || !lie )
+ {
+ return recognize_op_ret_action ( ReorgOpT_Address);
+ }
}
// TBD shouldn't we be testing for a reorg???
if ( inner_op0_code == VAR_DECL )
@@ -2154,25 +2209,44 @@ recognize_op ( tree op, bool lie, Info *info)
DEBUG_L("inner_op1 = ");
DEBUG_F(flexible_print, stderr, inner_op1, 0, (dump_flags_t)0);
DEBUG(", TREE_CODE = %s\n", code_str( inner_op1_code));
-
+
+ // Note, a reorg type can only occurr at the bottom or
+ // the top, that is "rt.a.b..." or "a.b...z.rt".
if ( tree deep_type = multilevel_component_ref ( op) )
{
DEBUG_L("Is multilevel component ref: deep_type is ");
DEBUG_F(flexible_print, stderr, deep_type, 1, (dump_flags_t)0);
- bool a_reorg = is_reorg_type ( base_type_of ( deep_type), info);
- if ( a_reorg || !lie )
+ bool a_deep_reorg = is_reorg_type ( base_type_of ( deep_type), info);
+ if ( a_deep_reorg || !lie )
{
return recognize_op_ret_action ( ReorgOpT_Indirect);
}
// Just normal field reference otherwise...
return recognize_op_ret_action ( ReorgOpT_Scalar);
}
+ if ( tree_contains_a_reorgtype_p ( op, info))
+ {
+ DEBUG_A("POINTER_TYPE_P ( type) : %s\n",
+ POINTER_TYPE_P ( type) ? "true" : "false");
+ if ( POINTER_TYPE_P ( type))
+ {
+ DEBUG_A("TREE_CODE ( TREE_TYPE( type)) == RECORD_TYPE : %s\n",
+ TREE_CODE ( TREE_TYPE( type)) == RECORD_TYPE ? "true" : "false");
+ }
+ }
+ if ( tree_contains_a_reorgtype_p ( op, info)
+ && POINTER_TYPE_P ( type)
+ && TREE_CODE ( TREE_TYPE( type)) == RECORD_TYPE )
+ {
+
+ return recognize_op_ret_action ( ReorgOpT_Pointer);
+ }
if ( inner_op0_code == INDIRECT_REF )
{
DEBUG_L("TREE_CODE( inner_op) == INDIRECT_REF\n");
- bool a_reorg = is_reorg_type ( base_type_of ( type), info);
- if ( a_reorg || !lie )
+ bool a_base_reorg = is_reorg_type ( base_type_of ( type), info);
+ if ( a_base_reorg || !lie )
{
return recognize_op_ret_action ( ReorgOpT_Indirect);
}
@@ -2290,7 +2364,6 @@ multilevel_component_ref ( tree op)
{
DEBUG_A("multilevel_component_ref: ");
DEBUG_F(flexible_print, stderr, op, 1, (dump_flags_t)0);
- DEBUG_F(flexible_print, stderr, op, 1, (dump_flags_t)0);
INDENT(2);
tree inner_op0 = TREE_OPERAND( op, 0);
//tree inner_op1 = TREE_OPERAND( op, 1);
@@ -2313,6 +2386,7 @@ multilevel_component_ref ( tree op)
return type;
}
}
+ DEBUG_A(" found: no deep type\n");
INDENT(-2);
return NULL;
}
@@ -2784,8 +2858,8 @@ print_program ( FILE *file, bool my_format, int leading_space, Info_t *info)
}
}
- //DEBUG ("INTERNALS PRINT\n");
- //DEBUG_F (apply_to_all_gimple, print_internals, true, (void*)info);
+ DEBUG ("INTERNALS PRINT:\n");
+ DEBUG_F (apply_to_all_gimple, print_internals, true, (void*)info);
}
static void
@@ -3109,14 +3183,86 @@ optrans_to_str ( enum ReorgOpTrans e )
return "ReorgOpT_AryDir";
case ReorgOpT_Cst:
return "ReorgOpT_Cst";
- case ReorgOpT_Cst0 :
+ case ReorgOpT_Cst0:
return "ReorgOpT_Cst0";
+ case ReorgOpT_Clobber:
+ return "ReorgOpT_Clobber";
default:
gcc_assert (0);
}
return NULL;
}
+char *
+reorgtrans_to_str ( enum ReorgTransformation t)
+{
+ switch ( t )
+ {
+ case ReorgT_StrAssign:
+ return "ReorgT_StrAssign";
+ case ReorgT_ElemAssign:
+ return "ReorgT_ElemAssign";
+ case ReorgT_If_Null:
+ return "ReorgT_If_Null";
+ case ReorgT_If_NotNull:
+ return "ReorgT_If_NotNull";
+ case ReorgT_IfPtrEQ:
+ return "ReorgT_IfPtrEQ";
+ case ReorgT_IfPtrNE:
+ return "ReorgT_IfPtrNE";
+ case ReorgT_IfPtrLT:
+ return "ReorgT_IfPtrLT";
+ case ReorgT_IfPtrGT:
+ return "ReorgT_IfPtrGT";
+ case ReorgT_IfPtrLE:
+ return "ReorgT_IfPtrLE";
+ case ReorgT_IfPtrGE:
+ return "ReorgT_IfPtrGE";
+ case ReorgT_PtrPlusInt:
+ return "ReorgT_PtrPlusInt";
+ case ReorgT_Ptr2Zero:
+ return "ReorgT_Ptr2Zero";
+ case ReorgT_PtrDiff:
+ return "ReorgT_PtrDiff";
+ case ReorgT_Adr2Ptr:
+ return "ReorgT_Adr2Ptr";
+ case ReorgT_PtrNull:
+ return "ReorgT_PtrNull";
+ case ReorgT_PtrNotNull:
+ return "ReorgT_PtrNotNull";
+ case ReorgT_PtrEQ:
+ return "ReorgT_PtrEQ";
+ case ReorgT_PtrNE:
+ return "ReorgT_PtrNE";
+ case ReorgT_PtrLT:
+ return "ReorgT_PtrLT";
+ case ReorgT_PtrLE:
+ return "ReorgT_PtrLE";
+ case ReorgT_PtrGT:
+ return "ReorgT_PtrGT";
+ case ReorgT_PtrGE:
+ return "ReorgT_PtrGE";
+ case ReorgT_Malloc:
+ return "ReorgT_Malloc";
+ case ReorgT_Calloc:
+ return "ReorgT_Calloc";
+ case ReorgT_Realloc:
+ return "ReorgT_Realloc";
+ case ReorgT_Free:
+ return "ReorgT_Free";
+ case ReorgT_UserFunc:
+ return "ReorgT_UserFunc";
+ case ReorgT_Convert:
+ return "ReorgT_Convert";
+ case ReorgT_Return:
+ return "ReorgT_Return";
+ case ReorgT_Ignore:
+ return "ReorgT_Ignore";
+ case Not_Supported:
+ return "Not_Supported";
+ }
+}
+
#if DEBUGGING
void
handle_debug_indenting ( int amount )
diff --git a/gcc/ipa-structure-reorg.h b/gcc/ipa-structure-reorg.h
index f8200b845b7..715cd3b2930 100644
--- a/gcc/ipa-structure-reorg.h
+++ b/gcc/ipa-structure-reorg.h
@@ -102,7 +102,8 @@ enum ReorgOpTrans {
ReorgOpT_Indirect, // "a->f"
ReorgOpT_AryDir, // "x[i].f"
ReorgOpT_Cst,
- ReorgOpT_Cst0
+ ReorgOpT_Cst0,
+ ReorgOpT_Clobber
};
enum CompressionControl {
@@ -253,6 +254,7 @@ extern void print_type ( FILE *, tree);
extern void modify_ssa_name_type ( tree, tree);
extern bool print_internals (gimple *, void *);
extern const char *optrans_to_str ( enum ReorgOpTrans);
+extern char *reorgtrans_to_str ( enum ReorgTransformation);
extern bool is_assign_from_ssa ( gimple *);