Hi, Could a gatekeeper please review the attached patch.
This patch fixes a problem in load folding optimization where the memory location used in the load operation is overwritten by a store operation. A check is added to prevent folding of such load operations. The test-case and the patch is attached with the mail. Regards, Shivaram AMD Open Source Compiler Engineering
testcase.f
Description: testcase.f
Index: be/cg/x8664/ebo_special.cxx =================================================================== --- be/cg/x8664/ebo_special.cxx (revision 3725) +++ be/cg/x8664/ebo_special.cxx (working copy) @@ -10891,6 +10891,8 @@ #if Is_True_On if (!(EBO_Opt_Mask & EBO_FOLD_LOAD_DUPLICATE)) return FALSE; #endif + ARC_LIST *true_arcs, *arcs; + OPS ops = OPS_EMPTY; BOOL do_unpckhpd = FALSE; if (OP_code(op) != TOP_fmovddup && OP_code(op) != TOP_vmovddup) @@ -10983,7 +10985,41 @@ return FALSE; if (index_loc >= 0 && !Pred_Opnd_Avail(op, loaded_tn_info, index_loc)) return FALSE; + // for this bb, obtain the dependence graph so that we can + // walk this op's expression tree to check dependencies. + // Make sure that load operand is not overwritten + // by a store operation before op using this dependency graph. + CG_DEP_Compute_Graph ( op->bb, + NO_ASSIGNED_REG_DEPS, + NON_CYCLIC, + NO_MEMREAD_ARCS, + INCLUDE_MEMIN_ARCS, + NO_CONTROL_ARCS, + NULL); + + + const INT hash_value = EBO_hash_op( load, NULL ); + EBO_OP_INFO* opinfo = EBO_opinfo_table[hash_value]; + + while( opinfo != NULL ) { + OP* next_op = opinfo->in_op; + if( next_op == load ) break; + if( next_op && OP_store( next_op ) ) { + for (arcs = OP_succs(load); arcs != NULL; arcs = ARC_LIST_rest(arcs)) { + ARC *arc = ARC_LIST_first(arcs); + if (ARC_kind(arc) != CG_DEP_MEMANTI) continue; + OP *succ_op = ARC_succ(arc); + if ((succ_op == next_op) && OP_Precedes(next_op, op)) { + CG_DEP_Delete_Graph (op->bb); + return FALSE; + } + } + } + opinfo = opinfo->same; + } + CG_DEP_Delete_Graph (op->bb); + TOP topcode; if (base && offset && index && scale) { new_op = Mk_OP (TOP_fmovddupxx,
------------------------------------------------------------------------------ EMC VNX: the world's simplest storage, starting under $10K The only unified storage solution that offers unified management Up to 160% more powerful than alternatives and 25% more efficient. Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
_______________________________________________ Open64-devel mailing list Open64-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/open64-devel