<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 - [InstCombine] Blows up when attempting to foldICmpWithCastAndCast of a vector icmp"
   href="https://bugs.llvm.org/show_bug.cgi?id=36583">36583</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[InstCombine] Blows up when attempting to foldICmpWithCastAndCast of a vector icmp
          </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>All
          </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>dneilson@azul.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Source IR:
target datalayout = "e"
target triple = "x86_64-unknown-linux-gnu"

define <2 x i1> @foo(<2 x i8*>)  {
entry:
  %as.int = ptrtoint <2 x i8*> %0 to <2 x i64>
  %shift = lshr <2 x i64> %as.int, zeroinitializer
  %res = icmp eq <2 x i64> %shift, zeroinitializer
  ret <2 x i1> %res
}

---

Run with: opt -instcombine -S test.ll

Result:
Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"),
function cast, file
/Users/dneilson/Development/LLVM-dev/llvm/include/llvm/Support/Casting.h, line
255.
0  opt                      0x0000000103c1efec
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 60
1  opt                      0x0000000103c1f5e9
PrintStackTraceSignalHandler(void*) + 25
2  opt                      0x0000000103c1b0e9 llvm::sys::RunSignalHandlers() +
425
3  opt                      0x0000000103c1fa02 SignalHandler(int) + 354
4  libsystem_platform.dylib 0x00007fff64326f5a _sigtramp + 26
5  libsystem_platform.dylib 0x0000000000019858 _sigtramp + 2614044952
6  libsystem_c.dylib        0x00007fff64151312 abort + 127
7  libsystem_c.dylib        0x00007fff64119368 basename_r + 0
8  opt                      0x0000000100934057
llvm::cast_retty<llvm::IntegerType, llvm::Type const*>::ret_type
llvm::cast<llvm::IntegerType, llvm::Type const>(llvm::Type const*) + 103
9  opt                      0x0000000100933945 llvm::Type::getIntegerBitWidth()
const + 21
10 opt                      0x00000001033fd41b
llvm::InstCombiner::foldICmpWithCastAndCast(llvm::ICmpInst&) + 155
11 opt                      0x00000001034020a3
llvm::InstCombiner::visitICmpInst(llvm::ICmpInst&) + 3363
12 opt                      0x000000010338d138
llvm::InstVisitor<llvm::InstCombiner,
llvm::Instruction*>::visitICmp(llvm::ICmpInst&) + 40
13 opt                      0x000000010337eb2c
llvm::InstVisitor<llvm::InstCombiner,
llvm::Instruction*>::visit(llvm::Instruction&) + 1516
14 opt                      0x000000010337deb9 llvm::InstCombiner::run() + 2569
15 opt                      0x000000010337f44f
combineInstructionsOverFunction(llvm::Function&, llvm::InstCombineWorklist&,
llvm::AAResults*, llvm::AssumptionCache&, llvm::TargetLibraryInfo&,
llvm::DominatorTree&, llvm::OptimizationRemarkEmitter&, bool, llvm::LoopInfo*)
+ 1007
16 opt                      0x000000010337f6d6
llvm::InstructionCombiningPass::runOnFunction(llvm::Function&) + 342
17 opt                      0x000000010303bddf
llvm::FPPassManager::runOnFunction(llvm::Function&) + 399
18 opt                      0x000000010303c2e5
llvm::FPPassManager::runOnModule(llvm::Module&) + 117
19 opt                      0x000000010303d0b4 (anonymous
namespace)::MPPassManager::runOnModule(llvm::Module&) + 2196
20 opt                      0x000000010303c5a6
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 342
21 opt                      0x000000010303dde1
llvm::legacy::PassManager::run(llvm::Module&) + 33
22 opt                      0x000000010097dde4 main + 27636
23 libdyld.dylib            0x00007fff640a5115 start + 1

---

Expected:
define <2 x i1> @foo(<2 x i8*>)  {
entry:
  %res = icmp eq <2 x i8*> %0, zeroinitializer
  ret <2 x i1> %res
}</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>