<html><body bgcolor="#FFFFFF"><div>Hi shuxin, </div><div><br></div><div>Promote while-loop to do-loop is the job of loop induction recognized, not this transformation. The scalar transform for hwloop in optimizer is for that it is a trouble to discriminate trip counting code with the real production code stuff and do the elimination in cg,  we have to write customized code to handle this general stuff in ervey targets. So, we take the help from optimizer DCE,  make the trip count code hidden in emitted whirl, that greatly simply the design, especially interact with cg unroll, you can see the code, we add  validity check functionality , but the code reduced, more stable.<br><br>Gang</div><div><br>在 2012-11-23,3:17,Shuxin Yang <<a href="mailto:shuxin.llvm@gmail.com">shuxin.llvm@gmail.com</a>> 写道:<br><br></div><div></div><blockquote type="cite"><div>
    <div class="moz-cite-prefix">Hi, Gang:<br>
      <br>
         I remember there were different voices when you check-in the
      code. <br>
      I agree with them although I didn't reply your mail in open64's
      mailing list. <br>
      <br>
        In the transformation you illustrate, it involves two
      operations:<br>
        1) promote WHILE-loop into DO-loop (i.e noncountable loop to
      countable loop)<br>
        2) get rid of trip-count dec/inc and compare.<br>
      <br>
       1) is irrelevant to HW loop. Any scalar optimizer should handle
      1).<br>
      It is not difficult at all to handle 2) in CodeGen and it is
      unnecessary to <br>
      to introduce a Operator just for that purpose. <br>
      <br>
      Shuxin<br>
      <br>
      On 11/22/2012 06:03 AM, Gang Yu wrote:<br>
    </div>
    <blockquote cite="mid:7507086E-3FB2-4A71-9B9F-999EB0C1CC60@gmail.com" type="cite">
      <div>I am the designer for open64 hwloop structure, but I am not a
        student.</div>
      <div><br>
      </div>
      <div>Hope the following helps:</div>
      <div><br>
      </div>
      <div>To transform a loop into hwloop, we need the help from
        optimizer. For example, </div>
      <div><span class="Apple-style-span" style="font-family:
          sans-serif; -webkit-tap-highlight-color: rgba(26, 26, 26,
          0.296875); -webkit-composition-fill-color: rgba(175, 192, 227,
          0.230469); -webkit-composition-frame-color: rgba(77, 128, 180,
          0.230469); font-size: 13px; line-height: 19px; "><code style="background-color: rgb(249, 249, 249); " lang="text">
            <pre style="padding-top: 1em; padding-right: 1em; padding-bottom: 1em; padding-left: 1em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; border-left-style: dashed; border-top-color: rgb(47, 111, 171); border-right-color: rgb(47, 111, 171); border-bottom-color: rgb(47, 111, 171); border-left-color: rgb(47, 111, 171); color: black; background-color: rgb(249, 249, 249); line-height: 1.1em; ">   while(k3>=10){
     sum+=k1;
     k3 --;
   }
</pre>
          </code>
          <p style="margin-top: 0.4em; margin-right: 0px; margin-bottom:
            0.5em; margin-left: 0px; line-height: 1.5em; ">into the
            form:<code style="background-color: rgb(249, 249, 249); " lang="text"></code></p>
          <code style="background-color: rgb(249, 249, 249); " lang="text">
            <pre style="padding-top: 1em; padding-right: 1em; padding-bottom: 1em; padding-left: 1em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; border-left-style: dashed; border-top-color: rgb(47, 111, 171); border-right-color: rgb(47, 111, 171); border-bottom-color: rgb(47, 111, 171); border-left-color: rgb(47, 111, 171); color: black; background-color: rgb(249, 249, 249); line-height: 1.1em; ">   zdl_loop(k3-9) {
      sum+=k1;
   }
</pre>
          </code>
          <p style="margin-top: 0.4em; margin-right: 0px; margin-bottom:
            0.5em; margin-left: 0px; line-height: 1.5em; ">So, we
            introduce a new ZDLBR whirl(open64 optimizer intermediate)
            operator, which represents the loop in whirl as:<code style="background-color: rgb(249, 249, 249); " lang="text"></code></p>
          <code style="background-color: rgb(249, 249, 249); " lang="text">
            <pre style="padding-top: 1em; padding-right: 1em; padding-bottom: 1em; padding-left: 1em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; border-left-style: dashed; border-top-color: rgb(47, 111, 171); border-right-color: rgb(47, 111, 171); border-bottom-color: rgb(47, 111, 171); border-left-color: rgb(47, 111, 171); color: black; background-color: rgb(249, 249, 249); line-height: 1.1em; ">LABEL L2050 0 {line: 0}
LOOP_INFO 0 1 1
   I4I4LDID 73 <1,2,.preg_I4> T<4,.predef_I4,4> # k3
   I4I4LDID 77 <1,2,.preg_I4> T<4,.predef_I4,4> # <preg> 
 END_LOOP_INFO
   I4I4LDID 74 <1,2,.preg_I4> T<4,.predef_I4,4> # k1
   I4I4LDID 75 <1,2,.preg_I4> T<4,.predef_I4,4> # sum
  I4ADD
 I4STID 75 <1,2,.preg_I4> T<4,.predef_I4,4> # sum {line: 5}
 ZDLBR L2050 {line: 0}
</pre>
            <div>Then, we let cg do things. Such a design abstract the
              general operations in optimizer, while target specific
              part in cg, still a simulated op, until cg loop
              optimization finished. We implement a multi nested level
              hwloop by this approach. Gcc's 3 doloop expand names do
              the same, we believe.</div>
          </code></span>
        <div><br>
        </div>
        More details, please take a look at</div>
      <div><br>
      </div>
      <div><a moz-do-not-send="true" href="http://wiki.open64.net/index.php/Zero_Delay_Loop"><a href="http://wiki.open64.net/index.php/Zero_Delay_Loop">http://wiki.open64.net/index.php/Zero_Delay_Loop</a></a></div>
      <div><br>
      </div>
      <div>Thanks<br>
        Gang</div>
      <div><br>
      </div>
    </blockquote>
    <br>
  

</div></blockquote></body></html>