<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi, Chandler:<br>
    <br>
      Thank you for pointing out the problem. Yes, the "&&"
    should be replaced with "||".<br>
    I will commit the fix after some tests.  I don't feel like to
    include a testing case for <br>
    such inadvertent bug.  <br>
    <br>
       Following is the contrived *.ll to reproduce the problem. <br>
    <br>
    <br>
      /the/path/to/opt  -loop-idiom -mtriple=x86_64-apple-darwin
    -mcpu=corei7 a.ll -S -o -<br>
    <br>
    cat a.ll<br>
    <br>
    target triple = "x86_64-apple-macosx10.8.0"<br>
    <br>
    define i32 @PopCnt(i64 %a) nounwind uwtable readnone ssp {<br>
    entry:<br>
      %tobool3 = icmp eq i64 %a, 0<br>
      br i1 %tobool3, label %while.end, label %while.body<br>
    <br>
    while.body:                                       ; preds = %entry,
    %while.body<br>
      %c.05 = phi i32 [ %inc, %while.body ], [ 0, %entry ]<br>
      %a.addr.04 = phi i64 [ %and, %while.body ], [ %a, %entry ]<br>
      %t = add i32 %c.05, %c.05<br>
      %inc = add nsw i32 %t, 1<br>
      %sub = add i64 %a.addr.04, -1<br>
      %and = and i64 %sub, %a.addr.04<br>
      %tobool = icmp eq i64 %and, 0<br>
      br i1 %tobool, label %while.end, label %while.body<br>
    <br>
    while.end:                                        ; preds =
    %while.body, %entry<br>
      %c.0.lcssa = phi i32 [ 0, %entry ], [ %inc, %while.body ]<br>
      ret i32 %c.0.lcssa<br>
    }<br>
    <br>
       <br>
    <br>
    <br>
    <div><br>
    </div>
    <blockquote
cite="mid:CAGCO0Kh4Mx2qH58mWmp3qKLGXvh9OMjCskhvVGgVKJsdCbSLOA@mail.gmail.com"
      type="cite">
      <div style="font-family: arial, helvetica, sans-serif; font-size:
        10pt">
        <div dir="ltr">
          <div class="gmail_extra">
            <div class="gmail_quote">
              <div>
                <div
                  style="font-family:arial,helvetica,sans-serif;font-size:13px">This
                  is incorrect, and will crash LLVM on certain inputs:
                  if InitConst is null here, we pass the test and pass
                  it to CreateAdd below that eventually segfaults.
                  Please fix, and please add a test case for this case.
                  I spotted it by inspection (after some code in the
                  wild crashed). I can try to help you with a testcase
                  if you need, but it should be quite straight forward
                  to synthesize one.</div>
              </div>
              <div
                style="font-family:arial,helvetica,sans-serif;font-size:13px">-------</div>
              <div
                style="font-family:arial,helvetica,sans-serif;font-size:13px"><br>
              </div>
              <div
                style="font-family:arial,helvetica,sans-serif;font-size:13px">
                Here is the snippet regarding the other one I spotted by
                inspection:</div>
              <div
                style="font-family:arial,helvetica,sans-serif;font-size:13px">----</div>
              <div
                style="font-family:arial,helvetica,sans-serif;font-size:13px">
                <div class="im">
                  <blockquote class="gmail_quote" style="margin:0px 0px
                    0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">+
                         PHINode *Phi =
                    dyn_cast<PHINode>(Inst->getOperand(0));<br>
                    +      if (!Phi && Phi->getParent() !=
                    LoopEntry)<br>
                  </blockquote>
                  <div><br>
                  </div>
                </div>
                <br>
              </div>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>