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

    <tr>
        <th>Summary</th>
        <td>
            Assertion `getActiveBits() <= 64 && "Too many bits for uint64_t"' failed. for opt -passes="loop-idiom"
        </td>
    </tr>

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

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

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

<pre>
    llvm commit: 14b039c1dd1e20
Reproduce with:
```
opt -passes="loop-idiom" bbi-88060.ll -o /dev/null
```
Result:
```
opt: ../include/llvm/ADT/APInt.h:1488: uint64_t llvm::APInt::getZExtValue() const: Assertion `getActiveBits() <= 64 && "Too many bits for uint64_t"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: ../../main-github/llvm/build-all/bin/opt -passes=loop-idiom bbi-88060.ll -o /dev/null
 #0 0x00005597b3a36cf7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (../../main-github/llvm/build-all/bin/opt+0x2f49cf7)
 #1 0x00005597b3a3484e llvm::sys::RunSignalHandlers() (../../main-github/llvm/build-all/bin/opt+0x2f4784e)
 #2 0x00005597b3a373bf SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f22810b8630 __restore_rt sigaction.c:0:0
 #4 0x00007f227e7ff387 raise (/lib64/libc.so.6+0x36387)
 #5 0x00007f227e800a78 abort (/lib64/libc.so.6+0x37a78)
 #6 0x00007f227e7f81a6 __assert_fail_base (/lib64/libc.so.6+0x2f1a6)
 #7 0x00007f227e7f8252 (/lib64/libc.so.6+0x2f252)
 #8 0x00005597b458b876 (../../main-github/llvm/build-all/bin/opt+0x3a9e876)
 #9 0x00005597b45899ca (anonymous namespace)::LoopIdiomRecognize::processLoopStridedStore(llvm::Value*, llvm::SCEV const*, llvm::MaybeAlign, llvm::Value*, llvm::Instruction*, llvm::SmallPtrSetImpl<llvm::Instruction*>&, llvm::SCEVAddRecExpr const*, llvm::SCEV const*, bool, bool) LoopIdiomRecognize.cpp:0:0
#10 0x00005597b4588c83 (anonymous namespace)::LoopIdiomRecognize::processLoopStores(llvm::SmallVectorImpl<llvm::StoreInst*>&, llvm::SCEV const*, (anonymous namespace)::LoopIdiomRecognize::ForMemset) LoopIdiomRecognize.cpp:0:0
#11 0x00005597b4585bd3 (anonymous namespace)::LoopIdiomRecognize::runOnLoopBlock(llvm::BasicBlock*, llvm::SCEV const*, llvm::SmallVectorImpl<llvm::BasicBlock*>&) LoopIdiomRecognize.cpp:0:0
#12 0x00005597b457fba0 llvm::LoopIdiomRecognizePass::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (../../main-github/llvm/build-all/bin/opt+0x3a92ba0)
#13 0x00005597b3c576ad llvm::detail::PassModel<llvm::Loop, llvm::LoopIdiomRecognizePass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (../../main-github/llvm/build-all/bin/opt+0x316a6ad)
#14 0x00005597b45a4903 std::optional<llvm::PreservedAnalyses> llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::runSinglePass<llvm::Loop, std::unique_ptr<llvm::detail::PassConcept<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, std::default_delete<llvm::detail::PassConcept<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>>>>(llvm::Loop&, std::unique_ptr<llvm::detail::PassConcept<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, std::default_delete<llvm::detail::PassConcept<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>>>&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&, llvm::PassInstrumentation&) (../../main-github/llvm/build-all/bin/opt+0x3ab7903)
#15 0x00005597b45a4557 llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::runWithoutLoopNestPasses(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (../../main-github/llvm/build-all/bin/opt+0x3ab7557)
#16 0x00005597b45a3af8 llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (../../main-github/llvm/build-all/bin/opt+0x3ab6af8)
#17 0x00005597b3c33ded llvm::detail::PassModel<llvm::Loop, llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (../../main-github/llvm/build-all/bin/opt+0x3146ded)
#18 0x00005597b45a5961 llvm::FunctionToLoopPassAdaptor::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x3ab8961)
#19 0x00005597b3c572dd llvm::detail::PassModel<llvm::Function, llvm::FunctionToLoopPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x316a2dd)
#20 0x00005597b3455f64 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x2968f64)
#21 0x00005597b181a28d 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>&) (../../main-github/llvm/build-all/bin/opt+0xd2d28d)
#22 0x00005597b345a34e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x296d34e)
#23 0x00005597b181a02d llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0xd2d02d)
#24 0x00005597b34550f4 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x29680f4)
#25 0x00005597b1417c13 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (../../main-github/llvm/build-all/bin/opt+0x92ac13)
#26 0x00005597b142525c main (../../main-github/llvm/build-all/bin/opt+0x93825c)
#27 0x00007f227e7eb555 __libc_start_main (/lib64/libc.so.6+0x22555)
#28 0x00005597b1411db0 _start (../../main-github/llvm/build-all/bin/opt+0x924db0)
Abort (core dumped)
```
[bbi-88060.ll.gz](https://github.com/llvm/llvm-project/files/13111832/bbi-88060.ll.gz)

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWl1z2ywW_jXkhokHgT7QRS6cD89mttk3k2S7M3vjQQI5bBFoAbXN--t3kB3byE7qNOns27QzjuVIcD4ennMQcJhzcqGFOAHZKcjOj1jv7409aeUnJtS9Ua3QR5XhDydKfW5hbdpWekCmMEkrRMo64TwRGAF0DtD0RnTW8L4W8Iv094BMl7dBjlaf4V_TeXjcMeeEA-QcYKyM6Y4ll6YFGMOqkseUohxNlILHBgI84-IzwDPdK7VX4I1wvfLPqAv2TiYAz6SuVc8FwLPgDcCz6fld-L6-1H4SDE5SSkPrXmqfp3MPh3ZkCsh0aLT8uRD-3xdf_UemegEwBbiEtdFu0DN1TlgvjYYgRwvhp7WXn8Wp9G7VEpAzQM5hnkKAc4BzCDC-Mwa2TD_ASnoHG2PXBgCMAS5gw6QSfLL06PrDxfT2Arq-aqWHDFb9AlrRGeuhN_De-84FO_EM4NlC-vu-mtQB20enw-W4s-Y_ovYBFOd64QCeQaY5XEEE_b2AtWXuHlas_uQtq8VK_a1n9SfI-7ZbQ44mAJXX1iwsayGzi74V2rs17MNXy6Q-Xpq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