summaryrefslogtreecommitdiff
path: root/gcc/ipa-str-reorg-instance-interleave.c
diff options
context:
space:
mode:
authorGary Oblock <gary@amperecomputing.com>2020-09-05 14:06:28 -0700
committerGary Oblock <gary@amperecomputing.com>2020-09-05 14:06:28 -0700
commit505cb71e1db6ca699d06b4d6ba1a0a0865605fd4 (patch)
tree4ecb4e5c4a35a557edf8473cfdedf9011bfa2ccc /gcc/ipa-str-reorg-instance-interleave.c
parentcbfcdc8e69e841364ae47f1649f7cb4ccd3a83c7 (diff)
Fixed bug that cropped up with inlining on. I needed to add a result
decl to function decls who's return type that I modified. Added code for pointer difference transformation. It's mostly semantic sugar to make GCC happy but it also required multiplying by the structure size (to counteract the code dividing by it.)
Diffstat (limited to 'gcc/ipa-str-reorg-instance-interleave.c')
-rw-r--r--gcc/ipa-str-reorg-instance-interleave.c84
1 files changed, 69 insertions, 15 deletions
diff --git a/gcc/ipa-str-reorg-instance-interleave.c b/gcc/ipa-str-reorg-instance-interleave.c
index 7ba1da525f9..82a3919100a 100644
--- a/gcc/ipa-str-reorg-instance-interleave.c
+++ b/gcc/ipa-str-reorg-instance-interleave.c
@@ -484,7 +484,7 @@ str_reorg_instance_interleave_trans ( Info *info)
tree PPI_orig_lhs = gimple_assign_lhs ( stmt);
- tree offset_type = TREE_TYPE ( TYPE_SIZE_UNIT (ri->gcc_type));
+ //tree offset_type = TREE_TYPE ( TYPE_SIZE_UNIT (ri->gcc_type)); // not needed
tree type = ri->pointer_rep;
tree str_siz =
@@ -546,8 +546,56 @@ str_reorg_instance_interleave_trans ( Info *info)
*/
break;
case ReorgT_PtrDiff: // "i = a - b"
- DEBUG_L("ReorgT_PtrDiff\n");
- // Do nothing in the single pool case. TBD test this
+ {
+ DEBUG_L("ReorgT_PtrDiff\n");
+ // We basically need to modify the gimple code
+ // but that also means adding converts.
+ tree type = ri->pointer_rep;
+ tree str_siz =
+ build_int_cst ( type, int_cst_value ( TYPE_SIZE_UNIT (ri->gcc_type)));
+ tree rhs1 = gimple_assign_rhs1( stmt);
+ tree rhs2 = gimple_assign_rhs2( stmt);
+ tree PD_orig_lhs = gimple_assign_lhs ( stmt);
+
+ tree PD_rhs1_cast = make_temp_ssa_name( type, NULL, "PD_rhs1_cast");
+ gimple *gPD_rhs1_cast = gimple_build_assign ( PD_rhs1_cast, CONVERT_EXPR, rhs1);
+ SSA_NAME_DEF_STMT ( PD_rhs1_cast) = gPD_rhs1_cast;
+
+ tree PD_rhs2_cast = make_temp_ssa_name( type, NULL, "PD_rhs2_cast");
+ gimple *gPD_rhs2_cast = gimple_build_assign ( PD_rhs2_cast, CONVERT_EXPR, rhs2);
+ SSA_NAME_DEF_STMT ( PD_rhs2_cast) = gPD_rhs2_cast;
+
+ tree ptrdiff = make_temp_ssa_name( type, NULL, "PtrDiff");
+ gimple *gPD =
+ gimple_build_assign ( ptrdiff, MINUS_EXPR, PD_rhs1_cast, PD_rhs2_cast);
+ SSA_NAME_DEF_STMT ( ptrdiff) = gPD;
+
+ tree PD_adjust = make_temp_ssa_name( type, NULL, "PD_adjust");
+ gimple *gPD_adjust =
+ gimple_build_assign ( PD_adjust, MULT_EXPR, ptrdiff, str_siz);
+
+ gimple *gPD_cast =
+ gimple_build_assign ( PD_orig_lhs, CONVERT_EXPR, PD_adjust);
+ SSA_NAME_DEF_STMT ( PD_orig_lhs) = gPD_cast;
+
+ gimple_stmt_iterator gsi = gsi_for_stmt( stmt);
+ gsi_insert_before( &gsi, gPD_rhs1_cast, GSI_SAME_STMT);
+ gsi_insert_before( &gsi, gPD_rhs2_cast, GSI_SAME_STMT);
+ gsi_insert_before( &gsi, gPD, GSI_SAME_STMT);
+ gsi_insert_before( &gsi, gPD_adjust, GSI_SAME_STMT);
+ gsi_insert_before( &gsi, gPD_cast, GSI_SAME_STMT);
+
+ 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);
+ }
break;
case ReorgT_Adr2Ptr: // "a = &x[i]"
DEBUG_L("ReorgT_Adr2Ptr\n");
@@ -1271,8 +1319,8 @@ str_reorg_instance_interleave_trans ( Info *info)
DEBUG_L("Mini-Pass on Function %s:\n", lang_hooks.decl_printable_name ( func->decl, 2));
- DEBUG_L("\n");
- DEBUG_F( wolf_fence, info);
+ //DEBUG_L("\n");
+ //DEBUG_F( wolf_fence, info);
// We need a map of old ssa_name to new ssa_name. Not currently used.
std::map <tree,tree> ssa_map;
@@ -1295,6 +1343,11 @@ str_reorg_instance_interleave_trans ( Info *info)
// Default defs case first
// For parameters
+
+ // Note, we don't do anything unless it's necessary and it's
+ // not necessay if it's been done before. Hence the possibility
+ // 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);
@@ -1396,11 +1449,11 @@ str_reorg_instance_interleave_trans ( Info *info)
INDENT(-2);
}
INDENT(-4);
-
+
DEBUG_L("Dangling Types for Function Local (default defs).\n");
INDENT(4);
- DEBUG_L("\n");
- DEBUG_F( wolf_fence, info);
+ //DEBUG_L("\n");
+ //DEBUG_F( wolf_fence, info);
// For locals
//
@@ -1459,8 +1512,8 @@ str_reorg_instance_interleave_trans ( Info *info)
// Normal ssa name case
DEBUG_L("Dangling Types for Normal SSA Names:\n");
- DEBUG_L("\n");
- DEBUG_F( wolf_fence, info);
+ //DEBUG_L("\n");
+ //DEBUG_F( wolf_fence, info);
INDENT(4);
// We use len instead of using func->length() in the for loop test
@@ -1538,7 +1591,7 @@ 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: ");
+ DEBUG_L("use_stmt before: ");
DEBUG_F ( print_gimple_stmt, stderr, use_stmt, 0);
// Deal with the uses
@@ -1554,6 +1607,9 @@ str_reorg_instance_interleave_trans ( Info *info)
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);
+
// Should update_stmt be called here?
// It does not seem either harm or help so I'll
// leave it in.
@@ -1564,8 +1620,7 @@ 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, (dump_flags_t)0);
- DEBUG("\n");
+ DEBUG_F(flexible_print, stderr, ssa_name, 1, (dump_flags_t)0);
gimple *def = SSA_NAME_DEF_STMT ( ssa_name);
DEBUG_L("def: ");
@@ -1713,8 +1768,7 @@ print_internals (gimple *stmt, void *data)
bool lhs_reorg = tree_contains_a_reorgtype_p ( lhs, info);
//DEBUG_L("rhs1 = ");
- //DEBUG_F(flexible_print, stderr, rhs1, (dump_flags_t)0);
- //DEBUG("\n");
+ //DEBUG_F(flexible_print, stderr, rhs1, 1, (dump_flags_t)0);
bool rhs1_reorg = tree_contains_a_reorgtype_p ( rhs1, info);
bool rhs2_reorg = tree_contains_a_reorgtype_p ( rhs2, info);
bool rhs3_reorg = tree_contains_a_reorgtype_p ( rhs3, info);