<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 `(!From->hasAnyUseOfValue(i) || From->getValueType(i) == To->getValueType(i)) && "Cannot use this version of ReplaceAllUsesWith!""
   href="https://bugs.llvm.org/show_bug.cgi?id=52504">52504</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Assertion `(!From->hasAnyUseOfValue(i) || From->getValueType(i) == To->getValueType(i)) && "Cannot use this version of 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>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>Backend: X86
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>Vsevolod.Livinskij@frtk.ru
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, pengfei.wang@intel.com, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>IR Reproducer:

@b = external global [0 x i16]
@c = external global [0 x i8]

define void @_Z1hv([0 x i16]* %b, i64 %0, i16* %1, i16 %2, <8 x i16> %3, <8 x
i16> %4, <8 x i16> %5, [0 x i8]* %c, i8* %6, i8* %7) {
vector.ph:
  br label %vector.body

vector.body:                                      ; preds = %vector.body,
%vector.ph
  %8 = or i64 0, 0
  %9 = getelementptr inbounds [0 x i16], [0 x i16]* %b, i64 0, i64 %0
  %10 = load i16, i16* %1, align 2
  %11 = insertelement <8 x i16> zeroinitializer, i16 %2, i32 1
  %12 = insertelement <8 x i16> %3, i16 0, i32 0
  %13 = insertelement <8 x i16> %3, i16 0, i32 0
  %14 = sext <8 x i16> %3 to <8 x i64>
  %15 = icmp sgt <8 x i64> %14, <i64 -1, i64 -1, i64 -1, i64 -1, i64 -1, i64
-1, i64 -1, i64 -1>
  %16 = select <8 x i1> %15, <8 x i64> %14, <8 x i64> <i64 -1, i64 -1, i64 -1,
i64 -1, i64 -1, i64 -1, i64 -1, i64 -1>
  %17 = trunc <8 x i64> %16 to <8 x i32>
  %18 = icmp ne <8 x i32> %17, zeroinitializer
  %19 = getelementptr inbounds [0 x i8], [0 x i8]* %c, i64 0, i64 %0
  %20 = getelementptr inbounds [0 x i8], [0 x i8]* %c, i64 0, i64 undef
  %21 = zext <8 x i1> %18 to <8 x i8>
  %22 = extractelement <8 x i8> %21, i32 1
  store i8 %22, i8* %6, align 1
  %23 = extractelement <8 x i8> %21, i32 0
  store i8 %23, i8* %7, align 1
  br label %vector.body
}

<span class="quote">>$ clang++ -c reduced.ll</span >
clang++:
/testing/llvm/llvm_src_main/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:9444:
void llvm::SelectionDAG::ReplaceAllUsesWith(llvm::SDNode*, llvm::SDNode*):
Assertion `(!From->hasAnyUseOfValue(i) || From->getValueType(i) ==
To->getValueType(i)) && "Cannot use this version of ReplaceAllUsesWith!"'
failed.
PLEASE submit a bug report to <a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: clang++ -c reduced.ll
1.      Code generation
2.      Running pass 'Function Pass Manager' on module 'reduced.ll'.
3.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@_Z1hv'
 #0 0x0000561d20998344 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x0000561d20996154 llvm::sys::CleanupOnSignal(unsigned long)
(/testing/llvm/bin_main/bin/clang-14+0x224b154)
 #2 0x0000561d208de158 CrashRecoverySignalHandler(int)
CrashRecoveryContext.cpp:0:0
 #3 0x00007fbfac0d23c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #4 0x00007fbfabb8218b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4618b)
 #5 0x00007fbfabb61859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x25859)
 #6 0x00007fbfabb61729 (/lib/x86_64-linux-gnu/libc.so.6+0x25729)
 #7 0x00007fbfabb72f36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
 #8 0x0000561d219e2f9f llvm::SelectionDAG::ReplaceAllUsesWith(llvm::SDNode*,
llvm::SDNode*) (/testing/llvm/bin_main/bin/clang-14+0x3297f9f)
 #9 0x0000561d2190aa89 llvm::SelectionDAG::Combine(llvm::CombineLevel,
llvm::AAResults*, llvm::CodeGenOpt::Level)
(/testing/llvm/bin_main/bin/clang-14+0x31bfa89)
#10 0x0000561d21a1a739 llvm::SelectionDAGISel::CodeGenAndEmitDAG()
(/testing/llvm/bin_main/bin/clang-14+0x32cf739)
#11 0x0000561d21a1df7b
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&)
(/testing/llvm/bin_main/bin/clang-14+0x32d2f7b)
#12 0x0000561d21a20191
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0)
SelectionDAGISel.cpp:0:0
#13 0x0000561d1f54c7c0 (anonymous
namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&)
X86ISelDAGToDAG.cpp:0:0
#14 0x0000561d1fbe0e38
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
(/testing/llvm/bin_main/bin/clang-14+0x1495e38)
#15 0x0000561d201462e5 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/testing/llvm/bin_main/bin/clang-14+0x19fb2e5)
#16 0x0000561d20146529 llvm::FPPassManager::runOnModule(llvm::Module&)
(/testing/llvm/bin_main/bin/clang-14+0x19fb529)
#17 0x0000561d20147612 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/testing/llvm/bin_main/bin/clang-14+0x19fc612)
#18 0x0000561d20ce62c3 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef,
llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(/testing/llvm/bin_main/bin/clang-14+0x259b2c3)
#19 0x0000561d21b5b453 clang::CodeGenAction::ExecuteAction()
(/testing/llvm/bin_main/bin/clang-14+0x3410453)
#20 0x0000561d21405b09 clang::FrontendAction::Execute()
(/testing/llvm/bin_main/bin/clang-14+0x2cbab09)
#21 0x0000561d21394b8e
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/testing/llvm/bin_main/bin/clang-14+0x2c49b8e)
#22 0x0000561d214e6e53
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/testing/llvm/bin_main/bin/clang-14+0x2d9be53)
#23 0x0000561d1f44da17 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/testing/llvm/bin_main/bin/clang-14+0xd02a17)
#24 0x0000561d1f44a068 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
driver.cpp:0:0
#25 0x0000561d2121f8d9 void llvm::function_ref<void
()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
<span class="quote">>, std::__cxx11::basic_string<char, std::char_traits<char>,</span >
std::allocator<char> >*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#26 0x0000561d208de2dc
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/testing/llvm/bin_main/bin/clang-14+0x21932dc)
#27 0x0000561d2121ffed
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
<span class="quote">>, std::__cxx11::basic_string<char, std::char_traits<char>,</span >
std::allocator<char> >*, bool*) const (.part.0) Job.cpp:0:0
#28 0x0000561d211f157b
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
(/testing/llvm/bin_main/bin/clang-14+0x2aa657b)
#29 0x0000561d211f2089
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const
(/testing/llvm/bin_main/bin/clang-14+0x2aa7089)
#30 0x0000561d211fb999
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/testing/llvm/bin_main/bin/clang-14+0x2ab0999)
#31 0x0000561d1f3c7b9a main (/testing/llvm/bin_main/bin/clang-14+0xc7cb9a)
#32 0x00007fbfabb630b3 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
#33 0x0000561d1f449bde _start (/testing/llvm/bin_main/bin/clang-14+0xcfebde)
clang-14: error: clang frontend command failed with exit code 134 (use -v to
see invocation)
clang version 14.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
51715fbd96c100e08ad5e0afe78eff474e4caa3f)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /testing/llvm/bin_main/bin
clang-14: note: diagnostic msg: Error generating preprocessed source(s) - no
preprocessable inputs.

C++ Reproducer:
char a;
extern short b[];
extern bool c[];
long d(long f, long g) { return f > g ? f : g; }
void h() {
#pragma clang loop vectorize(enable)
  for (int e = 0; e < a; e += 4)
    c[e] = int(d(-1LL, b[e]));
}

Error:
<span class="quote">>$ clang++ -O1 -c func.cpp</span >

clang version 14.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
51715fbd96c100e08ad5e0afe78eff474e4caa3f)</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>