<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 - nary-reassociate crashes: Assertion `S1->getType() == S2->getType() && "Cannot create binary operator with two operands of differing type!"' failed."
   href="https://bugs.llvm.org/show_bug.cgi?id=43581">43581</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>nary-reassociate crashes: Assertion `S1->getType() == S2->getType() && "Cannot create binary operator with two operands of differing 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>cszide@163.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=22635" name="attach_22635" title="cat.bc">attachment 22635</a> <a href="attachment.cgi?id=22635&action=edit" title="cat.bc">[details]</a></span>
cat.bc

$clang -v
clang version 10.0.0 (trunk 373844)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.4.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64

$opt -instcombine -partial-inliner -globalopt -mem2reg -jump-threading
-callsite-splitting -inline -licm -nary-reassociate cat.bc 
WARNING: You're attempting to print out a bitcode file.
This is inadvisable as it may cause display problems. If
you REALLY want to taste LLVM bitcode first-hand, you
can force output with the `-f' option.

opt:
/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/lib/IR/Instructions.cpp:2344:
static llvm::BinaryOperator*
llvm::BinaryOperator::Create(llvm::Instruction::BinaryOps, llvm::Value*,
llvm::Value*, const llvm::Twine&, llvm::Instruction*): Assertion `S1->getType()
== S2->getType() && "Cannot create binary operator with two operands of
differing type!"' failed.
Stack dump:
0.      Program arguments:
/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt -instcombine
-partial-inliner -globalopt -mem2reg -jump-threading -callsite-splitting
-inline -licm -nary-reassociate cat.bc 
1.      Running pass 'CallGraph Pass Manager' on module 'cat.bc'.
2.      Running pass 'Nary reassociation' on function '@main'
 #0 0x00005579be2b7baa llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x2791baa)
 #1 0x00005579be2b5884 llvm::sys::RunSignalHandlers()
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x278f884)
 #2 0x00005579be2b59c2 SignalHandler(int)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x278f9c2)
 #3 0x00007f71ebc0c890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
 #4 0x00007f71ea8bee97 raise
/build/glibc-OTsEL5/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #5 0x00007f71ea8c0801 abort /build/glibc-OTsEL5/glibc-2.27/stdlib/abort.c:81:0
 #6 0x00007f71ea8b039a __assert_fail_base
/build/glibc-OTsEL5/glibc-2.27/assert/assert.c:89:0
 #7 0x00007f71ea8b0412 (/lib/x86_64-linux-gnu/libc.so.6+0x30412)
 #8 0x00005579bdbc9a9c
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x20a3a9c)
 #9 0x00005579be125812
llvm::NaryReassociatePass::tryReassociatedBinaryOp(llvm::SCEV const*,
llvm::Value*, llvm::BinaryOperator*)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x25ff812)
#10 0x00005579be12596c
llvm::NaryReassociatePass::tryReassociateBinaryOp(llvm::Value*, llvm::Value*,
llvm::BinaryOperator*)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x25ff96c)
#11 0x00005579be1259be
llvm::NaryReassociatePass::tryReassociateBinaryOp(llvm::BinaryOperator*)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x25ff9be)
#12 0x00005579be127e12
llvm::NaryReassociatePass::doOneIteration(llvm::Function&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x2601e12)
#13 0x00005579be129ae6 llvm::NaryReassociatePass::runImpl(llvm::Function&,
llvm::AssumptionCache*, llvm::DominatorTree*, llvm::ScalarEvolution*,
llvm::TargetLibraryInfo*, llvm::TargetTransformInfo*)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x2603ae6)
#14 0x00005579be129daf (anonymous
namespace)::NaryReassociateLegacyPass::runOnFunction(llvm::Function&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x2603daf)
#15 0x00005579bdbf1a49 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x20cba49)
#16 0x00005579bd4b53da (anonymous
namespace)::CGPassManager::runOnModule(llvm::Module&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x198f3da)
#17 0x00005579bdbf0ca1 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x20caca1)
#18 0x00005579bc3bc01f main
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x89601f)
#19 0x00007f71ea8a1b97 __libc_start_main
/build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0
#20 0x00005579bc43421a _start
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x90e21a)
Aborted (core dumped)

The optimization sequence can be reduced to "-nary-reassociate" using bugpoint.

$opt bugpoint-reduced-simplified.bc -nary-reassociate
WARNING: You're attempting to print out a bitcode file.
This is inadvisable as it may cause display problems. If
you REALLY want to taste LLVM bitcode first-hand, you
can force output with the `-f' option.

opt:
/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/lib/IR/Instructions.cpp:2344:
static llvm::BinaryOperator*
llvm::BinaryOperator::Create(llvm::Instruction::BinaryOps, llvm::Value*,
llvm::Value*, const llvm::Twine&, llvm::Instruction*): Assertion `S1->getType()
== S2->getType() && "Cannot create binary operator with two operands of
differing type!"' failed.
Stack dump:
0.      Program arguments:
/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt
bugpoint-reduced-simplified.bc -nary-reassociate 
1.      Running pass 'Function Pass Manager' on module
'bugpoint-reduced-simplified.bc'.
2.      Running pass 'Nary reassociation' on function '@main'
 #0 0x00005621cdb93baa llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x2791baa)
 #1 0x00005621cdb91884 llvm::sys::RunSignalHandlers()
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x278f884)
 #2 0x00005621cdb919c2 SignalHandler(int)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x278f9c2)
 #3 0x00007f2a01068890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
 #4 0x00007f29ffd1ae97 raise
/build/glibc-OTsEL5/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #5 0x00007f29ffd1c801 abort /build/glibc-OTsEL5/glibc-2.27/stdlib/abort.c:81:0
 #6 0x00007f29ffd0c39a __assert_fail_base
/build/glibc-OTsEL5/glibc-2.27/assert/assert.c:89:0
 #7 0x00007f29ffd0c412 (/lib/x86_64-linux-gnu/libc.so.6+0x30412)
 #8 0x00005621cd4a5a9c
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x20a3a9c)
 #9 0x00005621cda01812
llvm::NaryReassociatePass::tryReassociatedBinaryOp(llvm::SCEV const*,
llvm::Value*, llvm::BinaryOperator*)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x25ff812)
#10 0x00005621cda01919
llvm::NaryReassociatePass::tryReassociateBinaryOp(llvm::Value*, llvm::Value*,
llvm::BinaryOperator*)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x25ff919)
#11 0x00005621cda019be
llvm::NaryReassociatePass::tryReassociateBinaryOp(llvm::BinaryOperator*)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x25ff9be)
#12 0x00005621cda03e12
llvm::NaryReassociatePass::doOneIteration(llvm::Function&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x2601e12)
#13 0x00005621cda05ae6 llvm::NaryReassociatePass::runImpl(llvm::Function&,
llvm::AssumptionCache*, llvm::DominatorTree*, llvm::ScalarEvolution*,
llvm::TargetLibraryInfo*, llvm::TargetTransformInfo*)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x2603ae6)
#14 0x00005621cda05daf (anonymous
namespace)::NaryReassociateLegacyPass::runOnFunction(llvm::Function&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x2603daf)
#15 0x00005621cd4cda49 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x20cba49)
#16 0x00005621cd4cdb19 llvm::FPPassManager::runOnModule(llvm::Module&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x20cbb19)
#17 0x00005621cd4ccca1 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x20caca1)
#18 0x00005621cbc9801f main
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x89601f)
#19 0x00007f29ffcfdb97 __libc_start_main
/build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0
#20 0x00005621cbd1021a _start
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x90e21a)
Aborted (core dumped)</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>