<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 - Assertion failure /home/mkazantsev/work/llvm/include/llvm/IR/Instructions.h:3123: llvm::Value* llvm::PHINode::getIncomingValueForBlock(const llvm::BasicBlock*) const: Assertion `Idx >= 0 && "Invalid basic block argument!"' failed. Stack dump:"
   href="https://bugs.llvm.org/show_bug.cgi?id=39160">39160</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Assertion failure /home/mkazantsev/work/llvm/include/llvm/IR/Instructions.h:3123: llvm::Value* llvm::PHINode::getIncomingValueForBlock(const llvm::BasicBlock*) const: Assertion `Idx >= 0 && "Invalid basic block argument!"' failed. Stack dump:
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

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

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

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>max.kazantsev@azul.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=20953" name="attach_20953" title="Reproducer IR">attachment 20953</a> <a href="attachment.cgi?id=20953&action=edit" title="Reproducer IR">[details]</a></span>
Reproducer IR

Download the IR in attachment and run

opt -loop-vectorizer -S ./ir.ll

It fails an assertion in SCEV like this:

opt: /home/mkazantsev/work/llvm/include/llvm/IR/Instructions.h:3123:
llvm::Value* llvm::PHINode::getIncomingValueForBlock(const llvm::BasicBlock*)
const: Assertion `Idx >= 0 && "Invalid basic block argument!"' failed.
Stack dump:
0.      Program arguments: /home/mkazantsev/work/llvm/build/buildRA/bin/opt
-loop-vectorize -S ./ir.ll
1.      Running pass 'Function Pass Manager' on module './ir.ll'.
2.      Running pass 'Loop Vectorization' on function '@barney'
#0 0x00007f663bb828aa llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/home/mkazantsev/work/llvm/lib/Support/Unix/Signals.inc:494:0
#1 0x00007f663bb80e6a llvm::sys::RunSignalHandlers()
/home/mkazantsev/work/llvm/lib/Support/Signals.cpp:67:0
#2 0x00007f663bb80f9d SignalHandler(int)
/home/mkazantsev/work/llvm/lib/Support/Unix/Signals.inc:353:0
#3 0x00007f663ae9b390 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#4 0x00007f663a254428 gsignal
/build/glibc-Cl5G7W/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54:0
#5 0x00007f663a25602a abort /build/glibc-Cl5G7W/glibc-2.23/stdlib/abort.c:91:0
#6 0x00007f663a24cbd7 __assert_fail_base
/build/glibc-Cl5G7W/glibc-2.23/assert/assert.c:92:0
#7 0x00007f663a24cc82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)
#8 0x00007f663bd3efd7
(/home/mkazantsev/work/llvm/build/buildRA/bin/../lib/libLLVM-8svn.so+0xc97fd7)
#9 0x00007f663cabf807
llvm::ScalarEvolution::isImpliedViaMerge(llvm::CmpInst::Predicate, llvm::SCEV
const*, llvm::SCEV const*, llvm::SCEV const*, llvm::SCEV const*, unsigned int)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:10006:0
#10 0x00007f663cabfe42
llvm::ScalarEvolution::isImpliedViaOperations(llvm::CmpInst::Predicate,
llvm::SCEV const*, llvm::SCEV const*, llvm::SCEV const*, llvm::SCEV const*,
unsigned int)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:10278:0
#11 0x00007f663cac0241
llvm::ScalarEvolution::isImpliedViaMerge(llvm::CmpInst::Predicate, llvm::SCEV
const*, llvm::SCEV const*, llvm::SCEV const*, llvm::SCEV const*, unsigned
int)::'lambda0'(llvm::SCEV const*, llvm::SCEV const*)::operator()(llvm::SCEV
const*, llvm::SCEV const*) const
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:9965:0
#12 0x00007f663cabf820
llvm::ScalarEvolution::isImpliedViaMerge(llvm::CmpInst::Predicate, llvm::SCEV
const*, llvm::SCEV const*, llvm::SCEV const*, llvm::SCEV const*, unsigned int)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:10007:0
#13 0x00007f663cabfe42
llvm::ScalarEvolution::isImpliedViaOperations(llvm::CmpInst::Predicate,
llvm::SCEV const*, llvm::SCEV const*, llvm::SCEV const*, llvm::SCEV const*,
unsigned int)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:10278:0
#14 0x00007f663cac02cd
llvm::ScalarEvolution::isImpliedCondOperandsHelper(llvm::CmpInst::Predicate,
llvm::SCEV const*, llvm::SCEV const*, llvm::SCEV const*, llvm::SCEV const*)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:10336:0


The failure is gone is the following patch is reverted:

commit 4090ce2a163b88ef04a8f1a72e421f154c98a1eb
Author: Justin Lebar <<a href="mailto:jlebar@google.com">jlebar@google.com</a>>
Date:   Thu Jun 14 17:13:35 2018 +0000

    [SCEV] Simplify trunc-of-add/mul to add/mul-of-trunc under more
circumstances.

    Summary:
    Previously we would do this simplification only if it did not introduce
    any new truncs (excepting new truncs which replace other cast ops).

    This change weakens this condition: If the number of truncs stays the
    same, but we're able to transform trunc(X + Y) to X + trunc(Y), that's
    still simpler, and it may open up additional transformations.

    While we're here, also clean up some duplicated code.

    Reviewers: sanjoy

    Subscribers: hiraditya, llvm-commits

    Differential Revision: <a href="https://reviews.llvm.org/D48160">https://reviews.llvm.org/D48160</a>

    git-svn-id: <a href="https://llvm.org/svn/llvm-project/llvm/trunk@334736">https://llvm.org/svn/llvm-project/llvm/trunk@334736</a>
91177308-0d34-0410-b5e6-96231b3b80d8



Note that after looking into the patch's code I don't see any obvious problem
there, so it might be not causing the bug but exposing something that's already
there.</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>