diff options
author | Gary Oblock <gary@amperecomputing.com> | 2021-01-27 12:52:57 -0800 |
---|---|---|
committer | Gary Oblock <gary@amperecomputing.com> | 2021-01-27 12:52:57 -0800 |
commit | 1b626504db35c830078788d473bd6e738c519c8a (patch) | |
tree | b85fb29b2e194ace6aef8e6e4b3a2fba74281f89 | |
parent | e499b3a2700784552d2e0fcb206b76bfac72c2ba (diff) |
Some fixes (though test_09_24 regressed.)
-rw-r--r-- | gcc/ipa-str-reorg-instance-interleave.c | 58 | ||||
-rw-r--r-- | gcc/ipa-structure-reorg.c | 118 | ||||
-rw-r--r-- | gcc/ipa-structure-reorg.h | 3 |
3 files changed, 155 insertions, 24 deletions
diff --git a/gcc/ipa-str-reorg-instance-interleave.c b/gcc/ipa-str-reorg-instance-interleave.c index b7b37c8dd97..599458ba0d9 100644 --- a/gcc/ipa-str-reorg-instance-interleave.c +++ b/gcc/ipa-str-reorg-instance-interleave.c @@ -448,8 +448,8 @@ str_reorg_instance_interleave_trans ( Info *info) case ReorgT_If_Null: case ReorgT_If_NotNull: { - //DEBUG_L("ReorgT_If_(Not)Null: "); - //DEBUG_F( print_gimple_stmt, stderr, stmt, 0); + DEBUG_L("ReorgT_If_(Not)Null: "); + DEBUG_F( print_gimple_stmt, stderr, stmt, 0); /* gimple_cond_set_rhs( stmt, TYPE_MAX_VALUE( pointer_sized_int_node)); @@ -464,14 +464,26 @@ str_reorg_instance_interleave_trans ( Info *info) //tree max = TYPE_MAX_VALUE ( TREE_TYPE ( ri->pointer_rep)); tree max = TYPE_MAX_VALUE ( ri->pointer_rep); - //DEBUG_L("max: "); - //DEBUG_F(print_generic_expr, stderr, max, (dump_flags_t)0); - //DEBUG("\n"); + DEBUG_L("max: "); + DEBUG_F(print_generic_expr, stderr, max, (dump_flags_t)0); + DEBUG("\n"); + + tree cond_op1 = gimple_cond_lhs ( cond_stmt); + + tree convert_dest = + make_temp_ssa_name( ri->pointer_rep, NULL, "cond_cast"); + gimple *gcond_cast = + gimple_build_assign ( convert_dest, CONVERT_EXPR, cond_op1); + SSA_NAME_DEF_STMT ( convert_dest) = gcond_cast; + + gimple_cond_set_lhs( cond_stmt, convert_dest); gimple_cond_set_rhs( cond_stmt, max); + + gsi_insert_before( &gsi, gcond_cast, GSI_SAME_STMT); - //DEBUG_L("after: "); - //DEBUG_F( print_gimple_stmt, stderr, stmt, 0); + DEBUG_L("after: "); + DEBUG_F( print_gimple_stmt, stderr, stmt, 0); } break; case ReorgT_IfPtrEQ: @@ -491,8 +503,8 @@ str_reorg_instance_interleave_trans ( Info *info) break; case ReorgT_PtrPlusInt: // "a = b + i" { - //DEBUG_L("ReorgT_PtrPlusInt: "); - //DEBUG_F( print_gimple_stmt, stderr, stmt, 0); + DEBUG_L("ReorgT_PtrPlusInt: "); + DEBUG_F( print_gimple_stmt, stderr, stmt, 0); // Needed for hellowotrld // Does the type of stmt need to be adjusted? I assume so. @@ -514,6 +526,8 @@ str_reorg_instance_interleave_trans ( Info *info) tree rhs1 = gimple_assign_rhs1( stmt); tree rhs2 = gimple_assign_rhs2( stmt); + DEBUG_L("\n"); + gcc_assert ( type); tree PPI_rhs1_cast = make_temp_ssa_name( type, NULL, "PPI_rhs1_cast"); gimple *gPPI_rhs1_cast = gimple_build_assign ( PPI_rhs1_cast, CONVERT_EXPR, rhs1); @@ -523,6 +537,8 @@ str_reorg_instance_interleave_trans ( Info *info) gimple *gPPI_rhs2_cast = gimple_build_assign ( PPI_rhs2_cast, CONVERT_EXPR, rhs2); SSA_NAME_DEF_STMT ( PPI_rhs2_cast) = gPPI_rhs2_cast; + DEBUG_L("\n"); + tree PPI_adj = make_temp_ssa_name( type, NULL, "PtrPlusInt_Adj"); gimple *gPPI_adj = gimple_build_assign ( PPI_adj, TRUNC_DIV_EXPR, PPI_rhs2_cast, str_siz); @@ -533,10 +549,14 @@ str_reorg_instance_interleave_trans ( Info *info) gimple_build_assign ( ptrplusint, PLUS_EXPR, PPI_rhs1_cast, PPI_adj); SSA_NAME_DEF_STMT ( ptrplusint) = gPPI; + DEBUG_L("\n"); + gimple *gPPI_cast = gimple_build_assign ( PPI_orig_lhs, CONVERT_EXPR, ptrplusint); SSA_NAME_DEF_STMT ( PPI_orig_lhs) = gPPI_cast; + DEBUG_L("\n"); + //gimple_set_op( stmt, 2, tmp); gimple_stmt_iterator gsi = gsi_for_stmt( stmt); gsi_insert_before( &gsi, gPPI_rhs1_cast, GSI_SAME_STMT); @@ -545,16 +565,18 @@ str_reorg_instance_interleave_trans ( Info *info) gsi_insert_before( &gsi, gPPI, GSI_SAME_STMT); gsi_insert_before( &gsi, gPPI_cast, GSI_SAME_STMT); + DEBUG_L("\n"); + gsi_remove ( &gsi, true); - //DEBUG_L(""); - //DEBUG_F( print_gimple_stmt, stderr, gPPI_rhs2_cast, 0); - //DEBUG_L(""); - //DEBUG_F( print_gimple_stmt, stderr, gPPI_adj, 0); - //DEBUG_L(""); - //DEBUG_F( print_gimple_stmt, stderr, gPPI, 0); - //DEBUG_L(""); - //DEBUG_F( print_gimple_stmt, stderr, gPPI_cast, 0); + DEBUG_A("gPPI_rhs2_cast: "); + DEBUG_F( print_gimple_stmt, stderr, gPPI_rhs2_cast, 0); + DEBUG_A("gPPI_adj"); + DEBUG_F( print_gimple_stmt, stderr, gPPI_adj, 0); + DEBUG_A("gPPI"); + DEBUG_F( print_gimple_stmt, stderr, gPPI, 0); + DEBUG_A("gPPI_cast"); + DEBUG_F( print_gimple_stmt, stderr, gPPI_cast, 0); } break; case ReorgT_Ptr2Zero: // "a = 0" @@ -3707,7 +3729,7 @@ pointer_conditional_transfer_transformation ( gimple *stmt, Info *info) else { convert_dest = - make_temp_ssa_name( op1_type, NULL, "cond_temp");; + make_temp_ssa_name( op1_type, NULL, "cond_temp"); convert_source = cond_op2; new_cond_op1 = cond_op1; new_cond_op2 = convert_dest; diff --git a/gcc/ipa-structure-reorg.c b/gcc/ipa-structure-reorg.c index bfe6c54a9c3..559416753f4 100644 --- a/gcc/ipa-structure-reorg.c +++ b/gcc/ipa-structure-reorg.c @@ -112,6 +112,7 @@ static void reorg_forbidden ( gimple *, Info *); static bool is_user_function ( gimple *, cgraph_node *, Info *); static bool is_reorg_alloc_trigger ( gimple *); static ReorgType_t *find_struct_type_ptr_to_struct ( tree, Info *); +static ReorgType_t *the_reorg_walker ( gimple *, Info *); //static ReorgType_t *get_reorgtype_info ( tree, Info *); //static void print_reorg_with_msg ( FILE *, ReorgType_t *, int, const char *); static void dump_reorg ( ReorgType_t *reorg); @@ -294,6 +295,7 @@ final_debug_info ( Info *info) { print_program ( info->reorg_dump_file, "Final State", PRINT_FORMAT, false, 0, info); } + DEBUG_F( print_program, stderr, "Final Internal State", true, true, 0, info); } static unsigned int @@ -3859,19 +3861,20 @@ struct hidden_info { static tree detect_reorg ( tree *tp, int *dummy, void *data) { - //DEBUG_A("detect_reorg:>\n"); + DEBUG_A("detect_reorg:>\n"); struct walk_stmt_info *walk_data = ( struct walk_stmt_info *)data; hidden_info_t *hi = ( hidden_info_t *)walk_data->info; - //DEBUG_L( "*tp = "); - //DEBUG_F( print_generic_expr, stderr, *tp, (dump_flags_t)-1); - //DEBUG("\n"); + DEBUG_L( "*tp = "); + DEBUG_F( flexible_print, stderr, *tp, 1, (dump_flags_t)-1); tree operand = base_type_of ( TREE_TYPE ( *tp)); ReorgType_t *ri = get_reorgtype_info ( operand, hi->info); if ( ri != NULL ) { + DEBUG_A("found\n"); hi->found_reorg = ri; } - + + DEBUG_A("not found\n"); return NULL_TREE; } @@ -3888,8 +3891,33 @@ contains_a_reorgtype ( gimple *stmt, Info *info) tree base = base_type_of ( TREE_TYPE ( PHI_RESULT ( stmt))); return get_reorgtype_info ( base, info); } + else if ( is_gimple_call ( stmt) ) + { + DEBUG_A("a call\n"); + ReorgType_t *just_walker = the_reorg_walker ( stmt, info); + if ( just_walker != NULL ) + { + DEBUG_A("walker found something\n"); + return just_walker; + } + tree return_type = function_return_type ( stmt, info); + DEBUG_A("return_type = "); + DEBUG_F( flexible_print, stderr, return_type, 1, (dump_flags_t)0); + //if ( TREE_CODE ( return_type) == VOID_TYPE) + if ( VOID_TYPE_P ( return_type) ) + { + DEBUG_A("VOID\n"); + return NULL; + } + else + { + DEBUG_A("Not VOID.. looking it up\n"); + return get_reorgtype_info ( return_type, info ); + } + } else { + #if 0 // Note walk_stmt_info is compilcated, use it's info // field for hidden_info hidden_info_t hi = { NULL, info }; @@ -3901,9 +3929,29 @@ contains_a_reorgtype ( gimple *stmt, Info *info) &walk_info); //INDENT(-2); return hi.found_reorg; + #else + return the_reorg_walker ( stmt, info); + #endif + } } +static ReorgType_t * +the_reorg_walker ( gimple *stmt, Info *info ) +{ + // Note walk_stmt_info is compilcated, use it's info + // field for hidden_info + hidden_info_t hi = { NULL, info }; + struct walk_stmt_info walk_info; // expt + memset ( &walk_info, 0, sizeof ( walk_info)); + walk_info.info = ( void*)&hi; //expt + walk_gimple_op ( stmt, + detect_reorg, + &walk_info); + //INDENT(-2); + return hi.found_reorg; +} + static tree detect_reorg_in_expr ( tree *tp, int *w_s, void *data) { @@ -3930,6 +3978,66 @@ detect_reorg_in_expr ( tree *tp, int *w_s, void *data) return NULL_TREE; } +// If this gets a void it goes looking for the effective type +tree +function_return_type ( gimple *stmt, Info *info ) +{ + DEBUG_A( "function_return_type:> "); + DEBUG_F ( print_gimple_stmt, stderr, stmt, 0); + INDENT(2); + tree bt = void_type_node; // default to void + // next line has issues but the mechanism is sound + tree t = *gimple_call_lhs_ptr ( stmt); + DEBUG_A( "t %p\n", t); + // Calls to a function returning void are skipped. + if ( t != NULL ) + { + DEBUG_A( "t: "); + DEBUG_F( flexible_print, stderr, t, 1, (dump_flags_t)0); + tree type = TREE_TYPE( t); + DEBUG_A( "type: "); + DEBUG_F( flexible_print, stderr, type, 1, (dump_flags_t)0); + + tree bt = base_type_of ( type); + if ( TREE_CODE( bt) == VOID_TYPE ) + { + // Find the use of lhs. If is an assign + // get use the base type of it's lhs. + // Otherwise never mind. Note, there + // can be multiple uses but find the "one" + // that's a simple assignment to a typed + // variable. + + tree ssa_name = gimple_call_lhs( stmt); + gimple *use_stmt; + imm_use_iterator iter; + int num_bt = 0; // Use future + FOR_EACH_IMM_USE_STMT ( use_stmt, iter, ssa_name) + { + DEBUG_A("use_stmt: "); + DEBUG_F ( print_gimple_stmt, stderr, use_stmt, 0); + if ( is_assign_from_ssa ( use_stmt ) ) + { + DEBUG_A("is assign from ssa\n"); + tree lhs_assign = gimple_assign_lhs( use_stmt); + tree lhs_type = TREE_TYPE ( lhs_assign); + tree lhs_base_type = base_type_of ( lhs_type); + //if ( TREE_CODE( lhs_base_type) != VOID_TYPE ) + if ( !VOID_TYPE_P ( lhs_base_type) ) + { + DEBUG_A("not void\n"); + return lhs_base_type; + //num_bt++; + //bt = lhs_base_type; + } + } + } + } + } + INDENT(-2); + return bt; +} + bool tree_contains_a_reorgtype_p ( tree expr, Info *info) { diff --git a/gcc/ipa-structure-reorg.h b/gcc/ipa-structure-reorg.h index c503946d791..9020bb86ee6 100644 --- a/gcc/ipa-structure-reorg.h +++ b/gcc/ipa-structure-reorg.h @@ -289,6 +289,7 @@ extern bool is_reorg_pointer_type ( tree, Info*); extern ReorgType_t *get_reorgtype_info ( tree, Info_t *); extern void print_reorg_with_msg ( FILE *, ReorgType_t *, int, const char *); extern ReorgType_t *contains_a_reorgtype ( gimple *, Info *); +extern tree function_return_type ( gimple *, Info *); extern bool tree_contains_a_reorgtype_p ( tree, Info *); extern ReorgType_t *tree_contains_a_reorgtype ( tree, Info *); extern tree multilevel_component_ref ( tree); @@ -309,7 +310,7 @@ extern bool is_assign_from_ssa ( gimple *); // I have no intention of leaving these debugging marcos or uses of // them in the code. However, some of the uses should obviously be // converted to dump file information. -#define DEBUGGING 0 +#define DEBUGGING 1 #if DEBUGGING enum Display { Show_nothing, |