<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 - ICE: "Cannot replace uses of with self" in llvm::SelectionDAG::ReplaceAllUsesWith"
   href="https://bugs.llvm.org/show_bug.cgi?id=32894">32894</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>ICE: "Cannot replace uses of with self" in llvm::SelectionDAG::ReplaceAllUsesWith
          </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>All
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>GlobalISel
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>babokin@gmail.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=18392" name="attach_18392" title="reproducers">attachment 18392</a> <a href="attachment.cgi?id=18392&action=edit" title="reproducers">[details]</a></span>
reproducers

LLVM trunk (301887), x86_64 build.

I've attached reduced (small.cpp) and original (big.cpp) test cases.

<span class="quote">> clang++ -std=c++11 -w -O2 -c small.cpp</span >
clang-5.0:
/home/dybaboki/llvm/llvm-trunk-20170501/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:6719:
void llvm::SelectionDAG::ReplaceAllUsesWith(llvm::SDValue, llvm::SDValue):
Assertion `From != To.getNode() && "Cannot replace uses of with self"' failed.
#0 0x00000000012a446f llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/dybaboki/llvm/bin-trunk-20170501/bin/clang-5.0+0x12a446f)
#1 0x00000000012a4776 SignalHandler(int)
(/home/dybaboki/llvm/bin-trunk-20170501/bin/clang-5.0+0x12a4776)
#2 0x00007f0e91e31370 __restore_rt (/lib64/libpthread.so.0+0xf370)
#3 0x00007f0e909ae1d7 __GI_raise (/lib64/libc.so.6+0x351d7)
#4 0x00007f0e909af8c8 __GI_abort (/lib64/libc.so.6+0x368c8)
#5 0x00007f0e909a7146 __assert_fail_base (/lib64/libc.so.6+0x2e146)
#6 0x00007f0e909a71f2 (/lib64/libc.so.6+0x2e1f2)
#7 0x00000000019a9e91 llvm::SelectionDAG::ReplaceAllUsesWith(llvm::SDValue,
llvm::SDValue) (/home/dybaboki/llvm/bin-trunk-20170501/bin/clang-5.0+0x19a9e91)
#8 0x00000000018963e2 (anonymous
namespace)::DAGCombiner::CombineTo(llvm::SDNode*, llvm::SDValue const*,
unsigned int, bool)
(/home/dybaboki/llvm/bin-trunk-20170501/bin/clang-5.0+0x18963e2)
#9 0x00000000018eed72 (anonymous
namespace)::DAGCombiner::ExtendSetCCUses(llvm::SmallVectorImpl<llvm::SDNode*>
const&, llvm::SDValue, llvm::SDValue, llvm::SDLoc const&, llvm::ISD::NodeType)
(/home/dybaboki/llvm/bin-trunk-20170501/bin/clang-5.0+0x18eed72)
#10 0x00000000018ce9e6 (anonymous
namespace)::DAGCombiner::visitZERO_EXTEND(llvm::SDNode*)
(/home/dybaboki/llvm/bin-trunk-20170501/bin/clang-5.0+0x18ce9e6)
#11 0x000000000189ec9a (anonymous namespace)::DAGCombiner::visit(llvm::SDNode*)
(/home/dybaboki/llvm/bin-trunk-20170501/bin/clang-5.0+0x189ec9a)
#12 0x00000000018986ac (anonymous
namespace)::DAGCombiner::combine(llvm::SDNode*)
(/home/dybaboki/llvm/bin-trunk-20170501/bin/clang-5.0+0x18986ac)
#13 0x00000000018973f8 llvm::SelectionDAG::Combine(llvm::CombineLevel,
llvm::AAResults&, llvm::CodeGenOpt::Level)
(/home/dybaboki/llvm/bin-trunk-20170501/bin/clang-5.0+0x18973f8)
#14 0x00000000019bb1c5 llvm::SelectionDAGISel::CodeGenAndEmitDAG()
(/home/dybaboki/llvm/bin-trunk-20170501/bin/clang-5.0+0x19bb1c5)
#15 0x00000000019b9a78
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&)
(/home/dybaboki/llvm/bin-trunk-20170501/bin/clang-5.0+0x19b9a78)
#16 0x00000000019b6a46
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&)
(/home/dybaboki/llvm/bin-trunk-20170501/bin/clang-5.0+0x19b6a46)</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>