<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - getBasicBlockIndex() returns -1. [LoopUnroller, LoopPeel]"
   href="https://bugs.llvm.org/show_bug.cgi?id=33384">33384</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>getBasicBlockIndex() returns -1. [LoopUnroller, LoopPeel]
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>paulsson@linux.vnet.ibm.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=18603" name="attach_18603" title="reduced testcase">attachment 18603</a> <a href="attachment.cgi?id=18603&action=edit" title="reduced testcase">[details]</a></span>
reduced testcase

bin/opt -S -mtriple=s390x-unknown-linux -mcpu=z13 -O3 -o out.opt.ll
unroller_assert.ll

include/llvm/IR/Instructions.h:2764: llvm::Value*
llvm::PHINode::getIncomingValueForBlock(const llvm::BasicBlock*) const:
Assertion `Idx >= 0 && "Invalid basic block argument!"' failed.

  Value *getIncomingValueForBlock(const BasicBlock *BB) const {
    int Idx = getBasicBlockIndex(BB);
    assert(Idx >= 0 && "Invalid basic block argument!");
    return getIncomingValue(Idx);
  }

p Idx
$184 = -1

[UP]
LoopUnroll.cpp:

      PN->replaceAllUsesWith(PN->getIncomingValueForBlock(Preheader));

p Preheader->dump()

entry:
  %l_869 = alloca [8 x i32], align 4
  br label %for.cond1128.preheader.peel.begin

p L->getLoopPreheader()->dump()

entry.peel.newph:                                 ; preds =
%for.cond1128.preheader.peel.next9
  br label %for.cond1128.preheader

Why is Preheader != L->getLoopPreheader() ?
Why is the index for the entry block -1?
Related to peeling?</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>