Mei,
I have a question, why is there need for "compiler generated temps"? What
is that? Compiler generated temps should be PREGs that has no
"storage" requirements (to me, temps has storage allocation associated)
Sun
On Wed, May 30, 2012 at 4:04 PM, <s...@open64.net> wrote:
> Author: meiye
> Date: 2012-05-30 19:04:01 -0400 (Wed, 30 May 2012)
> New Revision: 3928
>
> Modified:
> trunk/osprey/be/opt/opt_cfg_trans.cxx
> trunk/osprey/be/opt/opt_proactive.cxx
> trunk/osprey/be/opt/opt_proactive.h
> trunk/osprey/be/opt/opt_wn.cxx
> Log:
> Cosmetic changes to add trace/dump/assert and use better names, CR:
> Jian-xin Lai
>
> Modified: trunk/osprey/be/opt/opt_cfg_trans.cxx
> ===================================================================
> --- trunk/osprey/be/opt/opt_cfg_trans.cxx 2012-05-30 22:43:20 UTC
> (rev 3927)
> +++ trunk/osprey/be/opt/opt_cfg_trans.cxx 2012-05-30 23:04:01 UTC
> (rev 3928)
> @@ -286,6 +286,11 @@
> if (do_pro_loop_fusion || do_pro_loop_interchange) {
> pro_loop_trans->Hash_def_cnt_map(sc_root);
>
> + if (dump) {
> + fprintf(TFile, "\b Before proactive loop transformation\n");
> + _cfg->Print(TFile, false, (unsigned) -1);
> + }
> +
> if (do_pro_loop_fusion) {
> // Start a top-down if-merging.
> pro_loop_trans->Set_pass(PASS_GLOBAL);
> @@ -320,6 +325,13 @@
> printf("\n\t Proactive Loop Fusion total:%d\n",
> pro_loop_trans->Transform_count());
> }
> +
> + if (dump) {
> + if (pro_loop_trans_count > 0) {
> + fprintf(TFile, "\b After proactive loop fusion\n");
> + _cfg->Print(TFile, false, (unsigned) -1);
> + }
> + }
> }
>
> if (do_pro_loop_interchange) {
> @@ -340,6 +352,13 @@
> if (count_delta > 0)
> printf("\n\t Proactive Loop Interchange total:%d\n",
> count_delta);
> }
> +
> + if (dump) {
> + if (count_delta > 0) {
> + fprintf(TFile, "\b After proactive loop interchange\n");
> + _cfg->Print(TFile, false, (unsigned) -1);
> + }
> + }
> }
>
> if (do_pro_loop_ext) {
> @@ -360,6 +379,13 @@
> if (count_delta > 0)
> printf("\n\t Extended Proactive Loop Fusion total:%d\n",
> count_delta);
> }
> +
> + if (dump) {
> + if (count_delta > 0) {
> + fprintf(TFile, "\b After extended proactive loop fusion\n");
> + _cfg->Print(TFile, false, (unsigned) -1);
> + }
> + }
> }
>
> pro_loop_trans->Delete();
>
> Modified: trunk/osprey/be/opt/opt_proactive.cxx
> ===================================================================
> --- trunk/osprey/be/opt/opt_proactive.cxx 2012-05-30 22:43:20 UTC
> (rev 3927)
> +++ trunk/osprey/be/opt/opt_proactive.cxx 2012-05-30 23:04:01 UTC
> (rev 3928)
> @@ -1383,6 +1383,8 @@
> sc_iter1 = sc_iter1->Parent();
> sc_iter2 = sc_iter2->Parent();
> }
> +
> + return 0;
> }
>
> // Count number of loops on the path from this SC_NODE to given sc_root.
> @@ -1517,6 +1519,8 @@
> BOOL
> SC_NODE::Is_same(SC_NODE * sc)
> {
> + FmtAssert((sc != this), ("Expect different SC_NODE."));
> +
> if ((type != sc->Type())
> || (kids->Len() != sc->Kids()->Len()))
> return FALSE;
> @@ -1656,12 +1660,12 @@
> return TRUE;
> }
>
> -// Create and return a temporary MTYPE_I4 array of 'size'
> +// Create and return a temporary 'mtype' array of 'size'
> ST *
> -CFG_TRANS::Tmp_array_st(int size)
> +CFG_TRANS::Tmp_array_st(MTYPE mtype, int size)
> {
> TY_IDX arr_ty_idx;
> - TY_IDX ele_ty_idx = MTYPE_To_TY(MTYPE_I4);
> + TY_IDX ele_ty_idx = MTYPE_To_TY(mtype);
> TY & ty = New_TY(arr_ty_idx);
> TY_Init (ty, size * TY_size(ele_ty_idx), KIND_ARRAY, MTYPE_UNKNOWN,
> Save_Str("_local_temp_array"));
>
> @@ -1695,6 +1699,10 @@
> CFG_TRANS::Create_array_load(ST * st, WN * wn_index)
> {
> TY_IDX ty_idx = ST_type(*st);
> + FmtAssert((TY_kind(ty_idx) == KIND_ARRAY), ("Expect an array."));
> + ARB_HANDLE arb = TY_arb(ty_idx);
> + FmtAssert((ARB_dimension(arb) == 1), ("Expect 1 dimension."));
> +
> TY_IDX element_ty_idx = TY_etype(ty_idx);
> TYPE_ID element_type_id = TY_mtype(element_ty_idx);
> UINT64 element_size = TY_size(element_ty_idx);
> @@ -1747,6 +1755,7 @@
> TY_IDX ty_idx = ST_type(*st);
> TY_IDX element_ty_idx = TY_etype(ty_idx);
> TYPE_ID element_type_id = TY_mtype(element_ty_idx);
> + FmtAssert((element_type_id == WN_rtype(wn_val)), ("Type of store value
> does not match"));
> UINT64 element_size = TY_size(element_ty_idx);
> UINT64 element_count = TY_size(ty_idx) / element_size;
> TY_IDX ty_ptr = Make_Pointer_Type(element_ty_idx);
> @@ -5215,7 +5224,6 @@
> cfg->Invalidate_and_update_aux_info(FALSE);
> cfg->Invalidate_loops();
> Inc_transform_count();
> - Inc_transform_count();
> }
>
> // Insert a single-entry-single-exit region defined by (src_entry,
> src_exit) between
> @@ -6711,7 +6719,6 @@
> PRO_LOOP_INTERCHANGE_TRANS::Process_non_identical_nodes
> (STACK<SC_NODE *> * fusion_stack, SC_NODE * outer_loop, UINT32 path_code)
> {
> - BOOL is_candidate = TRUE;
> for (int i = 0; i < fusion_stack->Elements(); i++) {
> SC_NODE * sc_cur = fusion_stack->Top_nth(i);
> SC_NODE * inner_loop = sc_cur;
> @@ -6724,25 +6731,22 @@
> SC_NODE * sc_iter = inner_loop->Next_sibling();
> while (sc_iter) {
> if (Has_dependency(sc_iter, inner_loop)) {
> - is_candidate = FALSE;
> - break;
> + return FALSE;
> }
> sc_iter = sc_iter->Next_sibling();
> }
>
> - if (is_candidate) {
> - if (!Is_invariant(inner_loop, sc_if->Get_cond(), 0)
> - || !Do_sink_node(sc_if, inner_loop, TRUE)) {
> - is_candidate = FALSE;
> - break;
> + if (!Is_invariant(inner_loop, sc_if->Get_cond(), 0)
> + || !Do_sink_node(sc_if, inner_loop, TRUE)) {
> + return FALSE;
> + }
> + else {
> + if (_trace) {
> + printf("\n\t\t Func: %s(%d) sink loop (SC%d) out of if-condition
> (SC:%d)\n",
> + Current_PU_Name(), Current_PU_Count(), inner_loop->Id(),
> sc_if->Id());
> }
> - else {
> - if (_trace) {
> - printf("\n\t\t Func: %s(%d) sink loop (SC%d) out of
> if-condition (SC:%d)\n",
> - Current_PU_Name(), Current_PU_Count(),
> inner_loop->Id(), sc_if->Id());
> - }
> - }
> }
> +
> continue;
> }
>
> @@ -6759,24 +6763,20 @@
> sc_cur = inner_loop->Get_nesting_if(level);
> if (!Do_canon(sc_cur, inner_loop, SPLIT_IF_HEAD | HEAD_DUP |
> TAIL_DUP | CHK_LEGAL)
> || !Do_if_cond_dist(sc_cur, TRUE)) {
> - is_candidate = FALSE;
> - break;
> + return FALSE;
> }
> level--;
> }
> }
> else
> - is_candidate = FALSE;
> + return FALSE;
> break;
> }
> - cur_code >>= 1;
> - level++;
> - }
> -
> - if (!is_candidate)
> - break;
> + cur_code >>= 1;
> + level++;
> + }
> }
> - return is_candidate;
> + return TRUE;
> }
>
> // Process identical if-conditions between the outer loop and the inner
> loop.
> @@ -6819,10 +6819,7 @@
>
> if (is_invar || is_partial_invar) {
> // Do if-condition tree-height reduction and/or loop unswitching.
> - if (sc_tmp && !Do_if_cond_tree_height_reduction(outer_if,
> sc_if->Parent())) {
> - ;
> - }
> - else {
> + if (!sc_tmp || Do_if_cond_tree_height_reduction(outer_if,
> sc_if->Parent())) {
> sc_if = inner_loop->Get_nesting_if(outer_loop);
> if (Do_loop_unswitching(sc_if, outer_loop, !is_invar))
> return TRUE;
> @@ -7154,14 +7151,24 @@
> // Swap 'sc_if' with if-conditions are nested insider it. The
> transformation is limited to
> // perfectly-nested SC_IFs with either an empty then-path or an empty
> else-path, e.g.,
> //
> -// if (...) {
> -// if (...) {
> -// if (...) {
> +// From:
> +// if (a) {
> +// if (b) {
> +// if (c) {
> // ...
> // }
> // }
> // }
> //
> +// To:
> +// if (b) {
> +// if (c) {
> +// if (a) {
> +// ...
> +// }
> +// }
> +// }
> +//
> // Caller of this routine should ensure the legality.
> BOOL
> PRO_LOOP_INTERCHANGE_TRANS::Do_swap_if(SC_NODE * sc_if)
> @@ -7212,6 +7219,8 @@
>
> // Do loop unswitching for nested if-regions whose conditional
> expressions are loop invariants
> // in a top down order, e.g., the outermost if-condition is hoisted first.
> +//
> +// From:
> // for (..) {
> // if (invar1) {
> // if (invar2) {
> @@ -7219,6 +7228,14 @@
> // }
> // }
> // }
> +//
> +// To:
> +// if (invar1) {
> +// if (invar2) {
> +// for (...)
> +// }
> +// }
> +//
> void
> PRO_LOOP_INTERCHANGE_TRANS::Top_down_do_loop_unswitch(SC_NODE * sc_loop)
> {
> @@ -7620,7 +7637,7 @@
>
> // Create a temporay array.
> int trip_cnt = upper_bound - lower_bound + 1;
> - ST * array_st = Tmp_array_st(trip_cnt);
> + ST * array_st = Tmp_array_st(MTYPE_I4, trip_cnt);
>
> for (int i = 0; i < size; i++) {
> SC_NODE * sc_if = stk_precomp->Bottom_nth(i);
> @@ -10218,13 +10235,15 @@
> // }
> // }
> // else {
> -// if (a) {
> -// block 1;
> +// for (...) {
> +// if (a) {
> +// block 1;
> +// }
> +// else {
> +// a = ...;
> +// block 2;
> +// }
> // }
> -// else {
> -// a = ...;
> -// block 2;
> -// }
> // }
> //
> // Caller of this routine must canonicalize the if-condition first.
> @@ -15293,6 +15312,7 @@
> CFG_TRANS::Get_wn_by_aux_id(AUX_ID aux_id, WN * wn)
> {
> OPERATOR opr = WN_operator(wn);
> + FmtAssert(opr != OPR_BLOCK, ("Illegal input WHILR"));
>
> if (OPERATOR_is_scalar_load(opr)
> && (WN_aux(wn) == aux_id))
>
> Modified: trunk/osprey/be/opt/opt_proactive.h
> ===================================================================
> --- trunk/osprey/be/opt/opt_proactive.h 2012-05-30 22:43:20 UTC (rev 3927)
> +++ trunk/osprey/be/opt/opt_proactive.h 2012-05-30 23:04:01 UTC (rev 3928)
> @@ -532,7 +532,7 @@
> void Set_hi(MAP *, WN *, int);
> std::pair<bool,int> Clone_val(WN *, WN *, MAP *);
> WN * Get_wn_by_aux_id(AUX_ID, WN *);
> - ST * Tmp_array_st(int);
> + ST * Tmp_array_st(MTYPE mtype, int);
> WN * Create_array_store(ST *, WN *, WN *);
> WN * Create_array_load(ST *, WN *);
>
>
> Modified: trunk/osprey/be/opt/opt_wn.cxx
> ===================================================================
> --- trunk/osprey/be/opt/opt_wn.cxx 2012-05-30 22:43:20 UTC (rev 3927)
> +++ trunk/osprey/be/opt/opt_wn.cxx 2012-05-30 23:04:01 UTC (rev 3928)
> @@ -1857,7 +1857,7 @@
> }
>
> // Add all integer constant elements in 'stk'.
> -static INT64 Add_const_wn_stack(STACK<WN *> * stk)
> +static INT64 Add_const_in_stack(STACK<WN *> * stk)
> {
> INT64 sum = 0;
> for (int i = 0; i < stk->Elements(); i++) {
> @@ -1870,7 +1870,7 @@
>
> // Collect addition and substraction operands in 'wn',
> // save addition operands in 'stack1', save substraction operands in
> 'stack2'.
> -static void Add_wn_stack(WN * wn, STACK<WN *> * stack1, STACK<WN *> *
> stack2, MEM_POOL * pool)
> +static void Collect_wn_stack(WN * wn, STACK<WN *> * stack1, STACK<WN *> *
> stack2, MEM_POOL * pool)
> {
> STACK<WN *> * add_stk = CXX_NEW(STACK<WN *> (pool), pool);
> STACK<WN *> * sub_stk = CXX_NEW(STACK<WN *> (pool), pool);
> @@ -1894,26 +1894,26 @@
> CXX_DELETE(sub_stk, pool);
> }
>
> -// Find elements in 'stack1' that matches 'wn_iter2' and remove such
> elements
> -// from 'stack1'. Return TRUE if found. Expression "x" is considered to
> match
> +// Find elements in 'stack' that matches 'wn_match' and remove such
> elements
> +// from 'stack'. Return TRUE if found. Expression "x" is considered to
> match
> // expression "c * x", where c is an integer constant. In this case, also
> return
> // the diff "(c - 1) * x".
> static std::pair<WN *, BOOL>
> -Get_diff(WN * wn2_iter, STACK<WN *> * stack1, MEM_POOL * pool)
> +Get_diff(WN * wn_match, STACK<WN *> * stack, MEM_POOL * pool)
> {
> WN * wn_mul = NULL;
> WN * wn_diff = NULL;
>
> - if ((WN_operator(wn2_iter) == OPR_MPY)
> - && (WN_operator(WN_kid1(wn2_iter)) == OPR_INTCONST))
> - wn_mul = WN_kid0(wn2_iter);
> + if ((WN_operator(wn_match) == OPR_MPY)
> + && (WN_operator(WN_kid1(wn_match)) == OPR_INTCONST))
> + wn_mul = WN_kid0(wn_match);
>
> BOOL found = FALSE;
> - STACK<WN *> * stack_tmp1 = CXX_NEW(STACK<WN *>(pool), pool);
> - for (int j = 0; j < stack1->Elements(); j++) {
> - WN * wn1_iter = stack1->Top_nth(j);
> - if (WN_Simp_Compare_Trees(wn1_iter, wn2_iter) == 0) {
> - stack1->DeleteTop(j);
> + STACK<WN *> * stack_tmp = CXX_NEW(STACK<WN *>(pool), pool);
> + for (int j = 0; j < stack->Elements(); j++) {
> + WN * wn1_iter = stack->Top_nth(j);
> + if (WN_Simp_Compare_Trees(wn1_iter, wn_match) == 0) {
> + stack->DeleteTop(j);
> found = TRUE;
> break;
> }
> @@ -1922,26 +1922,26 @@
> // expressions like 'x+x' is equal to '2*x'.
> int cnt = 0;
> WN * wn_tmp;
> - while (!stack_tmp1->Is_Empty())
> - stack_tmp1->Pop();
> + while (!stack_tmp->Is_Empty())
> + stack_tmp->Pop();
>
> - for (int k = 0; k < stack1->Elements(); k++) {
> - wn_tmp = stack1->Top_nth(k);
> + for (int k = 0; k < stack->Elements(); k++) {
> + wn_tmp = stack->Top_nth(k);
> if (WN_Simp_Compare_Trees(wn_mul, wn_tmp) == 0)
> cnt++;
> else
> - stack_tmp1->Push(wn_tmp);
> + stack_tmp->Push(wn_tmp);
> }
>
> - INT64 val = WN_const_val(WN_kid1(wn2_iter));
> + INT64 val = WN_const_val(WN_kid1(wn_match));
> if (cnt == val) {
> - // Remove matched elements from 'stack1'.
> - while (!stack1->Is_Empty())
> - stack1->Pop();
> + // Remove matched elements from 'stack'.
> + while (!stack->Is_Empty())
> + stack->Pop();
>
> - while (!stack_tmp1->Is_Empty()) {
> - wn_tmp = stack_tmp1->Pop();
> - stack1->Push(wn_tmp);
> + while (!stack_tmp->Is_Empty()) {
> + wn_tmp = stack_tmp->Pop();
> + stack->Push(wn_tmp);
> }
> found = TRUE;
> break;
> @@ -1953,7 +1953,7 @@
> }
> }
> }
> - CXX_DELETE(stack_tmp1, pool);
> + CXX_DELETE(stack_tmp, pool);
> return std::pair<WN *, bool>(wn_diff, found);
> }
>
> @@ -2041,8 +2041,8 @@
> STACK<WN *> * stack1 = CXX_NEW(STACK<WN *> (pool), pool);
> STACK<WN *> * stack2 = CXX_NEW(STACK<WN *> (pool), pool);
>
> - Add_wn_stack(wn1, stack1, stack2, pool);
> - Add_wn_stack(wn2, stack2, stack1, pool);
> + Collect_wn_stack(wn1, stack1, stack2, pool);
> + Collect_wn_stack(wn2, stack2, stack1, pool);
> STACK<WN *> * stack_tmp1 = NULL;
> STACK<WN *> * stack_tmp2 = NULL;
> BOOL do_swap = FALSE;
> @@ -2077,7 +2077,7 @@
> WN * wn_deriv = WN_get_deriv(wn_iter, deriv_map);
> if (wn_deriv && (WN_operator(wn_deriv) == OPR_LT)) {
> wn_deriv = WN_kid1(wn_deriv);
> - Add_wn_stack(wn_deriv, stack_tmp1, stack_tmp2, pool);
> + Collect_wn_stack(wn_deriv, stack_tmp1, stack_tmp2, pool);
> }
> else
> stack_tmp1->Push(wn_iter);
> @@ -2094,10 +2094,10 @@
>
> int delta = 0;
> if (stack_tmp1)
> - delta -= Add_const_wn_stack(stack_tmp1);
> + delta -= Add_const_in_stack(stack_tmp1);
>
> if (stack_tmp2)
> - delta += Add_const_wn_stack(stack_tmp2);
> + delta += Add_const_in_stack(stack_tmp2);
>
> // Evalute diff of stack_tmp1 and stack_tmp2 using deriv_map.
> BOOL is_disjoint = TRUE;
> @@ -2141,8 +2141,8 @@
> }
>
> // Evaluate diff of stack1 and stack2 using lo_map and hi_map.
> - delta = Add_const_wn_stack(stack1);
> - delta -= Add_const_wn_stack(stack2);
> + delta = Add_const_in_stack(stack1);
> + delta -= Add_const_in_stack(stack2);
> int delta_lo = delta;
> int delta_hi = delta;
> std::pair<bool, int> p_val;
> @@ -2217,6 +2217,8 @@
> WN_has_indir_load(WN * wn)
> {
> OPERATOR opr = WN_operator(wn);
> + FmtAssert(opr != OPR_BLOCK, ("Illegal input WHILR"));
> +
> if (OPERATOR_is_load(opr) && !OPERATOR_is_scalar_load(opr))
> return TRUE;
>
>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Open64-devel mailing list
> Open64-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/open64-devel
>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Open64-devel mailing list
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel