---------------------------------------- > From: ajit.kumar.agar...@xilinx.com > To: l...@redhat.com; richard.guent...@gmail.com; gcc@gcc.gnu.org > CC: vin...@xilinx.com; shail...@xilinx.com; vid...@xilinx.com; > nmek...@xilinx.com > Subject: Proposal for another approach for Loop transformation with > conditional in Loops. > Date: Sun, 15 Mar 2015 04:40:54 +0000 > > Hello All: > > I am proposing the new approach to Loop transformation as given below in the > example For the loops with > conditional expression inside the Loops. The Loop body should be reducible > control flow graph. The iteration > space is partitioned into different spaces for which either the cond_expr is > true or cond_expr is false. The > evaluation of cond_expr for the partitioned iteration spaces can be > determined statically. For the partitioned > iterations and based on the analysis of cond_expr on the partitioned > iterations spaces the Loops in fig (a) will > be transformed to Loops in fig (b). > > for the iteration spaces of the conditional inside the loop is live in at the > entry of the cond_expr and Live out > the Control flow graph is topological ordered with the basic blocks for the > conditional CFG and the partitioned > iteration spaces can be formed for which the spaces can be true for > conditional expr and false and unknown. > > Based on the above info and analysis the Loop of Fig (a) will be transformed > to Loop Fig (b). > > This is much more optimized code as compared to the performance. The cases > will be triggered for SPEC > Benchmarks. Loops is partitioned to different version with different > iteration spaces. Optimized in the presence > Of the transformed generation of the loops without conditional. > > For ( x1= lb1; x1<= ub1; x1++) > .. > For(xn= lbn; xn <= ubn; xn++) > { > > V = cond_expr; > If ( V) > Code_FOR _THEN; > Else > Code_FOR_ELSE; > } > > } > Fig(a) > > /* Loop for cond_expr == true */ > For( x1 = ................................) > For(xn = ............................) > CODE_FOR_THEN; > End > End > > /* Loop for cond_expr == false */ > For ( x1 = ......................) > For( xn = .......................) > CODE_FOR_ELSE; > End > End > > /* Loop for cond_expr == unknown *// > For ( x1 = ...........................) > For( xn = ........................ > { > V = cond_expr; > If( v) > CODE_FOR_THEN; > Else > CODE_FOR_ELSE; > } > } > > Fig ( b). > > Thoughts Please ? > > Thanks & Regards > Ajit
Also, to add to it, we could have profile feedback so that we only do this in the case of hot loops and not do when optimizing for size. -Aditya