From 4789615e63750498eb7129054d5fc72d503f6bf9 Mon Sep 17 00:00:00 2001 From: Gary Oblock Date: Thu, 8 Oct 2020 18:43:21 -0700 Subject: This is a set of fixes that allow instance interleaving performance qualification to work for mcf. --- gcc/ipa-str-reorg-instance-interleave.c | 529 ++++++++++++++++++-------------- 1 file changed, 304 insertions(+), 225 deletions(-) (limited to 'gcc/ipa-str-reorg-instance-interleave.c') diff --git a/gcc/ipa-str-reorg-instance-interleave.c b/gcc/ipa-str-reorg-instance-interleave.c index f171359b661..7073c9fc1d2 100644 --- a/gcc/ipa-str-reorg-instance-interleave.c +++ b/gcc/ipa-str-reorg-instance-interleave.c @@ -109,9 +109,9 @@ static basic_block make_bb ( char *, basic_block); */ // These are dummy values tha alway result the reorganization -#define SINGLE_POOL_RAW_SKIP_IT 0.10 +#define SINGLE_POOL_RAW_SKIP_IT 0.05 #define SINGLE_POOL_RAW_DO_IT_ALWAYS 0.90 -#define SINGLE_POOL_ABS_SKIP_IT 0.05 +#define SINGLE_POOL_ABS_SKIP_IT 0.02 #define SINGLE_POOL_ABS_DO_IT_ALWAYS 0.10 int @@ -121,6 +121,7 @@ str_reorg_instance_interleave_qual ( Info *info) // str_reorg_instance_interleave_qual_part ( info); + //if ( BYPASS_TRANSFORM ) return 0; // this modifiies the qualified types. // str_reorg_instance_interleave_type_part ( info); @@ -130,17 +131,21 @@ str_reorg_instance_interleave_qual ( Info *info) int str_reorg_instance_interleave_trans ( Info *info) { + if ( BYPASS_TRANSFORM ) + { + + fprintf ( stderr, "Bypassing str_reorg_instance_interleave_trans for experiment\n"); + return 0; + } + if ( info->show_all_reorg_cands ) { fprintf ( info->reorg_dump_file, "Start of str_reorg_instance_interleave_trans:\n"); print_program ( info->reorg_dump_file, PRINT_FORMAT, 4, info); } - fprintf ( stderr, "Bypassing str_reorg_instance_interleave_trans for experiment\n"); - return 0; - - 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); struct cgraph_node *node; FOR_EACH_FUNCTION_WITH_GIMPLE_BODY ( node) { @@ -264,7 +269,7 @@ str_reorg_instance_interleave_trans ( Info *info) DEBUG_L("ReorgT_ElemAssign: "); DEBUG_F( print_gimple_stmt, stderr, stmt, 0); - INDENT(2); + //INDENT(2); // Needed for helloworld tree lhs = gimple_assign_lhs( stmt); tree rhs = gimple_assign_rhs1( stmt); @@ -446,14 +451,14 @@ str_reorg_instance_interleave_trans ( Info *info) } // end recognize_op ( rhs, info) switch - INDENT(-2); + //INDENT(-2); } // end ReorgT_ElemAssign case break; 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)); @@ -468,14 +473,14 @@ 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"); gimple_cond_set_rhs( cond_stmt, max); - 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: @@ -484,13 +489,13 @@ str_reorg_instance_interleave_trans ( Info *info) case ReorgT_IfPtrGT: case ReorgT_IfPtrLE: case ReorgT_IfPtrGE: - DEBUG_L("ReorgT_IfPtr*\n"); + //DEBUG_L("ReorgT_IfPtr*\n"); // Not needed for single pool. TBD test this 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. @@ -545,14 +550,14 @@ str_reorg_instance_interleave_trans ( Info *info) 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_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); } break; case ReorgT_Ptr2Zero: // "a = 0" @@ -606,14 +611,14 @@ str_reorg_instance_interleave_trans ( Info *info) gsi_remove ( &gsi, true); - DEBUG_L(""); - DEBUG_F( print_gimple_stmt, stderr, gPD_rhs1_cast, 0); - DEBUG_L(""); - DEBUG_F( print_gimple_stmt, stderr, gPD_rhs2_cast, 0); - DEBUG_L(""); - DEBUG_F( print_gimple_stmt, stderr, gPD, 0); - DEBUG_L(""); - DEBUG_F( print_gimple_stmt, stderr, gPD_cast, 0); + //DEBUG_L(""); + //DEBUG_F( print_gimple_stmt, stderr, gPD_rhs1_cast, 0); + //DEBUG_L(""); + //DEBUG_F( print_gimple_stmt, stderr, gPD_rhs2_cast, 0); + //DEBUG_L(""); + //DEBUG_F( print_gimple_stmt, stderr, gPD, 0); + //DEBUG_L(""); + //DEBUG_F( print_gimple_stmt, stderr, gPD_cast, 0); } break; case ReorgT_Adr2Ptr: // "a = &x[i]" @@ -635,7 +640,7 @@ str_reorg_instance_interleave_trans ( Info *info) break; case ReorgT_PtrNull: // "x = a == 0" case ReorgT_PtrNotNull: // "x = a != 0" - DEBUG_L("ReorgT_Ptr(Not)Null\n");\ + DEBUG_L("ReorgT_Ptr(Not)Null\n"); \ // TBD /* gimple_set_op( stmt, 2, @@ -654,7 +659,7 @@ str_reorg_instance_interleave_trans ( Info *info) case ReorgT_Malloc: { DEBUG_L("Transform ReorgT_Malloc\n"); - INDENT(2); + //INDENT(2); // We need to use the user malloc function // declaration rather than the builtin!!! @@ -1101,7 +1106,7 @@ str_reorg_instance_interleave_trans ( Info *info) //DEBUG_L("End of malloc:\n"); //DEBUG_F( print_program, PRINT_FORMAT, stderr, 4); } - INDENT(-2); + //INDENT(-2); break; case ReorgT_Calloc: // TBD @@ -1320,8 +1325,8 @@ str_reorg_instance_interleave_trans ( Info *info) // transform any constant zero into it's new repersentation. // OR MAYBE... use FOR_EACH_PHI_ARG for the iterator... - DEBUG_L("Phis with constant operands:\n"); - INDENT(4); + //DEBUG_L("Phis with constant operands:\n"); + //INDENT(4); gphi_iterator pi; for ( pi = gsi_start_phis (bb); !gsi_end_p (pi); gsi_next (&pi)) { @@ -1338,30 +1343,30 @@ str_reorg_instance_interleave_trans ( Info *info) for (int i = 0; i < gimple_phi_num_args (phi); i++) { tree *arg = gimple_phi_arg_def_ptr (phi, i); - DEBUG_A("arg[%d] = ",i); - DEBUG_F(flexible_print, stderr, *arg, 1, (dump_flags_t)0); + //DEBUG_A("arg[%d] = ",i); + //DEBUG_F(flexible_print, stderr, *arg, 1, (dump_flags_t)0); bool int_cst = TREE_CODE ( *arg) == INTEGER_CST; - DEBUG_A("is %sinteger constant\n", int_cst ? "" : "not "); + //DEBUG_A("is %sinteger constant\n", int_cst ? "" : "not "); if ( int_cst && integer_zerop ( *arg) ) { *arg = TYPE_MAX_VALUE ( ri->pointer_rep); - DEBUG_L("arg after = "); - DEBUG_F(flexible_print, stderr, *arg, 1, (dump_flags_t)0); + //DEBUG_L("arg after = "); + //DEBUG_F(flexible_print, stderr, *arg, 1, (dump_flags_t)0); } } } } - INDENT(-4); + //INDENT(-4); } 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); + //DEBUG ("INTERNALS PRINT\n"); + //DEBUG_F (apply_to_all_gimple, print_internals, true, (void *)info); // A mini-pass to fixup dangling SSA temps. @@ -1372,7 +1377,7 @@ str_reorg_instance_interleave_trans ( Info *info) std::vector 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); @@ -1404,21 +1409,21 @@ 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( print_generic_decl, stderr, parm, (dump_flags_t)0); + //DEBUG("\n"); + //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( print_generic_expr, stderr, old_default_def, (dump_flags_t)0); + //DEBUG("\n"); tree new_default_def; // Modify prameter and do the default def stuff @@ -1428,9 +1433,9 @@ 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( print_generic_decl, stderr, parm, (dump_flags_t)0); + //DEBUG("\n"); // New default def here @@ -1457,11 +1462,11 @@ 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(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"); // TBD REMOVE DUPLICATE! // Replace old one (not really totally hence the @@ -1475,8 +1480,8 @@ str_reorg_instance_interleave_trans ( Info *info) // new default def FOR_EACH_IMM_USE_STMT ( stmt, iter, old_default_def) // <== use other form??? Not { - DEBUG_A("before: "); - DEBUG_F ( print_gimple_stmt, stderr, stmt, 0); + //DEBUG_A("before: "); + //DEBUG_F ( print_gimple_stmt, stderr, stmt, 0); use_operand_p use_p; ssa_op_iter ssa_iter; // The F_E_S_U_O macro was blowing up on a phi @@ -1485,14 +1490,14 @@ 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( print_generic_expr, stderr, use, (dump_flags_t)0); + //DEBUG("\n"); 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 // @@ -1501,12 +1506,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); @@ -1521,9 +1526,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( print_generic_decl, stderr, decl, (dump_flags_t)0); + //DEBUG("\n"); tree old_default_def = ssa_default_def ( func, decl); tree new_default_def; @@ -1563,28 +1568,28 @@ str_reorg_instance_interleave_trans ( Info *info) } } } - INDENT(-4); + //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; } @@ -1595,42 +1600,42 @@ 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++) { @@ -1646,8 +1651,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; @@ -1656,14 +1661,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 @@ -1672,12 +1677,12 @@ 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); + //DEBUG_L("def: "); + //DEBUG_F ( print_gimple_stmt, stderr, def, 0); set_lhs_for ( def, new_ssa_name); @@ -1687,7 +1692,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 @@ -1700,29 +1705,19 @@ str_reorg_instance_interleave_trans ( Info *info) pop_cfun (); } - DEBUG_L("after mini-passes\n"); - - if ( info->show_all_reorg_cands ) - { - fprintf ( info->reorg_dump_file, "End of str_reorg_instance_interleave_trans:\n"); - print_program ( info->reorg_dump_file, PRINT_FORMAT, 4, info); - } + // This used to be off of.. "if ( info->show_all_reorg_cands ) { ..." + // I'm leaning towards deleting this as redundnt. + //DEBUG ( info->reorg_dump_file, + // "\nEnd of str_reorg_instance_interleave_trans (after mini-psasses):\n\n"); + //DEBUG_F ( print_program, info->reorg_dump_file, PRINT_FORMAT, 4, info); // TBD Should this be a diagnostic or not? - 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); - // Spin through all the functions and recompute the dominace info. - FOR_EACH_FUNCTION_WITH_GIMPLE_BODY ( node) { - struct function *func = DECL_STRUCT_FUNCTION ( node->decl); - push_cfun ( func); - if ( dom_info_available_p ( CDI_DOMINATORS) ) - { - free_dominance_info ( CDI_DOMINATORS); - } - calculate_dominance_info (CDI_DOMINATORS); - pop_cfun (); - } + // NOTE, spinning through all the functions and recomputing all the + // dominace info here is a really bad idea. + return 0; } @@ -1977,7 +1972,7 @@ reorg_perf_qual ( Info *info) { fprintf ( info->reorg_dump_file, "Doing Performance Qualification\n"); } - DEBUG_L("reorg_perf_qual:\n"); + //DEBUG_L("reorg_perf_qual:\n"); #if 1 // TBD use design in doc but mark ReorgTypes // (do_instance_interleave) that qualify instead of deleting them @@ -2030,11 +2025,13 @@ reorg_perf_qual ( Info *info) // However, the dominace calculations other things need it. push_cfun ( func); + #if 1 if ( dom_info_available_p ( CDI_DOMINATORS) ) { free_dominance_info ( CDI_DOMINATORS); } calculate_dominance_info (CDI_DOMINATORS); + #endif if ( info->show_perf_qualify ) { @@ -2065,13 +2062,17 @@ reorg_perf_qual ( Info *info) { basic_block bb = bbs [i]; //DEBUG_A("BB %i:\n", bb->index); - INDENT(4); + //INDENT(4); for ( auto gsi = gsi_start_bb ( bb); !gsi_end_p ( gsi); gsi_next ( &gsi) ) { gimple *stmt = gsi_stmt ( gsi); //DEBUG_A("examine: "); //DEBUG_F ( print_gimple_stmt, stderr, stmt, TDF_DETAILS); - INDENT(4); + //INDENT(4); + + if ( gimple_code ( stmt) == GIMPLE_LABEL || + gimple_code ( stmt) == GIMPLE_SWITCH ) continue; + unsigned n_ops = gimple_num_ops( stmt); tree op; unsigned ith_op; @@ -2080,8 +2081,8 @@ reorg_perf_qual ( Info *info) op = gimple_op ( stmt, ith_op); // It's lieing about the number of operands... so... if ( op == NULL ) continue; - //DEBUG_A("op[%d]: %p", ith_op, op); - //DEBUG_F(flexible_print, stderr, op, 0, (dump_flags_t)0); + //DEBUG_A("op[%d]: %p, ", ith_op, op); + //DEBUG_F(flexible_print, stderr, op, 1, (dump_flags_t)0); ReorgType_t *tri = tree_contains_a_reorgtype ( op, info); enum ReorgOpTrans optran = recognize_op ( op, false, info); // TBD This is where we need to remember @@ -2138,9 +2139,9 @@ reorg_perf_qual ( Info *info) missing_cases = true; } } - INDENT(-4); + //INDENT(-4); } - INDENT(-4); + //INDENT(-4); } //DEBUG_L("Dumping acc_info:\n"); @@ -2166,8 +2167,8 @@ reorg_perf_qual ( Info *info) compress_acc_infos ( acc_info ); - DEBUG_A("after compress: \n"); - DEBUG_F(print_acc_infos, stderr, acc_info ); + //DEBUG_A("after compress: \n"); + //DEBUG_F(print_acc_infos, stderr, acc_info ); // Obtain loop count by looking at all the block counts. unsigned loop_count = 0; @@ -2176,13 +2177,17 @@ reorg_perf_qual ( Info *info) basic_block bb = bbs [i]; loop_count = MAX( loop_count, bb->count.value ()); } - DEBUG_L("loop_count = %d, nb_iterations_estimate = %ld\n", - loop_count, loop->nb_iterations_estimate); + //DEBUG_L("loop_count = %d, nb_iterations_estimate = %ld\n", + // loop_count, loop->nb_iterations_estimate); // Create the variable infos varInfo_t var_entry; var_entry.rep_access = &acc_info[0]; unsigned len = acc_info.size (); + + // If no accesses detected, never for this loop. + if ( len == 0 ) continue; + if ( len == 1 ) { var_entry.fields.push_front ( acc_info[0].field); @@ -2206,12 +2211,16 @@ reorg_perf_qual ( Info *info) } var_info.push_back( var_entry); - print_var_infos ( stderr, var_info); + if ( info->show_perf_qualify ) + { + fprintf ( stderr, "%d VarInfos\n", var_info.size ()); + } + //DEBUG_F(print_var_infos, stderr, var_info); // // Model the performance // - DEBUG_A("Model The Performance\n"); + //DEBUG_A("Model The Performance\n"); // Originally this was done per bb but now it has to be per // loop. TBD But perf_bb is per loop so we need something similar @@ -2223,17 +2232,16 @@ reorg_perf_qual ( Info *info) ReorgType_t *ri = pvi->rep_access->reorg; // Reorg accounting - DEBUG_L("\n"); - DEBUG_A("Reorg Accounting\n"); + //DEBUG_L("\n"); + //DEBUG_A("Reorg Accounting\n"); if( ri != NULL ) { double reorg_nca = 0.0; - DEBUG_A(" for: "); - DEBUG_F( flexible_print, stderr, ri->gcc_type, 1, (dump_flags_t)0); - - INDENT(4); + //DEBUG_A(" for: "); + //DEBUG_F( flexible_print, stderr, ri->gcc_type, 1, (dump_flags_t)0); + //INDENT(4); for ( auto fldi = pvi->fields.begin (); fldi != pvi->fields.end (); fldi++ ) { unsigned HOST_WIDE_INT fld_width = @@ -2241,18 +2249,18 @@ reorg_perf_qual ( Info *info) double effect = alignment_effect ( fld_width); double product = loop_count * effect; reorg_nca += product; - DEBUG_A("Add loop_count * effect (%d * %f = %f) to reorg_nca (now %f)\n", - loop_count, effect, product, reorg_nca); + //DEBUG_A("Add loop_count * effect (%d * %f = %f) to reorg_nca (now %f)\n", + // loop_count, effect, product, reorg_nca); } - INDENT(-4); + //INDENT(-4); ri->instance_interleave.reorg_perf += reorg_nca; - DEBUG_A("Add reorg_nca (%f) to reorg_perf (now %e)\n", - reorg_nca, ri->instance_interleave.reorg_perf); + //DEBUG_A("Add reorg_nca (%f) to reorg_perf (now %e)\n", + // reorg_nca, ri->instance_interleave.reorg_perf); } // 699 // regular accounting - DEBUG_L("\n"); - DEBUG_A("Regular Accounting\n"); + //DEBUG_L("\n"); + //DEBUG_A("Regular Accounting\n"); double regular_nca = 0.0; sbitmap cache_model = sbitmap_alloc(1); @@ -2261,11 +2269,14 @@ reorg_perf_qual ( Info *info) { // 704 tree access = pv2i->rep_access->base_info.acc_base; tree base_type; // = base_type_of ( access); - if ( pv2i->rep_access->reorg != NULL ) { + if ( pv2i->rep_access->reorg != NULL ) + { + //DEBUG_A("Base type from reorg: "); base_type = pv2i->rep_access->reorg->gcc_type; } else { + //DEBUG_A("Base type from access: "); if ( TREE_TYPE ( access ) != NULL ) { base_type = base_type_of ( access); @@ -2275,15 +2286,56 @@ reorg_perf_qual ( Info *info) gcc_assert (0); } } + //DEBUG_F( flexible_print, stderr, base_type, 1, (dump_flags_t)0); bool base_type_isa_decl = DECL_P ( base_type ); // create a tiny model of the cache big // enough for this record. + #if 0 tree base_type_size = base_type_isa_decl ? DECL_SIZE ( base_type ) : TYPE_SIZE ( base_type); + #else + tree base_type_size; + if ( base_type_isa_decl ) + { + //DEBUG_A("decl\n"); + switch ( TREE_CODE (base_type) ) + { + case VAR_DECL: + { + //DEBUG_A("VAR_DECL\n"); + base_type_size = TYPE_SIZE ( base_type); + break; + } + case FIELD_DECL: + { + //DEBUG_A("VAR_DECL\n"); + base_type_size = TYPE_SIZE ( TREE_TYPE ( base_type)); + break; + } + default: + { + //DEBUG_A("other decl %s\n", code_str(TREE_CODE (base_type))); + gcc_assert(0); + } + } + } + else + { + //DEBUG_A("nondecl %s\n", code_str(TREE_CODE (base_type))); + if ( TREE_CODE ( base_type) == SSA_NAME ) + { + base_type_size = TYPE_SIZE ( TREE_TYPE( base_type)); + } + else + { + base_type_size = TYPE_SIZE ( base_type); + } + } + #endif unsigned HOST_WIDE_INT len = (( tree_to_uhwi ( base_type_size) @@ -2293,15 +2345,21 @@ reorg_perf_qual ( Info *info) param_l1_cache_line_size) + 1; - DEBUG_L("\n"); - DEBUG_A("cache len = %d\n", len); + //DEBUG_L("\n"); + //DEBUG_A("cache len = %d (lines), for: ", len); + //DEBUG_F( flexible_print, stderr, base_type, 0, (dump_flags_t)0); + //DEBUG("%sstruct\n") // TBD Does this clear the bits??? It needs to. // Each bit represents a cache line. cache_model = sbitmap_resize( cache_model, (unsigned) len, 0); double accum = 0.0; int nrbo = 0; - if ( base_type_isa_decl ) + tree type = TREE_TYPE ( base_type); + + //bool a_record = type == NULL && TREE_CODE ( type) == RECORD_TYPE; + bool a_record = type != NULL && TREE_CODE ( type) == RECORD_TYPE; + if ( base_type_isa_decl && a_record ) { for ( auto field_ex = TYPE_FIELDS ( base_type); field_ex; @@ -2312,14 +2370,14 @@ reorg_perf_qual ( Info *info) // why this is here and what it does. Sigh... unsigned HOST_WIDE_INT base_offset = tree_to_uhwi ( DECL_FIELD_OFFSET( field_ex)); - DEBUG_L("\n"); - DEBUG_A("For field_ex: "); - DEBUG_F( flexible_print, stderr, field_ex, 0, (dump_flags_t)0); - DEBUG(", nrbo %d, base_offset %d\n", nrbo, base_offset); + //DEBUG_L("\n"); + //DEBUG_A("For field_ex: "); + //DEBUG_F( flexible_print, stderr, field_ex, 0, (dump_flags_t)0); + //DEBUG(", nrbo %d, base_offset %d\n", nrbo, base_offset); // Access accounting - INDENT(4); + //INDENT(4); for ( auto fldi = pv2i->fields.begin (); fldi != pv2i->fields.end (); fldi++ ) { @@ -2327,27 +2385,27 @@ reorg_perf_qual ( Info *info) unsigned HOST_WIDE_INT fld_width, fld_offset; fld_width = tree_to_uhwi ( DECL_SIZE ( field)); fld_offset = tree_to_uhwi ( DECL_FIELD_OFFSET ( field)); - DEBUG_A("Field: "); - DEBUG_F( flexible_print, stderr, field, 0, (dump_flags_t)0); - DEBUG(", width = %d, offset = %d\n", fld_width, fld_offset); + //DEBUG_A("Field: "); + //DEBUG_F( flexible_print, stderr, field, 0, (dump_flags_t)0); + //DEBUG(", width = %d, offset = %d\n", fld_width, fld_offset); int chari; - INDENT(4); + //INDENT(4); for ( chari = 0; chari < fld_width; chari++ ) { int loc = (chari + fld_offset + base_offset) / param_l1_cache_line_size; - DEBUG_A("loc: %d\n", loc); + //DEBUG_A("loc: %d\n", loc); bitmap_set_bit ( cache_model, loc); } - INDENT(-4); + //INDENT(-4); } - INDENT(-4); + //INDENT(-4); unsigned bcount = bitmap_count_bits ( cache_model); accum += bcount; - DEBUG_L("\n"); - DEBUG_A("Add popcount of cache (%d) to accum (now %f)\n", - bcount, accum); + //DEBUG_L("\n"); + //DEBUG_A("Add popcount of cache (%d) to accum (now %f)\n", + // bcount, accum); bitmap_clear ( cache_model); } } @@ -2355,22 +2413,22 @@ reorg_perf_qual ( Info *info) { nrbo = 1; accum++; - DEBUG_L("\n"); - DEBUG_A("nrbo = 1, increment accum to %f\n", accum); + //DEBUG_L("\n"); + //DEBUG_A("nrbo = 1, increment accum to %f\n", accum); } #if 1 double amount = accum / nrbo; double product = amount * loop_count; regular_nca += product; - DEBUG_L("\n"); - DEBUG_A("Add loop_count*accum/nrbo (%f*%f/%d = %f) to regular_nca (now %e)\n", - loop_count, accum, nrbo, product, regular_nca); + //DEBUG_L("\n"); + //DEBUG_A("Add loop_count*accum/nrbo (%f*%f/%d = %f) to regular_nca (now %e)\n", + // loop_count, accum, nrbo, product, regular_nca); #else double amount = accum / nrbo; regular_nca += amount; - DEBUG_L("\n"); - DEBUG_A("Add accum/nrbo (%f/%d = %f) to regular_nca (now %e)\n", - accum, nrbo, amount, regular_nca); + //DEBUG_L("\n"); + //DEBUG_A("Add accum/nrbo (%f/%d = %f) to regular_nca (now %e)\n", + // accum, nrbo, amount, regular_nca); #endif } // 739 sbitmap_free ( cache_model); @@ -2378,11 +2436,11 @@ reorg_perf_qual ( Info *info) if( ri != NULL ) { ri->instance_interleave.regular_perf += regular_nca; cache_accesses_noreorg += regular_nca; - DEBUG_L("\n"); - DEBUG_A("Add regular_nca (%f) to regular_perf (now %e)", - regular_nca, ri->instance_interleave.regular_perf); - DEBUG_A(" and to cache_accesses_noreorg (now %e)\n", - cache_accesses_noreorg); + //DEBUG_L("\n"); + //DEBUG_A("Add regular_nca (%f) to regular_perf (now %e)", + // regular_nca, ri->instance_interleave.regular_perf); + //DEBUG_A(" and to cache_accesses_noreorg (now %e)\n", + // cache_accesses_noreorg); } else { cache_accesses += regular_nca; } @@ -2435,12 +2493,12 @@ reorg_perf_qual ( Info *info) double raw_effect = with_opt/without_opt; double absolute_effect = (without_opt - with_opt) / total_cache_accesses; - DEBUG_A("For "); - DEBUG_F(flexible_print, stderr, reorgi->gcc_type, 0, (dump_flags_t)0); - DEBUG(" with_opt: %e, without_opt %e, total_cache_accesses %e\n", - with_opt, without_opt, total_cache_accesses); - DEBUG_A(" Raw Effect: %5.4f, Absolute Effect %5.4f\n", - raw_effect, absolute_effect); + //DEBUG_A("For "); + //DEBUG_F(flexible_print, stderr, reorgi->gcc_type, 0, (dump_flags_t)0); + //DEBUG(" with_opt: %e, without_opt %e, total_cache_accesses %e\n", + // with_opt, without_opt, total_cache_accesses); + //DEBUG_A(" Raw Effect: %5.4f, Absolute Effect %5.4f\n", + // raw_effect, absolute_effect); // Note, there would need to be a multi-pool case here if // that is every done. @@ -2455,7 +2513,7 @@ reorg_perf_qual ( Info *info) (dump_flags_t)0); fprintf ( info->reorg_dump_file, ": Very small effect:\n"); fprintf ( info->reorg_dump_file, - " raw_effect %5.4 < SINGLE_POOL_RAW_SKIP_IT %5.4\n", + " raw_effect %5.4f < SINGLE_POOL_RAW_SKIP_IT %5.4f\n", raw_effect, SINGLE_POOL_RAW_SKIP_IT); } reorgi->do_instance_interleave = false; @@ -2577,7 +2635,8 @@ static void compress_acc_infos ( std::vector ainfo ) { unsigned len = ainfo.size (); - if ( len == 1 ) return; + //DEBUG_L("compress_acc_infos: len in %d, ",len); + if ( len <= 1 ) return; unsigned i, j; for ( i = j = 1; j < len; j++ ) { @@ -2586,11 +2645,13 @@ compress_acc_infos ( std::vector ainfo ) } if ( i == j ) return; ainfo.resize ( len - (j -i)); + //DEBUG_L("len out %d, ", ainfo.size ()); } static void print_acc_info ( FILE *file, acc_info_t *ainfo ) { + //DEBUG_L("print_acc_info: ainfo %p\n", ainfo); fprintf ( file, "%s%s%s%s%s%s\n", ainfo->base_info.a_def_def ? ", deflt_def" : "", ainfo->base_info.a_decl ? ", decl" : "", @@ -2804,10 +2865,10 @@ is_array_access( tree acc) static void account_for_access ( tree access, tree field, std::vector *acc_info, Info_t *info) { - DEBUG_A("account_for_use var: "); - DEBUG_F(flexible_print, stderr, access, 0, (dump_flags_t)0); - DEBUG(", field: "); - DEBUG_F(flexible_print, stderr, field, 1, (dump_flags_t)0); + //DEBUG_A("account_for_use var: "); + //DEBUG_F(flexible_print, stderr, access, 0, (dump_flags_t)0); + //DEBUG(", field: "); + //DEBUG_F(flexible_print, stderr, field, 1, (dump_flags_t)0); // assert might eventually make sense but not yet //gcc_assert ( TREE_CODE ( ssa_var) == SSA_NAME); @@ -2826,7 +2887,7 @@ account_for_access ( tree access, tree field, std::vector *acc_info static void tmasn_helper ( tree t, int indent, std::set *already ) { - DEBUG_A(""); + //DEBUG_A(""); fprintf( stderr, "%*s", indent, " "); indent += 4; flexible_print ( stderr, t, 0, (dump_flags_t)0); @@ -2839,7 +2900,7 @@ tmasn_helper ( tree t, int indent, std::set *already ) { fprintf( stderr, "\n"); } - DEBUG_L("code: %s\n", code_str(TREE_CODE (t))); + //DEBUG_L("code: %s\n", code_str(TREE_CODE (t))); if ( TREE_CODE (t) == SSA_NAME ) { already->insert (t); @@ -2905,16 +2966,20 @@ tell_me_about_ssa_name ( tree ssa_name, int indent) tmasn_helper ( ssa_name, indent, &already); } +static unsigned insane_helper; + static void an_ac_helper ( tree t, int indent, std::set *already, acc_info_t *ainfo ) { + gcc_assert ( insane_helper < 100 ); + insane_helper++; acc_base_info_t *binfo = &ainfo->base_info; - DEBUG_A("%*s", indent, " "); + //DEBUG_A("%*s", indent, " "); indent += 4; - DEBUG_F( flexible_print, stderr, t, 0, (dump_flags_t)0); + //DEBUG_F( flexible_print, stderr, t, 0, (dump_flags_t)0); if ( already->find (t) != already->end () ) { - DEBUG(" \n"); + //DEBUG(" \n"); binfo->multi_induct = binfo->multi_induct || binfo->has_induct_var_acc; binfo->induct_base = t; @@ -2923,15 +2988,16 @@ an_ac_helper ( tree t, int indent, std::set *already, acc_info_t *ainfo ) } else { - DEBUG("\n"); + //DEBUG("\n"); + } - DEBUG_A("%*scode: %s\n", indent, " ", code_str(TREE_CODE (t))); + //DEBUG_A("%*scode: %s\n", indent, " ", code_str(TREE_CODE (t))); if ( TREE_CODE (t) == SSA_NAME ) { already->insert (t); gimple *stmt = SSA_NAME_DEF_STMT (t); - DEBUG_A("%*sSSA_NAME defined in: ", indent, " "); - DEBUG_F(print_gimple_stmt, stderr, stmt, TDF_DETAILS); + //DEBUG_A("%*sSSA_NAME defined in: ", indent, " "); + //DEBUG_F(print_gimple_stmt, stderr, stmt, TDF_DETAILS); if ( SSA_NAME_IS_DEFAULT_DEF ( t ) ) { binfo->acc_base = t; @@ -2990,21 +3056,33 @@ an_ac_helper ( tree t, int indent, std::set *already, acc_info_t *ainfo ) binfo->complicated || binfo->a_def_def || binfo->a_decl || binfo->a_func; binfo->a_decl = true; - DEBUG_A("field (index) for a_decl: "); - DEBUG_F(flexible_print, stderr, ainfo->field, 1, (dump_flags_t)0); + //DEBUG_A("field (index) for a_decl: "); + //DEBUG_F(flexible_print, stderr, ainfo->field, 1, (dump_flags_t)0); - an_ac_helper ( ainfo->field, indent, already, ainfo); + if ( TREE_CODE ( t) != FIELD_DECL ) + { + an_ac_helper ( ainfo->field, indent, already, ainfo); + } return; } if ( TREE_CODE ( t) == MEM_REF ) { tree t_0 = TREE_OPERAND ( t, 0); - DEBUG_A("%*sMEM_REF t_0: ", indent, " "); - DEBUG_F(flexible_print, stderr, t_0, 1, (dump_flags_t)0); + //DEBUG_A("%*sMEM_REF t_0: ", indent, " "); + //DEBUG_F(flexible_print, stderr, t_0, 1, (dump_flags_t)0); + an_ac_helper ( t_0 , indent, already, ainfo); + return; + } + if ( TREE_CODE ( t) == COMPONENT_REF ) + { + tree t_0 = TREE_OPERAND ( t, 0); + //DEBUG_A("%*sCOMPONENT_REF t_0: ", indent, " "); + //DEBUG_F(flexible_print, stderr, t_0, 1, (dump_flags_t)0); an_ac_helper ( t_0 , indent, already, ainfo); return; } if ( TREE_CODE ( t) == INTEGER_CST ) return; + if ( TREE_CODE ( t) == ADDR_EXPR ) return; fprintf ( stderr, "Unanticipated TREE_CODE\n"); gcc_assert ( 0); } @@ -3012,8 +3090,9 @@ an_ac_helper ( tree t, int indent, std::set *already, acc_info_t *ainfo ) static void analyze_access ( tree access, acc_info_t *acc_info) { + insane_helper = 0; acc_base_info_t *base_info = &acc_info->base_info; - DEBUG_A("analyze_access:\n"); + //DEBUG_A("analyze_access:\n"); base_info->a_def_def = false; base_info->a_decl = false; base_info->a_func = false; @@ -3295,10 +3374,10 @@ static basic_block make_bb ( char *msg, basic_block prev_bb ) { basic_block ret = create_empty_bb ( prev_bb); - DEBUG_A( "make_bb ( %s, /%p ): /%p, prev: /%p, next: /%p\n", - msg, prev_bb->index, prev_bb, - ret->index, ret, - ret->prev_bb->index, ret->prev_bb, - ret->next_bb->index, ret->next_bb); + //DEBUG_A( "make_bb ( %s, /%p ): /%p, prev: /%p, next: /%p\n", + // msg, prev_bb->index, prev_bb, + // ret->index, ret, + // ret->prev_bb->index, ret->prev_bb, + // ret->next_bb->index, ret->next_bb); return ret; } -- cgit v1.2.3