<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/55217>55217</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang][InstCombine] Instruction Combining seems stuck in an infinite loop after 100 iterations.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          dbakunevich
      </td>
    </tr>
</table>

<pre>
    This bug was found by Azul FuzzGen fuzzer for CPP.

Godbolt link: https://godbolt.org/z/c78bn3Tx9

Run clang -O3 (x86_64) on the test
[crash_2.cpp.txt](https://github.com/llvm/llvm-project/files/8599473/crash_2.cpp.txt)

Passed on clang 14.0, so appears to be fresh.

Failure looks like:
```
fatal error: error in backend: Instruction Combining seems stuck in an infinite loop after 100 iterations.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O3 <source>
1.      <eof> parser at end of file
2.      Optimizer
 #0 0x000055d7e88e3e2f PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x000055d7e88e1b94 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ae1b94)
 #2 0x000055d7e881793f llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a1793f)
 #3 0x000055d7e88da28e llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ada28e)
 #4 0x000055d7e62325f3 LLVMErrorHandler(void*, char const*, bool) cc1_main.cpp:0:0
 #5 0x000055d7e882029f llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a2029f)
 #6 0x000055d7e83047d2 combineInstructionsOverFunction(llvm::Function&, llvm::InstructionWorklist&, llvm::AAResults*, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::ProfileSummaryInfo*, unsigned int, llvm::LoopInfo*) InstructionCombining.cpp:0:0
 #7 0x000055d7e8304e42 llvm::InstCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3504e42)
 #8 0x000055d7e99e4671 llvm::detail::PassModel<llvm::Function, llvm::InstCombinePass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4be4671)
 #9 0x000055d7e80a4dec llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x32a4dec)
#10 0x000055d7e64ff681 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x16ff681)
#11 0x000055d7e80a480a llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x32a480a)
#12 0x000055d7e64fffe1 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x16fffe1)
#13 0x000055d7e80a2fc4 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x32a2fc4)
#14 0x000055d7e8c2a6a7 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile> >&) (.constprop.777) BackendUtil.cpp:0:0
#15 0x000055d7e8c2d58a 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> >) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e2d58a)
#16 0x000055d7e9965ecb clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4b65ecb)
#17 0x000055d7ea9248f9 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5b248f9)
#18 0x000055d7e9964a00 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4b64a00)
#19 0x000055d7e92e5e29 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44e5e29)
#20 0x000055d7e927f3ca clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x447f3ca)
#21 0x000055d7e93b3c83 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45b3c83)
#22 0x000055d7e6233981 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x1433981)
#23 0x000055d7e622f819 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#24 0x000055d7e9115a25 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#25 0x000055d7e8817783 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a17783)
#26 0x000055d7e9117db6 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4317db6)
#27 0x000055d7e90e83da clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42e83da)
#28 0x000055d7e90e906f clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42e906f)
#29 0x000055d7e90f366a clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42f366a)
#30 0x000055d7e6177b7c main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x1377b7c)
#31 0x00007f5b2d65c0b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x240b3)
#32 0x000055d7e622f38a _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x142f38a)
clang-15: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Compiler returned: 70
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWltT4zgW_jXhRZWU75cHHtIBunuLLijCzD6mZFlOtNiWV5Ih9K-fI9lJLBO66alka3ZnqZDYun7nOxcdyc54_nr5uGESZe0avWCJCt7WOcpe0fx7W6Kb9vv3z7RGBfxSAZUCLe7vZxPnauLMu-_PPM94qVDJ6qeJP0cbpRoJFxPvBj7rrnbGxRruvsM_iZOs9h-36XCQh7ZGpMT1Gk3vfDTxkm0SraJg4qWI10htKFJUqr5H-IkILDcrb0aaZqa2ahJeQZfRxExt2mxGeAU3Zfm8-5k2gv-LEgW3BSuphN8kTNMg9jW20bieBfIeS0lzDaiD6gYzZ-ItkOQINw3FQiLFUUZRIajcWCTdYFa2gqKS8ycJVD1RDbRrEDn9x9wWWOESUSG40GyaC8RqlGHyROtcl32tpRItUQyQLHiVsZoBGklpJZFULXnS7XEN3wVUKTNrg3ChQIOu4yAoElj3lj3G-9vr-fIayTarmELY2IKgDRdKC_TLvDIpW0MsgMgBBSnbnBolGn6NKEpgQjV5DUwkOKGGWslb0RXrnkA3JwwrqBBgH5II1qge8lLBIChvq2ZPpANV6b3ga4ErhMW6rWitNHCwpxveaGSAugGliyndNiUXVOgyrcupVq0wnEyBW7Bk7wZ43VVPvE_wQdN1_oJFMQ3gCk25HhcUr0dvVdOqmUTTJZpO14RMFecl2WAYwr_64fS6saxxIzdcoWlBOFRMc4bXNZeKERiyqPnUEGcXaz_xFz1j_nXHgas5gGLKCyhDDdgkKB0rBKaDeIG0yXctPd3yrlGsYuDZXRkI5DvI2TrwF4Z5TJOE-tQr0L1gtTKUP2q9Ldm6xuUX0FGpZUieOcsn3lx7a1cltQcB847534_tjsZ2szRAxoZAh_5cvsruYlFSXLfNXd2NBjO0tYRLMISSa22kOkScSKvwcbY-NmD2Dq_RejZaN079YoB2oVXyQ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