<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 - opt -irce crashing with "Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed""
   href="https://bugs.llvm.org/show_bug.cgi?id=41194">41194</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>opt -irce crashing with "Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed"
          </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>mikael.holmen@ericsson.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=21652" name="attach_21652" title="reproducer">attachment 21652</a> <a href="attachment.cgi?id=21652&action=edit" title="reproducer">[details]</a></span>
reproducer

Reproduce with:
 opt -irce bbi-26117.ll -S -o -

which yields:

opt: ../include/llvm/Support/Casting.h:254: typename cast_retty<X, Y
*>::ret_type llvm::cast(Y *) [X = llvm::IntegerType, Y = llvm::Type]: Assertion
`isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
Stack dump:
0.      Program arguments: build-all/bin/opt -irce bbi-26117.ll -S -o - 
1.      Running pass 'Function Pass Manager' on module 'bbi-26117.ll'.
2.      Running pass 'Loop Pass Manager' on function '@test_read_imm_2'
3.      Running pass 'Inductive range check elimination' on basic block
'%cont48'
 #0 0x000000000229a344 PrintStackTraceSignalHandler(void*)
(build-all/bin/opt+0x229a344)
 #1 0x0000000002298350 llvm::sys::RunSignalHandlers()
(build-all/bin/opt+0x2298350)
 #2 0x000000000229a6a8 SignalHandler(int) (build-all/bin/opt+0x229a6a8)
 #3 0x00007f6fcc262330 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
 #4 0x00007f6fcae51c37 gsignal
/build/eglibc-ripdx6/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
 #5 0x00007f6fcae55028 abort
/build/eglibc-ripdx6/eglibc-2.19/stdlib/abort.c:91:0
 #6 0x00007f6fcae4abf6 __assert_fail_base
/build/eglibc-ripdx6/eglibc-2.19/assert/assert.c:92:0
 #7 0x00007f6fcae4aca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)
 #8 0x0000000002063ca5 (anonymous
namespace)::InductiveRangeCheckElimination::run(llvm::Loop*,
llvm::function_ref<void (llvm::Loop*, bool)>) (build-all/bin/opt+0x2063ca5)
 #9 0x0000000002066341 (anonymous
namespace)::IRCELegacyPass::runOnLoop(llvm::Loop*, llvm::LPPassManager&)
(build-all/bin/opt+0x2066341)
#10 0x00000000016fa4dc llvm::LPPassManager::runOnFunction(llvm::Function&)
(build-all/bin/opt+0x16fa4dc)
#11 0x0000000001ca0d4d llvm::FPPassManager::runOnFunction(llvm::Function&)
(build-all/bin/opt+0x1ca0d4d)
#12 0x0000000001ca1008 llvm::FPPassManager::runOnModule(llvm::Module&)
(build-all/bin/opt+0x1ca1008)
#13 0x0000000001ca146a llvm::legacy::PassManagerImpl::run(llvm::Module&)
(build-all/bin/opt+0x1ca146a)
#14 0x00000000007a073b main (build-all/bin/opt+0x7a073b)
#15 0x00007f6fcae3cf45 __libc_start_main
/build/eglibc-ripdx6/eglibc-2.19/csu/libc-start.c:321:0
#16 0x000000000078618d _start (build-all/bin/opt+0x78618d)
Abort

Starts crashing with r351926:

    [IRCE] Support narrow latch condition for wide range checks

    This patch relaxes restrictions on types of latch condition and range
check.
    In current implementation, they should match. This patch allows to handle
    wide range checks against narrow condition. The motivating example is the
    following:

      int N = ...
      for (long i = 0; (int) i < N; i++) {
        if (i >= length) deopt;
      }

    In this patch, the option that enables this support is turned off by
    default. We'll wait until it is switched to true.

    Differential Revision: <a href="https://reviews.llvm.org/D56837">https://reviews.llvm.org/D56837</a>
    Reviewed By: reames


    git-svn-id: <a href="https://llvm.org/svn/llvm-project/llvm/trunk@351926">https://llvm.org/svn/llvm-project/llvm/trunk@351926</a>
91177308-0d34-0410-b5e6-96231b3b80d8</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>