summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Oblock <gary@amperecomputing.com>2020-06-25 22:04:11 -0700
committerGary Oblock <gary@amperecomputing.com>2020-06-25 22:04:11 -0700
commita7611ae0ac4f0a1f851b91444ec2747c4bbe8a1f (patch)
tree39f70ad185437ab92b713ffa5ef15e7bb3fb02df
parentcb7743d77a90b9f5c696741e22daece19bb70764 (diff)
I finally got a working element assign idiom. Note, the mini pass for dangle reorg types is currently just a sanity check for missing transformations.
-rw-r--r--gcc/ipa-str-reorg-instance-interleave.c126
1 files changed, 99 insertions, 27 deletions
diff --git a/gcc/ipa-str-reorg-instance-interleave.c b/gcc/ipa-str-reorg-instance-interleave.c
index 70b27e170fe..e21554da887 100644
--- a/gcc/ipa-str-reorg-instance-interleave.c
+++ b/gcc/ipa-str-reorg-instance-interleave.c
@@ -193,7 +193,8 @@ str_reorg_instance_interleave_trans ( Info *info)
break;
case ReorgT_ElemAssign:
{
- break;
+ //break;
+ #define USE_MEM_REF 1
#if 0
gimple_stmt_iterator gsi = gsi_for_stmt( stmt);
@@ -507,15 +508,15 @@ str_reorg_instance_interleave_trans ( Info *info)
gimple *temp_set;
gimple *final_set;
- #if 0
- // DELETE THIS
+ #if USE_MEM_REF
// offset = index * size_of_field
tree size_of_field = TYPE_SIZE_UNIT ( base_field_type);
tree offset = make_temp_ssa_name( sizetype, NULL, "offset"); // TBD sizetype ???
- // DELETE THIS
+
gimple *get_offset = gimple_build_assign ( offset, MULT_EXPR, index, size_of_field);
- // DELETE THIS
+ #if 1
+ // DELETE THIS (WAIT!)
// field_addr = field_array + offset
// bug fix here (TBD) type must be *double not double
tree field_addr =
@@ -525,6 +526,7 @@ str_reorg_instance_interleave_trans ( Info *info)
gimple *get_field_addr =
gimple_build_assign ( field_addr, PLUS_EXPR, field_arry_addr, offset);
#endif
+ #endif
if ( ro_on_left )
{
@@ -542,15 +544,30 @@ str_reorg_instance_interleave_trans ( Info *info)
// gimple_build_assign( elem_to_set, field_val_temp);
// MOD THIS to ARRAY_REF
- #if 0
+ #if USE_MEM_REF
// NOTE, THIS (MEM_REF)SHOULD NOT WORK
// not tested yet!
// *field_addr = temp
- tree lhs_ref = build1 ( MEM_REF, field_type, field_addr);
+ // TODO
+ //tree lhs_ref = build1 ( MEM_REF, field_type, field_addr);
+
+ // NOPE!
+ //tree lhs_ref = build2 ( MEM_REF, base_field_type,
+ // base_field, offset);
+
+ tree lhs_ref = build2 ( MEM_REF, field_type, field_addr,
+ build_int_cst (ptr_type_node, 0));
+
#else
// field_arry_addr[index]
+ tree lhs_arry = build2 ( MEM_REF,
+ base_field_type, base_field,
+ build_int_cst (ptr_type_node, 0));
+ //tree lhs_ref =
+ // build4 ( ARRAY_REF, field_type, field_arry_addr, index,
+ // NULL_TREE, NULL_TREE);
tree lhs_ref =
- build4 ( ARRAY_REF, field_type, field_arry_addr, index,
+ build4 ( ARRAY_REF, field_type, lhs_arry, index,
NULL_TREE, NULL_TREE);
#endif
@@ -562,22 +579,57 @@ str_reorg_instance_interleave_trans ( Info *info)
// With: lhs = a->f
// Generate:
- //// temp = field_array[index]
- //tree elem_to_get =
- // build4 ( ARRAY_REF, field_type, field_arry_addr, index,
- // NULL_TREE, NULL_TREE);
- //temp_set =
- // gimple_build_assign( field_val_temp, elem_to_get);
+ // temp = *field_addr
+ #if USE_MEM_REF
+ // INDIRECT_REF is not supported fot GIMPLE... sigh...
+ // tree rhs_ref = build1 ( INDIRECT_REF, field_type, field_addr);
+
+ // This doesn't work
+ //tree rhs_ref = build2 ( MEM_REF,
+ // base_field_type, base_field, offset);
+ // Niether does this it dies on the offset
+ //tree rhs_ref = build2 ( MEM_REF,
+ // field_type, base_field, offset);
- // MOD THIS to ARRAY_REF
- // temp = *field_addr
- #if 0
- // I tried MEM_REF here and build1 had an internal error
- tree rhs_ref = build1 ( INDIRECT_REF, field_type, field_addr);
+ // This idiom seems to work (WTF?!)
+ tree rhs_ref = build2 ( MEM_REF, field_type, field_addr,
+ build_int_cst (ptr_type_node, 0));
+
+
+ // 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");
+
+ 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);
+ DEBUG_L("op0: ");
+ DEBUG_F(print_generic_expr, stderr, op0, (dump_flags_t)0);
+ DEBUG("\n")
+ DEBUG_L("op1: ");
+ DEBUG_F(print_generic_expr, stderr, op1, (dump_flags_t)0);
+ DEBUG("\n")
+ DEBUG_L("op1type: ");
+ DEBUG_F(print_generic_expr, stderr, op1type, (dump_flags_t)0);
+ DEBUG("\n");
+ DEBUG_L("op1type_type: %p\n", op1type_type);
+ DEBUG_L("op1type_type: ");
+ DEBUG_F(print_generic_expr, stderr, op1type_type, (dump_flags_t)0);
+ DEBUG("\n")
+
+
#else
+ //tree rhs_ref =
+ // build4 ( ARRAY_REF, field_type, field_arry_addr, index,
+ // NULL_TREE, NULL_TREE);
+ tree rhs_arry = build2 ( MEM_REF,
+ base_field_type, base_field,
+ build_int_cst (ptr_type_node, 0));
tree rhs_ref =
- build4 ( ARRAY_REF, field_type, field_arry_addr, index,
+ build4 ( ARRAY_REF, field_type, rhs_arry, index,
NULL_TREE, NULL_TREE);
#endif
@@ -596,17 +648,18 @@ str_reorg_instance_interleave_trans ( Info *info)
DEBUG_F( print_gimple_stmt, stderr, get_index, 0);
DEBUG("\n");
- #if 0
- // DELETE THIS
+ #if USE_MEM_REF
DEBUG_L("get_offset: ");
DEBUG_F( print_gimple_stmt, stderr, get_offset, 0);
DEBUG("\n");
- // DELETE THIS
+ #if 1
+ // DELETE THIS (WAIT!)
DEBUG_L("get_field_addr: ");
DEBUG_F( print_gimple_stmt, stderr, get_field_addr, 0);
DEBUG("\n");
#endif
+ #endif
DEBUG_L("temp_set: ");
DEBUG_F( print_gimple_stmt, stderr, temp_set, 0);
@@ -618,12 +671,13 @@ str_reorg_instance_interleave_trans ( Info *info)
gsi_insert_before( &gsi, get_field_arry_addr, GSI_SAME_STMT);
gsi_insert_before( &gsi, get_index, GSI_SAME_STMT);
- #if 0
- // DELETE THIS
+ #if USE_MEM_REF
gsi_insert_before( &gsi, get_offset, GSI_SAME_STMT);
- // DELETE THIS
+ #if 1
+ // DELETE THIS (WAIT!)
gsi_insert_before( &gsi, get_field_addr, GSI_SAME_STMT);
#endif
+ #endif
gsi_insert_before( &gsi, temp_set, GSI_SAME_STMT); // << malformed???
gsi_insert_before( &gsi, final_set, GSI_SAME_STMT);
@@ -1285,7 +1339,25 @@ str_reorg_instance_interleave_trans ( Info *info)
{
tree lhs = gimple_assign_lhs( stmt);
tree rhs = gimple_assign_rhs1( stmt);
- gcc_assert ( !tree_contains_a_reorgtype_p ( rhs, info));
+ bool lhs_reorg = tree_contains_a_reorgtype_p ( lhs, info);
+ bool rhs_reorg = tree_contains_a_reorgtype_p ( rhs, info);
+
+ if ( lhs_reorg || rhs_reorg )
+ {
+ print_gimple_stmt ( stderr, stmt, 0);
+ }
+ if ( lhs_reorg )
+ {
+ fprintf( stderr, " LHS: ");
+ print_generic_expr ( stderr, TREE_TYPE ( lhs), (dump_flags_t)0);
+ fprintf( stderr, " ");
+ }
+ if ( rhs_reorg )
+ {
+ fprintf( stderr, "%s RHS: ", lhs_reorg ? "," : "");
+ print_generic_expr ( stderr, TREE_TYPE ( rhs), (dump_flags_t)0);
+ fprintf( stderr, "\n");
+ }
// etc.
}