<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><span class="vcard"><a class="email" href="mailto:Vsevolod.Livinskij@frtk.ru" title="Vsevolod Livinskiy <Vsevolod.Livinskij@frtk.ru>"> <span class="fn">Vsevolod Livinskiy</span></a>
</span> changed
          <a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED - Instruction does not dominate all uses! Crash with -O2 in llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10474: bool llvm::LoopVectorizePass::processLoop(llvm::Loop*): Assertion `!verifyFunction(*L->getHeader()->getParent(), &dbgs())' failed"
   href="https://bugs.llvm.org/show_bug.cgi?id=52024">bug 52024</a>
          <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>FIXED
           </td>
           <td>---
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>RESOLVED
           </td>
           <td>REOPENED
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED - Instruction does not dominate all uses! Crash with -O2 in llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10474: bool llvm::LoopVectorizePass::processLoop(llvm::Loop*): Assertion `!verifyFunction(*L->getHeader()->getParent(), &dbgs())' failed"
   href="https://bugs.llvm.org/show_bug.cgi?id=52024#c3">Comment # 3</a>
              on <a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED - Instruction does not dominate all uses! Crash with -O2 in llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10474: bool llvm::LoopVectorizePass::processLoop(llvm::Loop*): Assertion `!verifyFunction(*L->getHeader()->getParent(), &dbgs())' failed"
   href="https://bugs.llvm.org/show_bug.cgi?id=52024">bug 52024</a>
              from <span class="vcard"><a class="email" href="mailto:Vsevolod.Livinskij@frtk.ru" title="Vsevolod Livinskiy <Vsevolod.Livinskij@frtk.ru>"> <span class="fn">Vsevolod Livinskiy</span></a>
</span></b>
        <pre>Unfortunately, the error still exists in the trunk.

Link to the Compiler Explorer: <a href="https://godbolt.org/z/zbfTKEET8">https://godbolt.org/z/zbfTKEET8</a>

LLVM IR Reproducer:
define void @_Z1fv(i32* %0, i64 %1, i32* %a, i8* %b) local_unnamed_addr {
entry:
  br label %for.cond1.preheader.us

for.cond1.preheader.us:                           ; preds =
%for.cond1.for.cond.cleanup3_crit_edge.us, %entry
  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next,
%for.cond1.for.cond.cleanup3_crit_edge.us ]
  %2 = icmp eq i64 %indvars.iv, 0
  %arrayidx7.us = getelementptr inbounds i32, i32* %0, i64 %indvars.iv
  br i1 %2, label %for.cond1.for.cond.cleanup3_crit_edge.us, label
%for.body4.lr.ph.split.us21

for.body4.lr.ph.split.us21:                       ; preds =
%for.cond1.preheader.us
  %3 = load i32, i32* %arrayidx7.us, align 4
  br label %for.cond1.for.cond.cleanup3_crit_edge.us

for.cond1.for.cond.cleanup3_crit_edge.us:         ; preds =
%for.body4.lr.ph.split.us21, %for.cond1.preheader.us
  %storemerge = phi i32 [ %3, %for.body4.lr.ph.split.us21 ], [ 0,
%for.cond1.preheader.us ]
  store i32 %storemerge, i32* %a, align 4
  %indvars.iv.next = add nsw i64 %indvars.iv, %1
  %cmp.us = icmp slt i64 %indvars.iv.next, 0
  br i1 %cmp.us, label %for.cond1.preheader.us, label
%for.cond.cleanup.split.us.split, !llvm.loop !0

for.cond.cleanup.split.us.split:                  ; preds =
%for.cond1.for.cond.cleanup3_crit_edge.us
  %arrayidx7.us.lcssa = phi i32* [ %arrayidx7.us,
%for.cond1.for.cond.cleanup3_crit_edge.us ]
  %.us-phi.us.in.in = load i32, i32* %arrayidx7.us.lcssa, align 4
  %.us-phi.us.in = icmp ne i32 %.us-phi.us.in.in, 0
  %.us-phi.us = zext i1 %.us-phi.us.in to i8
  store i8 %.us-phi.us, i8* %b, align 1
  ret void
}

!0 = distinct !{!0, !1, !2}
!1 = !{!"llvm.loop.mustprogress"}
!2 = !{!"llvm.loop.vectorize.enable", i1 true}

Error:
<span class="quote">>$ clang++ -c -O1 reduced.ll</span >
Instruction does not dominate all uses!
  %42 = getelementptr inbounds i32, i32* %0, i64 %41
  %arrayidx7.us.lcssa = phi i32* [ %arrayidx7.us,
%for.cond1.for.cond.cleanup3_crit_edge.us ], [ %42, %middle.block ]
clang++:
/testing/llvm/llvm_src_main/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10570:
bool llvm::LoopVectorizePass::processLoop(llvm::Loop*): Assertion
`!verifyFunction(*L->getHeader()->getParent(), &dbgs())' 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 -O1 reduced.ll
1.      Optimizer
 #0 0x000055951e0cc115 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x000055951e0c9d64 llvm::sys::CleanupOnSignal(unsigned long)
(/testing/llvm/bin_main/bin/clang-14+0x222bd64)
 #2 0x000055951e015fc8 CrashRecoverySignalHandler(int)
CrashRecoveryContext.cpp:0:0
 #3 0x00007f24091d7520 (/lib/x86_64-linux-gnu/libc.so.6+0x46520)
 #4 0x00007f240922b808 pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9a808)
 #5 0x00007f24091d7476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x46476)
 #6 0x00007f24091bd7b7 abort (/lib/x86_64-linux-gnu/libc.so.6+0x2c7b7)
 #7 0x00007f24091bd6db (/lib/x86_64-linux-gnu/libc.so.6+0x2c6db)
 #8 0x00007f24091cee26 (/lib/x86_64-linux-gnu/libc.so.6+0x3de26)
 #9 0x000055951e3008d9 llvm::LoopVectorizePass::processLoop(llvm::Loop*)
(/testing/llvm/bin_main/bin/clang-14+0x24628d9)
#10 0x000055951e300aee llvm::LoopVectorizePass::runImpl(llvm::Function&,
llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&,
llvm::DominatorTree&, llvm::BlockFrequencyInfo&, llvm::TargetLibraryInfo*,
llvm::DemandedBits&, llvm::AAResults&, llvm::AssumptionCache&,
std::function<llvm::LoopAccessInfo const& (llvm::Loop&)>&,
llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*)
(/testing/llvm/bin_main/bin/clang-14+0x2462aee)
#11 0x000055951e301332 llvm::LoopVectorizePass::run(llvm::Function&,
llvm::AnalysisManager<llvm::Function>&)
(/testing/llvm/bin_main/bin/clang-14+0x2463332)
#12 0x000055951f665046 llvm::detail::PassModel<llvm::Function,
llvm::LoopVectorizePass, llvm::PreservedAnalyses,
llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&,
llvm::AnalysisManager<llvm::Function>&)
(/testing/llvm/bin_main/bin/clang-14+0x37c7046)
#13 0x000055951d89e9a0 llvm::PassManager<llvm::Function,
llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&,
llvm::AnalysisManager<llvm::Function>&)
(/testing/llvm/bin_main/bin/clang-14+0x1a009a0)
#14 0x000055951e3f78c6 llvm::detail::PassModel<llvm::Function,
llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >,
llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>
<span class="quote">>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&)</span >
(/testing/llvm/bin_main/bin/clang-14+0x25598c6)
#15 0x000055951d89d436 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/testing/llvm/bin_main/bin/clang-14+0x19ff436)
#16 0x000055951e3f86a6 llvm::detail::PassModel<llvm::Module,
llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses,
llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/testing/llvm/bin_main/bin/clang-14+0x255a6a6)
#17 0x000055951d89b3db llvm::PassManager<llvm::Module,
llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/testing/llvm/bin_main/bin/clang-14+0x19fd3db)
#18 0x000055951e40a6b8 (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>
<span class="quote">>&) (.constprop.0) BackendUtil.cpp:0:0</span >
#19 0x000055951e40e0ec 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+0x25700ec)
#20 0x000055951f272c38 clang::CodeGenAction::ExecuteAction()
(/testing/llvm/bin_main/bin/clang-14+0x33d4c38)
#21 0x000055951eb19389 clang::FrontendAction::Execute()
(/testing/llvm/bin_main/bin/clang-14+0x2c7b389)
#22 0x000055951eaa64de
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/testing/llvm/bin_main/bin/clang-14+0x2c084de)
#23 0x000055951ebe1ed8
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/testing/llvm/bin_main/bin/clang-14+0x2d43ed8)
#24 0x000055951cb3a181 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/testing/llvm/bin_main/bin/clang-14+0xc9c181)
#25 0x000055951cb35de4 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
driver.cpp:0:0
#26 0x000055951e930699 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
#27 0x000055951e01615c
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/testing/llvm/bin_main/bin/clang-14+0x217815c)
#28 0x000055951e930fbc
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
#29 0x000055951e902952
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
(/testing/llvm/bin_main/bin/clang-14+0x2a64952)
#30 0x000055951e9034f9
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+0x2a654f9)
#31 0x000055951e9111a9
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/testing/llvm/bin_main/bin/clang-14+0x2a731a9)
#32 0x000055951cab4401 main (/testing/llvm/bin_main/bin/clang-14+0xc16401)
#33 0x00007f24091befd0 (/lib/x86_64-linux-gnu/libc.so.6+0x2dfd0)
#34 0x00007f24091bf07d __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x2e07d)
#35 0x000055951cb35765 _start (/testing/llvm/bin_main/bin/clang-14+0xc97765)
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>
8fb3f84484094230d563c1e4c1088755b7cde15b)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /testing/llvm/bin_main/bin

C++ Reproducer:
int a, c, d;
bool b;
int *e;
void f() {
  int g;
#pragma clang loop interleave(enable)
  for (int h = 0; h < 407794; h += c)
    for (bool i = 0; i < d; i = 1) {
      a = h ? e[h] : 0;
      int d = e[h];
      g = d;
      b = g;
    }
}

Error:
<span class="quote">>$ clang++ -c -O3 func.cpp</span ></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>