Datasets:

Modalities:
Text
Formats:
json
Size:
< 1K
Tags:
code
DOI:
Libraries:
Datasets
pandas
License:
dtcxzyw commited on
Commit
cf11aa0
·
1 Parent(s): 416886a
dataset.jsonl CHANGED
The diff for this file is too large to render. See raw diff
 
dataset/124518.json ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "124518",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/124518",
4
+ "bug_type": "crash",
5
+ "base_commit": "2ec88374e07f8ec395b7bf414bf1bdda88cebfc6",
6
+ "knowledge_cutoff": "2025-01-27T07:58:41Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopUnrollAndJam"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "3ef33066bb32a9d9b76d72c6de6a7ae9ff72ddcc",
12
+ "components": [
13
+ "LoopUnrollAndJamPass"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": [
17
+ [
18
+ 425,
19
+ 431
20
+ ],
21
+ [
22
+ 441,
23
+ 448
24
+ ],
25
+ [
26
+ 457,
27
+ 467
28
+ ]
29
+ ]
30
+ },
31
+ "bug_location_funcname": {
32
+ "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": [
33
+ "LoopUnrollAndJamPass::run",
34
+ "tryToUnrollAndJamLoop"
35
+ ]
36
+ }
37
+ },
38
+ "patch": "commit 3ef33066bb32a9d9b76d72c6de6a7ae9ff72ddcc\nAuthor: David Green <[email protected]>\nDate: Sat Mar 29 19:21:34 2025 +0000\n\n [UnrollAndJam] Do not preserve loop nests if a loop was fully unrolled. (#133510)\n \n If UnJ completely unrolls a loop and removes it entirely, the loop\n remains in the current loop nest. If the loop nest gets reused the loops\n will no longer be valid. As there is no way to remove a loop from a\n LoopNest, this patch removes the preserve of the LoopNestAnalysis so\n that it will be regenerated.\n \n Fixes #124518\n\ndiff --git a/llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp b/llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp\nindex f1d1f3bc1e30..4fe74c7c3bbc 100644\n--- a/llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp\n+++ b/llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp\n@@ -425,7 +425,7 @@ static bool tryToUnrollAndJamLoop(LoopNest &LN, DominatorTree &DT, LoopInfo &LI,\n const TargetTransformInfo &TTI,\n AssumptionCache &AC, DependenceInfo &DI,\n OptimizationRemarkEmitter &ORE, int OptLevel,\n- LPMUpdater &U) {\n+ LPMUpdater &U, bool &AnyLoopRemoved) {\n bool DidSomething = false;\n ArrayRef<Loop *> Loops = LN.getLoops();\n Loop *OutmostLoop = &LN.getOutermostLoop();\n@@ -441,8 +441,11 @@ static bool tryToUnrollAndJamLoop(LoopNest &LN, DominatorTree &DT, LoopInfo &LI,\n tryToUnrollAndJamLoop(L, DT, &LI, SE, TTI, AC, DI, ORE, OptLevel);\n if (Result != LoopUnrollResult::Unmodified)\n DidSomething = true;\n- if (L == OutmostLoop && Result == LoopUnrollResult::FullyUnrolled)\n- U.markLoopAsDeleted(*L, LoopName);\n+ if (Result == LoopUnrollResult::FullyUnrolled) {\n+ if (L == OutmostLoop)\n+ U.markLoopAsDeleted(*L, LoopName);\n+ AnyLoopRemoved = true;\n+ }\n }\n \n return DidSomething;\n@@ -457,11 +460,13 @@ PreservedAnalyses LoopUnrollAndJamPass::run(LoopNest &LN,\n DependenceInfo DI(&F, &AR.AA, &AR.SE, &AR.LI);\n OptimizationRemarkEmitter ORE(&F);\n \n+ bool AnyLoopRemoved = false;\n if (!tryToUnrollAndJamLoop(LN, AR.DT, AR.LI, AR.SE, AR.TTI, AR.AC, DI, ORE,\n- OptLevel, U))\n+ OptLevel, U, AnyLoopRemoved))\n return PreservedAnalyses::all();\n \n auto PA = getLoopPassPreservedAnalyses();\n- PA.preserve<LoopNestAnalysis>();\n+ if (!AnyLoopRemoved)\n+ PA.preserve<LoopNestAnalysis>();\n return PA;\n }\n",
39
+ "tests": [
40
+ {
41
+ "file": "llvm/test/Transforms/LoopUnrollAndJam/delete_middle_loop.ll",
42
+ "commands": [
43
+ "opt -passes=\"loop(invalidate<all>,loop-unroll-and-jam,loop-unroll-and-jam)\" -allow-unroll-and-jam -unroll-and-jam-count=4 < %s -S"
44
+ ],
45
+ "tests": [
46
+ {
47
+ "test_name": "<module>",
48
+ "test_body": "\n; This test completely unrolls the middle loop out of a 3-deep loop nest.\n\ndefine i16 @test_it() {\n;\nentry:\n br label %for.cond\n\nfor.cond: ; preds = %do.cond, %entry\n br label %do.body2\n\ndo.body2: ; preds = %do.cond, %for.cond\n br label %while.cond3\n\nwhile.cond3: ; preds = %while.cond3, %do.body2\n br i1 true, label %do.cond, label %while.cond3\n\ndo.cond: ; preds = %while.cond3\n br i1 true, label %for.cond, label %do.body2\n}\n"
49
+ }
50
+ ]
51
+ }
52
+ ],
53
+ "issue": {
54
+ "title": "LoopUnrollAndJamPass crash: GenericLoopInfo.h:146: [...] Assertion `!isInvalid() && \"Loop not in a valid state!\"' failed.",
55
+ "body": "llvm commit: 6805d7e8aa5f\n\nReproduce with:\n```opt -passes=\"loop(invalidate<all>,loop-unroll-and-jam,loop-unroll-and-jam)\" bbi-103085.ll -o /dev/null -S -unroll-and-jam-count=4 -mcpu=cortex-a55 -mtriple=aarch64```\n\nResult:\n```\nopt: ../include/llvm/Support/GenericLoopInfo.h:146: const std::vector<LoopT *> &llvm::LoopBase<llvm::BasicBlock, llvm::Loop>::getSubLoops() const [BlockT = llvm::BasicBlock, LoopT = llvm::Loop]: Assertion `!isInvalid() && \"Loop not in a valid state!\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0.\tProgram arguments: build-all/bin/opt -passes=loop(invalidate<all>,loop-unroll-and-jam,loop-unroll-and-jam) bbi-103085.ll -o /dev/null -S -unroll-and-jam-count=4 -mcpu=cortex-a55 -mtriple=aarch64\n1.\tRunning pass \"function(loop(invalidate<all>,loop-unroll-and-jam,loop-unroll-and-jam))\" on module \"bbi-103085.ll\"\n2.\tRunning pass \"loop(invalidate<all>,loop-unroll-and-jam,loop-unroll-and-jam)\" on function \"test_it\"\n #0 0x0000564cc1e14ac6 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (build-all/bin/opt+0x45ceac6)\n #1 0x0000564cc1e1250e llvm::sys::RunSignalHandlers() (build-all/bin/opt+0x45cc50e)\n #2 0x0000564cc1e15379 SignalHandler(int) Signals.cpp:0:0\n #3 0x00007fafbeb0bd10 __restore_rt (/lib64/libpthread.so.0+0x12d10)\n #4 0x00007fafbc4ab52f raise (/lib64/libc.so.6+0x4e52f)\n #5 0x00007fafbc47ee65 abort (/lib64/libc.so.6+0x21e65)\n #6 0x00007fafbc47ed39 _nl_load_domain.cold.0 (/lib64/libc.so.6+0x21d39)\n #7 0x00007fafbc4a3e86 (/lib64/libc.so.6+0x46e86)\n #8 0x0000564cc274b6cb void llvm::appendReversedLoopsToWorklist<llvm::iterator_range<std::reverse_iterator<llvm::Loop* const*>>>(llvm::iterator_range<std::reverse_iterator<llvm::Loop* const*>>&&, llvm::SmallPriorityWorklist<llvm::Loop*, 4u>&) (build-all/bin/opt+0x4f056cb)\n #9 0x0000564cc274b42e void llvm::appendLoopsToWorklist<llvm::ArrayRef<llvm::Loop*>&>(llvm::ArrayRef<llvm::Loop*>&, llvm::SmallPriorityWorklist<llvm::Loop*, 4u>&) (build-all/bin/opt+0x4f0542e)\n#10 0x0000564cc381dfce llvm::LoopUnrollAndJamPass::run(llvm::LoopNest&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (build-all/bin/opt+0x5fd7fce)\n#11 0x0000564cc328d01d llvm::detail::PassModel<llvm::LoopNest, llvm::LoopUnrollAndJamPass, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::LoopNest&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) PassBuilderPipelines.cpp:0:0\n#12 0x0000564cc34ff5ed std::optional<llvm::PreservedAnalyses> llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::runSinglePass<llvm::LoopNest, std::unique_ptr<llvm::detail::PassConcept<llvm::LoopNest, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, std::default_delete<llvm::detail::PassConcept<llvm::LoopNest, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>>>>(llvm::LoopNest&, std::unique_ptr<llvm::detail::PassConcept<llvm::LoopNest, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, std::default_delete<llvm::detail::PassConcept<llvm::LoopNest, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>>>&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&, llvm::PassInstrumentation&) (build-all/bin/opt+0x5cb95ed)\n#13 0x0000564cc34fe8e5 llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::runWithLoopNestPasses(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (build-all/bin/opt+0x5cb88e5)\n#14 0x0000564cc34fe480 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&) (build-all/bin/opt+0x5cb8480)\n#15 0x0000564cc327a8bd llvm::detail::PassModel<llvm::Loop, llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) PassBuilderPipelines.cpp:0:0\n#16 0x0000564cc35001a1 llvm::FunctionToLoopPassAdaptor::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (build-all/bin/opt+0x5cba1a1)\n#17 0x0000564cc327eedd llvm::detail::PassModel<llvm::Function, llvm::FunctionToLoopPassAdaptor, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) PassBuilderPipelines.cpp:0:0\n#18 0x0000564cc2035a27 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (build-all/bin/opt+0x47efa27)\n#19 0x0000564cc32846cd llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) PassBuilderPipelines.cpp:0:0\n#20 0x0000564cc203a5fe llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (build-all/bin/opt+0x47f45fe)\n#21 0x0000564cc327c19d llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) PassBuilderPipelines.cpp:0:0\n#22 0x0000564cc2034717 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (build-all/bin/opt+0x47ee717)\n#23 0x0000564cc320468c llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (build-all/bin/opt+0x59be68c)\n#24 0x0000564cc1dd7712 optMain (build-all/bin/opt+0x4591712)\n#25 0x00007fafbc4977e5 __libc_start_main (/lib64/libc.so.6+0x3a7e5)\n#26 0x0000564cc1dd532e _start (build-all/bin/opt+0x458f32e)\nAbort\n```\n\n[bbi-103085.ll.gz](https://github.com/user-attachments/files/18556221/bbi-103085.ll.gz)",
56
+ "author": "mikaelholmen",
57
+ "labels": [
58
+ "crash",
59
+ "llvm:transforms",
60
+ "generated by fuzzer"
61
+ ],
62
+ "comments": [
63
+ {
64
+ "author": "mikaelholmen",
65
+ "body": "The opt pipeline used to triggered this is non-standard and generated by a fuzzer, so I'm labelling this with \"generated by fuzzer\". I don't know if that the intended use. If not, please let me know."
66
+ },
67
+ {
68
+ "author": "davemgreen",
69
+ "body": "Do you have the IR reproducer too? Thanks"
70
+ },
71
+ {
72
+ "author": "mikaelholmen",
73
+ "body": "> Do you have the IR reproducer too? Thanks\n\nBah, sorry. Attached it to the original post now.\nThanks!"
74
+ },
75
+ {
76
+ "author": "mikaelholmen",
77
+ "body": "I noticed that if we build opt with ASAN and run the bbi-103085.ll testcase we get\n```\n==3349467==ERROR: AddressSanitizer: use-after-poison on address 0x521000007a40 at pc 0x55713d205877 bp 0x7ffdd1999e50 sp 0x7ffdd1999e48\nREAD of size 1 at 0x521000007a40 thread T0\n #0 0x55713d205876 in isInvalid /repo/llvm/build-all-bbisdk-asan/../include/llvm/Support/GenericLoopInfo.h:219:12\n #1 0x55713d205876 in getSubLoops /repo/llvm/build-all-bbisdk-asan/../include/llvm/Support/GenericLoopInfo.h:146:5\n #2 0x55713d205876 in begin /repo/llvm/build-all-bbisdk-asan/../include/llvm/Support/GenericLoopInfo.h:156:35\n #3 0x55713d205876 in void llvm::appendReversedLoopsToWorklist<llvm::iterator_range<std::__1::reverse_iterator<llvm::Loop* const*>>>(llvm::iterator_range<std::__1::reverse_iterator<llvm::Loop* const*>>&&, llvm::SmallPriorityWorklist<llvm::Loop*, 4u>&) /repo/llvm/build-all-bbisdk-asan/../lib/Transforms/Utils/LoopUtils.cpp:1808:34\n #4 0x55713d204ad9 in void llvm::appendLoopsToWorklist<llvm::ArrayRef<llvm::Loop*>&>(llvm::ArrayRef<llvm::Loop*>&, llvm::SmallPriorityWorklist<llvm::Loop*, 4u>&) /repo/llvm/build-all-bbisdk-asan/../lib/Transforms/Utils/LoopUtils.cpp:1820:3\n #5 0x55714083fe1b in tryToUnrollAndJamLoop /repo/llvm/build-all-bbisdk-asan/../lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp:436:3\n #6 0x55714083fe1b in llvm::LoopUnrollAndJamPass::run(llvm::LoopNest&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) /repo/llvm/build-all-bbisdk-asan/../lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp:460:8\n #7 0x55713f72db11 in llvm::detail::PassModel<llvm::LoopNest, llvm::LoopUnrollAndJamPass, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::LoopNest&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerInternal.h:91:17\n #8 0x55713fec0dd7 in std::__1::optional<llvm::PreservedAnalyses> llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::runSinglePass<llvm::LoopNest, std::__1::unique_ptr<llvm::detail::PassConcept<llvm::LoopNest, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, std::__1::default_delete<llvm::detail::PassConcept<llvm::LoopNest, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>>>>(llvm::LoopNest&, std::__1::unique_ptr<llvm::detail::PassConcept<llvm::LoopNest, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, std::__1::default_delete<llvm::detail::PassConcept<llvm::LoopNest, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>>>&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&, llvm::PassInstrumentation&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/Transforms/Scalar/LoopPassManager.h:375:32\n #9 0x55713febe67c in llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::runWithLoopNestPasses(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) /repo/llvm/build-all-bbisdk-asan/../lib/Transforms/Scalar/LoopPassManager.cpp:112:16\n #10 0x55713febdd61 in 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&) /repo/llvm/build-all-bbisdk-asan/../lib/Transforms/Scalar/LoopPassManager.cpp:30:32\n #11 0x55713f719901 in llvm::detail::PassModel<llvm::Loop, llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerInternal.h:91:17\n #12 0x55713fec3348 in llvm::FunctionToLoopPassAdaptor::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /repo/llvm/build-all-bbisdk-asan/../lib/Transforms/Scalar/LoopPassManager.cpp:302:38\n #13 0x55713f722991 in llvm::detail::PassModel<llvm::Function, llvm::FunctionToLoopPassAdaptor, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerInternal.h:91:17\n #14 0x55713ba254c9 in llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerImpl.h:81:38\n #15 0x55713f728871 in llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerInternal.h:91:17\n #16 0x55713ba34d25 in llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /repo/llvm/build-all-bbisdk-asan/../lib/IR/PassManager.cpp:124:38\n #17 0x55713f71d491 in llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerInternal.h:91:17\n #18 0x55713ba218f9 in llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerImpl.h:81:38\n #19 0x55713f5eda5d in llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::__1::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) /repo/llvm/build-all-bbisdk-asan/../tools/opt/NewPMDriver.cpp:552:7\n #20 0x55713b2721b3 in optMain /repo/llvm/build-all-bbisdk-asan/../tools/opt/optdriver.cpp:725:12\n #21 0x7f6c3bae47e4 in __libc_start_main (/lib64/libc.so.6+0x3a7e4) (BuildId: 37e4ac6a7fb96950b0e6bf72d73d94f3296c77eb)\n #22 0x55713b1823ad in _start (/repo/llvm/build-all-bbisdk-asan/bin/opt+0x8cfe3ad)\n\n0x521000007a40 is located 320 bytes inside of 4096-byte region [0x521000007900,0x521000008900)\nallocated by thread T0 here:\n #0 0x55713b25a992 in operator new(unsigned long, std::align_val_t, std::nothrow_t const&) asan_new_delete.cpp:113:3\n #1 0x55713b346d4f in llvm::allocate_buffer(unsigned long, unsigned long) /repo/llvm/build-all-bbisdk-asan/../lib/Support/MemAlloc.cpp:16:18\n #2 0x55713b34a30a in Allocate /repo/llvm/build-all-bbisdk-asan/../include/llvm/Support/AllocatorBase.h:92:12\n #3 0x55713b34a30a in StartNewSlab /repo/llvm/build-all-bbisdk-asan/../include/llvm/Support/Allocator.h:346:42\n #4 0x55713b34a30a in llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul, 128ul>::AllocateSlow(unsigned long, unsigned long, llvm::Align) /repo/llvm/build-all-bbisdk-asan/../include/llvm/Support/Allocator.h:202:5\n #5 0x55713cb12443 in Allocate /repo/llvm/build-all-bbisdk-asan/../include/llvm/Support/Allocator.h:178:12\n #6 0x55713cb12443 in Allocate /repo/llvm/build-all-bbisdk-asan/../include/llvm/Support/Allocator.h:216:12\n #7 0x55713cb12443 in Allocate /repo/llvm/build-all-bbisdk-asan/../include/llvm/Support/AllocatorBase.h:53:43\n #8 0x55713cb12443 in Allocate<llvm::Loop> /repo/llvm/build-all-bbisdk-asan/../include/llvm/Support/AllocatorBase.h:76:29\n #9 0x55713cb12443 in llvm::Loop* llvm::LoopInfoBase<llvm::BasicBlock, llvm::Loop>::AllocateLoop<llvm::BasicBlock*&>(llvm::BasicBlock*&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/Support/GenericLoopInfo.h:571:36\n #10 0x55713cb0ff50 in llvm::LoopInfoBase<llvm::BasicBlock, llvm::Loop>::analyze(llvm::DominatorTreeBase<llvm::BasicBlock, false> const&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/Support/GenericLoopInfoImpl.h:594:18\n #11 0x55713cb23dbc in llvm::LoopAnalysis::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /repo/llvm/build-all-bbisdk-asan/../lib/Analysis/LoopInfo.cpp:977:6\n #12 0x55714109e4e7 in llvm::detail::AnalysisPassModel<llvm::Function, llvm::LoopAnalysis, llvm::AnalysisManager<llvm::Function>::Invalidator>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerInternal.h:321:14\n #13 0x55713ba300ab in llvm::AnalysisManager<llvm::Function>::getResultImpl(llvm::AnalysisKey*, llvm::Function&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerImpl.h:156:35\n #14 0x55713d1e67b4 in getResult<llvm::LoopAnalysis> /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManager.h:414:9\n #15 0x55713d1e67b4 in llvm::LoopSimplifyPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /repo/llvm/build-all-bbisdk-asan/../lib/Transforms/Utils/LoopSimplify.cpp:825:22\n #16 0x55713f719f11 in llvm::detail::PassModel<llvm::Function, llvm::LoopSimplifyPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerInternal.h:91:17\n #17 0x55713ba254c9 in llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerImpl.h:81:38\n #18 0x55713fec1dce in llvm::FunctionToLoopPassAdaptor::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /repo/llvm/build-all-bbisdk-asan/../lib/Transforms/Scalar/LoopPassManager.cpp:209:34\n #19 0x55713f722991 in llvm::detail::PassModel<llvm::Function, llvm::FunctionToLoopPassAdaptor, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerInternal.h:91:17\n #20 0x55713ba254c9 in llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerImpl.h:81:38\n #21 0x55713f728871 in llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerInternal.h:91:17\n #22 0x55713ba34d25 in llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /repo/llvm/build-all-bbisdk-asan/../lib/IR/PassManager.cpp:124:38\n #23 0x55713f71d491 in llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerInternal.h:91:17\n #24 0x55713ba218f9 in llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerImpl.h:81:38\n #25 0x55713f5eda5d in llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::__1::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) /repo/llvm/build-all-bbisdk-asan/../tools/opt/NewPMDriver.cpp:552:7\n #26 0x55713b2721b3 in optMain /repo/llvm/build-all-bbisdk-asan/../tools/opt/optdriver.cpp:725:12\n #27 0x7f6c3bae47e4 in __libc_start_main (/lib64/libc.so.6+0x3a7e4) (BuildId: 37e4ac6a7fb96950b0e6bf72d73d94f3296c77eb)\n\nSUMMARY: AddressSanitizer: use-after-poison /repo/llvm/build-all-bbisdk-asan/../include/llvm/Support/GenericLoopInfo.h:219:12 in isInvalid\nShadow bytes around the buggy address:\n 0x521000007780: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\n 0x521000007800: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\n 0x521000007880: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\n 0x521000007900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n 0x521000007980: 00 00 00 00 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7\n=>0x521000007a00: f7 f7 f7 f7 f7 f7 f7 f7[f7]f7 00 00 00 00 00 00\n 0x521000007a80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f7 f7\n 0x521000007b00: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7\n 0x521000007b80: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7\n 0x521000007c00: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7\n 0x521000007c80: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7\nShadow byte legend (one shadow byte represents 8 application bytes):\n Addressable: 00\n Partially addressable: 01 02 03 04 05 06 07 \n Heap left redzone: fa\n Freed heap region: fd\n Stack left redzone: f1\n Stack mid redzone: f2\n Stack right redzone: f3\n Stack after return: f5\n Stack use after scope: f8\n Global redzone: f9\n Global init order: f6\n Poisoned by user: f7\n Container overflow: fc\n Array cookie: ac\n Intra object redzone: bb\n ASan internal: fe\n Left alloca redzone: ca\n Right alloca redzone: cb\n==3349467==ABORTING\n```\n"
78
+ }
79
+ ]
80
+ },
81
+ "verified": true
82
+ }
dataset/131359.json ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "131359",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/131359",
4
+ "bug_type": "crash",
5
+ "base_commit": "e2c43ba981620cf71ce3ccf004db7c0db4caf8a7",
6
+ "knowledge_cutoff": "2025-03-14T16:56:53Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "eef5ea0c42fc07ef2c948be59b57d0df8ec801ca",
12
+ "components": [
13
+ "LoopVectorize"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
17
+ [
18
+ 7467,
19
+ 7472
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
25
+ "planContainsAdditionalSimplifications"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit eef5ea0c42fc07ef2c948be59b57d0df8ec801ca\nAuthor: Luke Lau <[email protected]>\nDate: Tue Mar 18 01:00:54 2025 +0900\n\n [VPlan] Account for dead FOR splice simplification in cost model (#131486)\n \n Fixes #131359\n \n After #129645, a first-order recurrence will no longer have it's splice\n costed if the VPInstruction::FirstOrderRecurrenceSplice has no users and\n is dead.\n \n The legacy cost model didn't account for this, so this accounts for it\n in planContainsAdditionalSimplifications to avoid the \"VPlan cost model\n and legacy cost model disagreed\" assertion.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\nindex b26b36f91a39..0e38ccc565ea 100644\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n@@ -7467,6 +7467,16 @@ static bool planContainsAdditionalSimplifications(VPlan &Plan,\n }\n continue;\n }\n+ // Unused FOR splices are removed by VPlan transforms, so the VPlan-based\n+ // cost model won't cost it whilst the legacy will.\n+ if (auto *FOR = dyn_cast<VPFirstOrderRecurrencePHIRecipe>(&R)) {\n+ if (none_of(FOR->users(), [](VPUser *U) {\n+ auto *VPI = dyn_cast<VPInstruction>(U);\n+ return VPI && VPI->getOpcode() ==\n+ VPInstruction::FirstOrderRecurrenceSplice;\n+ }))\n+ return true;\n+ }\n // The VPlan-based cost model is more accurate for partial reduction and\n // comparing against the legacy cost isn't desirable.\n if (isa<VPPartialReductionRecipe>(&R))\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/LoopVectorize/X86/pr131359-dead-for-splice.ll",
33
+ "commands": [
34
+ "opt -p loop-vectorize -S %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "<module>",
39
+ "test_body": "\n; If a FOR isn't used the VPInstruction::FirstOrderRecurrenceSplice will be dead\n; and won't be costed in the VPlan cost model. Make sure we account for this\n; simplifcation in comparison to the legacy cost model.\n\ntarget triple = \"x86_64\"\n\ndefine void @no_use() {\n;\nentry:\n br label %loop\n\nloop:\n %for = phi i32 [ 0, %entry ], [ %iv, %loop ]\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.next = add i32 %iv, 1\n %exitcond.not.i = icmp eq i32 %iv, 43\n br i1 %exitcond.not.i, label %exit, label %loop\n\nexit:\n ret void\n}\n\ndefine void @dead_use() {\n;\nentry:\n br label %loop\n\nloop:\n %for = phi i32 [ 0, %entry ], [ %iv, %loop ]\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %dead = add i32 %for, 1\n %iv.next = add i32 %iv, 1\n %exitcond.not.i = icmp eq i32 %iv, 43\n br i1 %exitcond.not.i, label %exit, label %loop\n\nexit:\n ret void\n}"
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "issue": {
45
+ "title": "clang crashes at -Os on x86_64-linux-gnu: Assertion `... \" VPlan cost model and legacy cost model disagreed\"' failed",
46
+ "body": "It appears to be a regression from 19.1.0 and affects 20.1.0 and later. \n\nCompiler Explorer: https://godbolt.org/z/K3Y3zn4hP\n\n```\n[515] % clangtk -v\nclang version 21.0.0git (https://github.com/llvm/llvm-project.git da3ee9763266f9adedaac1b1b3162d14f951fc55)\nTarget: x86_64-unknown-linux-gnu\nThread model: posix\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\nBuild config: +assertions\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\nCandidate multilib: .;@m64\nSelected multilib: .;@m64\n[516] % \n[516] % clangtk -Os small.c\nclang-21: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7574: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || PlanForEarlyExitLoop || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop) || planContainsAdditionalSimplifications(getPlanFor(LegacyVF.Width), CostCtx, OrigLoop)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\nStack dump:\n0.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-21 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/20250313-clangtk-m64-Os-build-082148/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20250313-clangtk-m64-Os-build-082148/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/21 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Os -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-d02bf4.o -x c small.c\n1.\t<eof> parser at end of file\n2.\tOptimizer\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"small.c\"\n4.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\n #0 0x0000563ced471fcf llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x4577fcf)\n #1 0x0000563ced46f7a4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007f1c5b61c420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\n #3 0x00007f1c5b05300b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\n #4 0x00007f1c5b032859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\n #5 0x00007f1c5b032729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\n #6 0x00007f1c5b032729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\n #7 0x00007f1c5b043fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\n #8 0x0000563ceeecce93 llvm::LoopVectorizationPlanner::computeBestVF() (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5fd2e93)\n #9 0x0000563ceeee48a6 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5fea8a6)\n#10 0x0000563ceeee72a1 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5fed2a1)\n#11 0x0000563ceeee7943 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5fed943)\n#12 0x0000563ceea5a6d6 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5b606d6)\n#13 0x0000563cecde27c9 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x3ee87c9)\n#14 0x0000563cea6cc7a6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x17d27a6)\n#15 0x0000563cecde1032 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x3ee7032)\n#16 0x0000563cea6ca3b6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x17d03b6)\n#17 0x0000563cecde0a51 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x3ee6a51)\n#18 0x0000563ced72fe4a (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>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\n#19 0x0000563ced7338a1 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x48398a1)\n#20 0x0000563cede73d91 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x4f79d91)\n#21 0x0000563cef8016dc clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x69076dc)\n#22 0x0000563cede741b8 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x4f7a1b8)\n#23 0x0000563cee14abc9 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5250bc9)\n#24 0x0000563cee0cbece clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x51d1ece)\n#25 0x0000563cee23f996 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5345996)\n#26 0x0000563cea25f9ed cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x13659ed)\n#27 0x0000563cea25715a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#28 0x0000563cea25b3c7 clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x13613c7)\n#29 0x0000563cea1400db main (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x12460db)\n#30 0x00007f1c5b034083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\n#31 0x0000563cea256bee _start (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x135cbee)\nclangtk: error: unable to execute command: Aborted\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\nclang version 21.0.0git (https://github.com/llvm/llvm-project.git da3ee9763266f9adedaac1b1b3162d14f951fc55)\nTarget: x86_64-unknown-linux-gnu\nThread model: posix\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\nBuild config: +assertions\nclangtk: note: diagnostic msg: \n********************\n\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\nPreprocessed source(s) and associated run script(s) are located at:\nclangtk: note: diagnostic msg: /tmp/small-7bdf6a.c\nclangtk: note: diagnostic msg: /tmp/small-7bdf6a.sh\nclangtk: note: diagnostic msg: \n\n********************\n[517] % \n[517] % cat small.c\nint printf(const char *, ...);\nint a, c, d, e;\nstatic int b = 2;\nstatic void f() {\n printf(\"0\\n\");\n for (c = 0; c < 3; c++)\n if (d && c >= b && e)\n a = 0;\n}\nint main() {\n b = 0;\n f();\n return 0;\n}\n```\n\n",
47
+ "author": "zhendongsu",
48
+ "labels": [
49
+ "vectorizers",
50
+ "crash",
51
+ "regression:20"
52
+ ],
53
+ "comments": [
54
+ {
55
+ "author": "cardigan1008",
56
+ "body": "Here is another case that triggers the same crash at `-O2`:\n\n```c\nint a, b;\nchar c;\nvoid f(int g) {\n int d;\n for (int e = 0; e < g; e++)\n d = e;\n a = d;\n}\nvoid h() {\n if (c)\n b = 0;\n else\n b = 1;\n f(b + 42);\n}\nvoid main() {}\n```\n\nCompiler Explorer: https://godbolt.org/z/zY6GT5eox\n\nBisected to https://github.com/llvm/llvm-project/commit/26324bc1bf397453ce966f56a88245263f7beec5, which was committed by @lukel97 "
57
+ },
58
+ {
59
+ "author": "lukel97",
60
+ "body": "Hi @zhendongsu @cardigan1008, thanks for reporting/reducing/bisecting this. Can you confirm that this is fixed now after [eef5ea0](https://github.com/llvm/llvm-project/commit/eef5ea0c42fc07ef2c948be59b57d0df8ec801ca)?"
61
+ },
62
+ {
63
+ "author": "cardigan1008",
64
+ "body": "Hi @lukel97 my case has been fixed. But the first case seems to still trigger the same crash at `-Os`.\n\nMy clang version: clang version 21.0.0git (https://github.com/llvm/llvm-project.git b3c5031b07396959c5d4e7f62d516d63de015358)"
65
+ },
66
+ {
67
+ "author": "lukel97",
68
+ "body": "@cardigan1008 Looks like that's a separate vplan-legacy cost model mismatch, it seems to be reproducible before 26324bc1bf397453ce966f56a88245263f7beec5. I'll leave this issue open"
69
+ }
70
+ ]
71
+ },
72
+ "verified": true
73
+ }
dataset/132563.json ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "132563",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/132563",
4
+ "bug_type": "crash",
5
+ "base_commit": "57530c23a53b5e003d389437637f61c5b9814e22",
6
+ "knowledge_cutoff": "2025-03-22T20:38:57Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/VectorCombine"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "f572a5951a664d57e909928d5595285212ad6884",
12
+ "components": [
13
+ "VectorCombine"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [
17
+ [
18
+ 1438,
19
+ 1443
20
+ ],
21
+ [
22
+ 1445,
23
+ 1451
24
+ ]
25
+ ]
26
+ },
27
+ "bug_location_funcname": {
28
+ "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [
29
+ "canScalarizeAccess"
30
+ ]
31
+ }
32
+ },
33
+ "patch": "commit f572a5951a664d57e909928d5595285212ad6884\nAuthor: Simon Pilgrim <[email protected]>\nDate: Thu Apr 24 14:17:46 2025 +0100\n\n [VectorCombine] Ensure canScalarizeAccess handles cases where the index type can't represent all inbounds values\n \n Fixes #132563\n\ndiff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp\nindex bd225bcc0635..04c084ffdda9 100644\n--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp\n+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp\n@@ -1438,6 +1438,7 @@ static ScalarizationResult canScalarizeAccess(VectorType *VecTy, Value *Idx,\n // This is the number of elements of fixed vector types,\n // or the minimum number of elements of scalable vector types.\n uint64_t NumElements = VecTy->getElementCount().getKnownMinValue();\n+ unsigned IntWidth = Idx->getType()->getScalarSizeInBits();\n \n if (auto *C = dyn_cast<ConstantInt>(Idx)) {\n if (C->getValue().ult(NumElements))\n@@ -1445,7 +1446,10 @@ static ScalarizationResult canScalarizeAccess(VectorType *VecTy, Value *Idx,\n return ScalarizationResult::unsafe();\n }\n \n- unsigned IntWidth = Idx->getType()->getScalarSizeInBits();\n+ // Always unsafe if the index type can't handle all inbound values.\n+ if (!llvm::isUIntN(IntWidth, NumElements))\n+ return ScalarizationResult::unsafe();\n+\n APInt Zero(IntWidth, 0);\n APInt MaxElts(IntWidth, NumElements);\n ConstantRange ValidIndices(Zero, MaxElts);\n",
34
+ "tests": [
35
+ {
36
+ "file": "llvm/test/Transforms/VectorCombine/pr132563.ll",
37
+ "commands": [
38
+ "opt -passes=vector-combine -S %s"
39
+ ],
40
+ "tests": [
41
+ {
42
+ "test_name": "<module>",
43
+ "test_body": "\n; Ensure canScalarizeAccess handles cases where the index type can't represent all inbounds values\n\ndefine void @src_1_idx(ptr %q, i8 zeroext %s, i1 %idx) {\n;\n %ld = load <16 x i8>, ptr %q\n %v1 = insertelement <16 x i8> %ld, i8 %s, i1 %idx\n store <16 x i8> %v1, ptr %q\n ret void\n}\n\ndefine void @src_2_idx(ptr %q, i8 zeroext %s, i8 %idx) {\n;\n %ld = load <256 x i8>, ptr %q\n %v1 = insertelement <256 x i8> %ld, i8 %s, i8 %idx\n store <256 x i8> %v1, ptr %q\n ret void\n}"
44
+ }
45
+ ]
46
+ }
47
+ ],
48
+ "issue": {
49
+ "title": "[VectorCombine] Crash occured while fold load-insertelement-store",
50
+ "body": "This is an IR sample that crashes.\n\n```\ndefine void @src_1_idx(ptr %q, i8 zeroext %s, i1 %idx) {\nentry:\n %0 = load <16 x i8>, ptr %q\n %v1 = insertelement <16 x i8> %0, i8 %s, i1 %idx\n store <16 x i8> %v1, ptr %q\n ret void\n}\n\ndefine void @src_2_idx(ptr %q, i8 zeroext %s, i8 %idx) {\nentry:\n %0 = load <256 x i8>, ptr %q\n %v1 = insertelement <256 x i8> %0, i8 %s, i8 %idx\n store <256 x i8> %v1, ptr %q\n ret void\n}\n```\n\nand this is debugging message with crash dump\n```\nVECTORCOMBINE on src_2_idx\nVC: Visiting: %0 = load <16 x i8>, ptr %q, align 16\nVC: Visiting: %v1 = insertelement <16 x i8> %0, i8 %s, i1 %idx\nVC: Visiting: store <16 x i8> %v1, ptr %q, align 16\nAssertion failed: (llvm::isUIntN(BitWidth, val) && \"Value is not an N-bit unsigned value\"), function APInt, file APInt.h, line 128.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0.\tProgram arguments: bin/opt -passes=vector-combine t1.ll -S -debug\n1.\tRunning pass \"function(vector-combine)\" on module \"t1.ll\"\n2.\tRunning pass \"vector-combine\" on function \"src_2_idx\"\n #0 0x00000001026ca6ac llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/Users/b2sy/work/test3/bin/opt+0x1019566ac)\n #1 0x00000001026c8770 llvm::sys::RunSignalHandlers() (/Users/b2sy/work/test3/bin/opt+0x101954770)\n #2 0x00000001026cae7c SignalHandler(int, __siginfo*, void*) (/Users/b2sy/work/test3/bin/opt+0x101956e7c)\n #3 0x000000019733ede4 (/usr/lib/system/libsystem_platform.dylib+0x180482de4)\n #4 0x0000000197307f70 (/usr/lib/system/libsystem_pthread.dylib+0x18044bf70)\n #5 0x0000000197214908 (/usr/lib/system/libsystem_c.dylib+0x180358908)\n #6 0x0000000197213c1c (/usr/lib/system/libsystem_c.dylib+0x180357c1c)\n #7 0x00000001032ad794 isUpperSubvectorUndef(llvm::SDValue, llvm::SDLoc const&, llvm::SelectionDAG&) (.cold.2) (/Users/b2sy/work/test3/bin/opt+0x102539794)\n #8 0x00000001029c4990 canScalarizeAccess(llvm::VectorType*, llvm::Value*, llvm::Instruction*, llvm::AssumptionCache&, llvm::DominatorTree const&) (/Users/b2sy/work/test3/bin/opt+0x101c50990)\n```\n\nproblem occured here \n```\n// VectorCombine.cpp:1447\n unsigned IntWidth = Idx->getType()->getScalarSizeInBits();\n APInt Zero(IntWidth, 0); \n APInt MaxElts(IntWidth, NumElements); <<< crash\n ConstantRange ValidIndices(Zero, MaxElts);\n ConstantRange IdxRange(IntWidth, true);\n```\n\nI think this code is necessary because it checks to see if the index specified by insertelement is in an accessible range on the vector, so I think we need to add exception handling to fix the problem.\n\nWhat do you think?\n\nNote that this is not a real-world issue, but a bug that I discovered while writing the patch and creating the verification code.\n\n",
51
+ "author": "ParkHanbum",
52
+ "labels": [
53
+ "vectorizers",
54
+ "crash"
55
+ ],
56
+ "comments": [
57
+ {
58
+ "author": "ParkHanbum",
59
+ "body": "No. I am trying to verify i8 type for that IR because I was trying to support multiple inserts but alive didn't make it. So i reduce type size then occured this issue."
60
+ },
61
+ {
62
+ "author": "RKSimon",
63
+ "body": "I'm not sure whether this should be addressed or not - oddly the langref doesn't say that the index type must be able to dereference all elements, just that its treated as unsigned (so I guess we assume implicit zext?)"
64
+ },
65
+ {
66
+ "author": "RKSimon",
67
+ "body": "@dtcxzyw Do you know whether smaller index types are handled anywhere else in the codebase please?"
68
+ },
69
+ {
70
+ "author": "dtcxzyw",
71
+ "body": "> [@dtcxzyw](https://github.com/dtcxzyw) Do you know whether smaller index types are handled anywhere else in the codebase please?\n\nI don't know. But this crash can be fixed by passing `implicitTrunc=true` into the APInt constructor, as we did in https://github.com/llvm/llvm-project/pull/80309.\n"
72
+ }
73
+ ]
74
+ },
75
+ "verified": true
76
+ }
dataset/132841.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "132841",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/132841",
4
+ "bug_type": "crash",
5
+ "base_commit": "822aa5ec1afee68fb16457ff06de9111c1b62450",
6
+ "knowledge_cutoff": "2025-03-24T22:57:28Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/SLPVectorizer"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "8122bb9dbe39a1dde77eb4aad76bf1c0e70b2d89",
12
+ "components": [
13
+ "SLPVectorizer"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
17
+ [
18
+ 15071,
19
+ 15077
20
+ ],
21
+ [
22
+ 15098,
23
+ 15109
24
+ ]
25
+ ]
26
+ },
27
+ "bug_location_funcname": {
28
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
29
+ "BoUpSLP::getLastInstructionInBundle"
30
+ ]
31
+ }
32
+ },
33
+ "patch": "commit 8122bb9dbe39a1dde77eb4aad76bf1c0e70b2d89\nAuthor: Alexey Bataev <[email protected]>\nDate: Tue Mar 25 04:10:56 2025 -0700\n\n [SLP]Fix a check for non-schedulable instructions\n \n Need to fix a check for non-schedulable instructions in\n getLastInstructionInBundle function, because this check may not work\n correctly during the codegen. Instead, need to check that actually these\n instructions were never scheduled, since the scheduling analysis always\n performed before the codegen and is stable.\n \n Fixes #132841\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex 4dc398f716b3..7741f96ee897 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -15071,7 +15071,18 @@ Instruction &BoUpSLP::getLastInstructionInBundle(const TreeEntry *E) {\n \n // Set the insert point to the beginning of the basic block if the entry\n // should not be scheduled.\n- if (doesNotNeedToSchedule(E->Scalars) ||\n+ const auto *It = BlocksSchedules.find(BB);\n+ auto IsNotScheduledEntry = [&](const TreeEntry *E) {\n+ if (E->isGather())\n+ return false;\n+ // Found previously that the instruction do not need to be scheduled.\n+ return It == BlocksSchedules.end() || all_of(E->Scalars, [&](Value *V) {\n+ if (!isa<Instruction>(V))\n+ return true;\n+ return It->second->getScheduleBundles(V).empty();\n+ });\n+ };\n+ if (IsNotScheduledEntry(E) ||\n (!E->isGather() && all_of(E->Scalars, isVectorLikeInstWithConstOps))) {\n if ((E->getOpcode() == Instruction::GetElementPtr &&\n any_of(E->Scalars,\n@@ -15098,12 +15109,11 @@ Instruction &BoUpSLP::getLastInstructionInBundle(const TreeEntry *E) {\n // scheduled, and the last instruction is VL.back(). So we start with\n // VL.back() and iterate over schedule data until we reach the end of the\n // bundle. The end of the bundle is marked by null ScheduleData.\n- if (BlocksSchedules.count(BB) && !E->isGather()) {\n+ if (It != BlocksSchedules.end() && !E->isGather()) {\n Value *V = E->isOneOf(E->Scalars.back());\n if (doesNotNeedToBeScheduled(V))\n V = *find_if_not(E->Scalars, doesNotNeedToBeScheduled);\n- if (ArrayRef<ScheduleBundle *> Bundles =\n- BlocksSchedules[BB]->getScheduleBundles(V);\n+ if (ArrayRef<ScheduleBundle *> Bundles = It->second->getScheduleBundles(V);\n !Bundles.empty()) {\n const auto *It = find_if(\n Bundles, [&](ScheduleBundle *B) { return B->getTreeEntry() == E; });\n",
34
+ "tests": [
35
+ {
36
+ "file": "llvm/test/Transforms/SLPVectorizer/X86/non-schedulable-instructions-become-schedulable.ll",
37
+ "commands": [
38
+ "opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-unknown -mcpu=znver2 < %s"
39
+ ],
40
+ "tests": [
41
+ {
42
+ "test_name": "<module>",
43
+ "test_body": "\ndefine void @test() {\n;\nentry:\n br label %bb1\n\nif.then.i.i:\n br label %3\n\nbb1:\n %0 = zext i1 false to i64\n %1 = add i64 0, %0\n %2 = add i64 0, 0\n br i1 false, label %3, label %bb2\n\n3:\n %pgocount51962 = phi i64 [ 0, %bb1 ], [ 0, %if.then.i.i ]\n %pgocount62360 = phi i64 [ 0, %bb1 ], [ 0, %if.then.i.i ]\n %pgocount83056 = phi i64 [ %1, %bb1 ], [ 0, %if.then.i.i ]\n %pgocount93354 = phi i64 [ %2, %bb1 ], [ 0, %if.then.i.i ]\n br label %bb2\n\nbb2:\n %pgocount51961 = phi i64 [ %pgocount51962, %3 ], [ 0, %bb1 ]\n %pgocount62359 = phi i64 [ %pgocount62360, %3 ], [ 0, %bb1 ]\n %pgocount83055 = phi i64 [ %pgocount83056, %3 ], [ %1, %bb1 ]\n %pgocount93353 = phi i64 [ %pgocount93354, %3 ], [ %2, %bb1 ]\n store i64 %pgocount51961, ptr getelementptr inbounds nuw (i8, ptr null, i64 40), align 8\n store i64 %pgocount62359, ptr getelementptr inbounds nuw (i8, ptr null, i64 48), align 8\n store i64 %pgocount83055, ptr getelementptr inbounds nuw (i8, ptr null, i64 56), align 8\n store i64 %pgocount93353, ptr getelementptr inbounds nuw (i8, ptr null, i64 64), align 8\n ret void\n}"
44
+ }
45
+ ]
46
+ }
47
+ ],
48
+ "issue": {
49
+ "title": "[SLP] crash with -fprofile-generate: Instruction::PHI && \"Expected PHI\"",
50
+ "body": "One of our internal tests picked up a new assertion failure since #131625\n\nHere's a reduced test-case\nhttps://godbolt.org/z/rKT64of5b\n```\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-unknown\"\n\ndefine void @_Z1sv() #0 {\nentry:\n br label %\"_ZZ1svEN3$_08__invokeEii.exit\"\n\nif.then.i.i: ; No predecessors!\n br label %3\n\n\"_ZZ1svEN3$_08__invokeEii.exit\": ; preds = %entry\n %0 = zext i1 false to i64\n %1 = add i64 0, %0\n %2 = add i64 0, 0\n br i1 false, label %3, label %while.cond.while.end_crit_edge\n\n3: ; preds = %\"_ZZ1svEN3$_08__invokeEii.exit\", %if.then.i.i\n %pgocount51962 = phi i64 [ 0, %\"_ZZ1svEN3$_08__invokeEii.exit\" ], [ 0, %if.then.i.i ]\n %pgocount62360 = phi i64 [ 0, %\"_ZZ1svEN3$_08__invokeEii.exit\" ], [ 0, %if.then.i.i ]\n %pgocount83056 = phi i64 [ %1, %\"_ZZ1svEN3$_08__invokeEii.exit\" ], [ 0, %if.then.i.i ]\n %pgocount93354 = phi i64 [ %2, %\"_ZZ1svEN3$_08__invokeEii.exit\" ], [ 0, %if.then.i.i ]\n br label %while.cond.while.end_crit_edge\n\nwhile.cond.while.end_crit_edge: ; preds = %3, %\"_ZZ1svEN3$_08__invokeEii.exit\"\n %pgocount51961 = phi i64 [ %pgocount51962, %3 ], [ 0, %\"_ZZ1svEN3$_08__invokeEii.exit\" ]\n %pgocount62359 = phi i64 [ %pgocount62360, %3 ], [ 0, %\"_ZZ1svEN3$_08__invokeEii.exit\" ]\n %pgocount83055 = phi i64 [ %pgocount83056, %3 ], [ %1, %\"_ZZ1svEN3$_08__invokeEii.exit\" ]\n %pgocount93353 = phi i64 [ %pgocount93354, %3 ], [ %2, %\"_ZZ1svEN3$_08__invokeEii.exit\" ]\n store i64 %pgocount51961, ptr getelementptr inbounds nuw (i8, ptr null, i64 40), align 8\n store i64 %pgocount62359, ptr getelementptr inbounds nuw (i8, ptr null, i64 48), align 8\n store i64 %pgocount83055, ptr getelementptr inbounds nuw (i8, ptr null, i64 56), align 8\n store i64 %pgocount93353, ptr getelementptr inbounds nuw (i8, ptr null, i64 64), align 8\n ret void\n}\n\n; uselistorder directives\nuselistorder ptr null, { 3, 2, 1, 0 }\n\nattributes #0 = { \"target-cpu\"=\"znver2\" }\n```\n\n```\nopt: /root/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:15064: llvm::Instruction& llvm::slpvectorizer::BoUpSLP::getLastInstructionInBundle(const llvm::slpvectorizer::BoUpSLP::TreeEntry*): Assertion `E->getOpcode() == Instruction::PHI && \"Expected PHI\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes slp-vectorizer <source>\n1.\tRunning pass \"function(slp-vectorizer)\" on module \"<source>\"\n2.\tRunning pass \"slp-vectorizer\" on function \"_Z1sv\"\n```\n\nThis is derived from the following reduced C++ code:\n\nhttps://godbolt.org/z/aqYnvnGdj\n```\nint b, a, c, d, e, g, h, i;\nint j(const char *, const char *);\nint q();\nstruct ag {\n friend bool r(ag) {\n const char *f, *k = q() ? 0 : \"\";\n f = q() ? 0 : \"\";\n return j(k, f);\n }\n} l;\nbool m;\nvoid s() {\n auto n = [](int, int) {\n if (c) {\n if (a)\n return true;\n } else if (a)\n if (d)\n if (e) {\n bool o = r(l);\n return o;\n }\n return m;\n };\n bool (*p)(int, int) = n;\n while (h)\n g = p(b, i) ?: g;\n}\n```\n\n```\nclang++: /root/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:15064: llvm::Instruction& llvm::slpvectorizer::BoUpSLP::getLastInstructionInBundle(const llvm::slpvectorizer::BoUpSLP::TreeEntry*): Assertion `E->getOpcode() == Instruction::PHI && \"Expected PHI\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O2 -fprofile-generate -march=znver2 <source>\n1.\t<eof> parser at end of file\n2.\tOptimizer\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"<source>\"\n4.\tRunning pass \"slp-vectorizer\" on function \"_Z1sv\"\n\n```",
51
+ "author": "gregbedwell",
52
+ "labels": [
53
+ "llvm:SLPVectorizer",
54
+ "crash"
55
+ ],
56
+ "comments": []
57
+ },
58
+ "verified": true
59
+ }
dataset/134013.json ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "134013",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/134013",
4
+ "bug_type": "crash",
5
+ "base_commit": "65ed35393cc8a3b896d794ab316e0357d907efff",
6
+ "knowledge_cutoff": "2025-04-02T00:52:53Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/SLPVectorizer"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "48a4b14cb65d56ec3bbb473887c31d251092c83c",
12
+ "components": [
13
+ "SLPVectorizer"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
17
+ [
18
+ 8873,
19
+ 8878
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
25
+ "BoUpSLP::buildTree_rec"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit 48a4b14cb65d56ec3bbb473887c31d251092c83c\nAuthor: Alexey Bataev <[email protected]>\nDate: Wed Apr 2 05:57:16 2025 -0700\n\n [SLP]Fix whole vector registers calculations for compares\n \n Need to check that the calculated number of the elements is not larger\n than the original number of scalars to prevent a compiler crash.\n \n Fixes #134013\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex f9284b3a5f21..838e952c024c 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -8873,6 +8873,7 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,\n // Find the number of elements, which forms full vectors.\n unsigned PWSz = getFullVectorNumberOfElements(\n *TTI, UniqueValues.front()->getType(), UniqueValues.size());\n+ PWSz = std::min<unsigned>(PWSz, VL.size());\n if (PWSz == VL.size()) {\n ReuseShuffleIndices.clear();\n } else {\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/SLPVectorizer/X86/whole-registers-compare.ll",
33
+ "commands": [
34
+ "opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-99999 < %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "<module>",
39
+ "test_body": "\ndefine void @test() {\n;\nentry:\n br label %do.body\n\ndo.body:\n %val.sroa.66.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.66.1, %do.body ]\n %val.sroa.60.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.60.2, %do.body ]\n %val.sroa.54.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.54.2, %do.body ]\n %val.sroa.48.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.48.2, %do.body ]\n %val.sroa.42.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.42.2, %do.body ]\n %val.sroa.36.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.36.2, %do.body ]\n %val.sroa.30.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.30.2, %do.body ]\n %val.sroa.24.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.24.2, %do.body ]\n %val.sroa.18.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.18.2, %do.body ]\n %val.sroa.12.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.12.2, %do.body ]\n %val.sroa.6.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.6.2, %do.body ]\n %val.sroa.0.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.0.1, %do.body ]\n %cmp119 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.6.1 = select i1 %cmp119, float 0.000000e+00, float 0.000000e+00\n %val.sroa.0.1 = select i1 %cmp119, float 0.000000e+00, float 0.000000e+00\n %cmp119.1 = fcmp uge float %val.sroa.6.1, 0.000000e+00\n %val.sroa.6.2 = select i1 %cmp119.1, float 0.000000e+00, float 0.000000e+00\n %cmp119.2 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.12.2 = select i1 %cmp119.2, float 0.000000e+00, float 0.000000e+00\n %cmp119.3 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.18.2 = select i1 %cmp119.3, float 0.000000e+00, float 0.000000e+00\n %cmp119.4 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.24.2 = select i1 %cmp119.4, float 0.000000e+00, float 0.000000e+00\n %cmp119.5 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.30.2 = select i1 %cmp119.5, float 0.000000e+00, float 0.000000e+00\n %cmp119.6 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.36.2 = select i1 %cmp119.6, float 0.000000e+00, float 0.000000e+00\n %cmp119.7 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.42.2 = select i1 %cmp119.7, float 0.000000e+00, float 0.000000e+00\n %cmp119.8 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.48.2 = select i1 %cmp119.8, float 0.000000e+00, float 0.000000e+00\n %cmp119.9 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.54.2 = select i1 %cmp119.9, float 0.000000e+00, float 0.000000e+00\n %cmp119.10 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.66.1 = select i1 %cmp119.10, float 0.000000e+00, float 0.000000e+00\n %val.sroa.60.2 = select i1 %cmp119.10, float 0.000000e+00, float 0.000000e+00\n br label %do.body\n}"
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "issue": {
45
+ "title": "crash in slp vectorizer after \"[SLP]Fix a check for the whole register use\"",
46
+ "body": "After applying [bfd8cc0a3e82](https://github.com/llvm/llvm-project/commit/bfd8cc0a3e82), I am seeing a crash in SLPVectorize.cpp.\n\nReproducer:\n```\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine <2 x float> @foo() {\nentry:\n br label %do.body\n\ndo.body: ; preds = %do.body, %entry\n %val.sroa.66.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.66.1, %do.body ]\n %val.sroa.60.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.60.2, %do.body ]\n %val.sroa.54.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.54.2, %do.body ]\n %val.sroa.48.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.48.2, %do.body ]\n %val.sroa.42.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.42.2, %do.body ]\n %val.sroa.36.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.36.2, %do.body ]\n %val.sroa.30.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.30.2, %do.body ]\n %val.sroa.24.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.24.2, %do.body ]\n %val.sroa.18.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.18.2, %do.body ]\n %val.sroa.12.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.12.2, %do.body ]\n %val.sroa.6.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.6.2, %do.body ]\n %val.sroa.0.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.0.1, %do.body ]\n %cmp119 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.6.1 = select i1 %cmp119, float 0.000000e+00, float 0.000000e+00\n %val.sroa.0.1 = select i1 %cmp119, float 0.000000e+00, float 0.000000e+00\n %cmp119.1 = fcmp uge float %val.sroa.6.1, 0.000000e+00\n %val.sroa.6.2 = select i1 %cmp119.1, float 0.000000e+00, float 0.000000e+00\n %cmp119.2 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.12.2 = select i1 %cmp119.2, float 0.000000e+00, float 0.000000e+00\n %cmp119.3 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.18.2 = select i1 %cmp119.3, float 0.000000e+00, float 0.000000e+00\n %cmp119.4 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.24.2 = select i1 %cmp119.4, float 0.000000e+00, float 0.000000e+00\n %cmp119.5 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.30.2 = select i1 %cmp119.5, float 0.000000e+00, float 0.000000e+00\n %cmp119.6 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.36.2 = select i1 %cmp119.6, float 0.000000e+00, float 0.000000e+00\n %cmp119.7 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.42.2 = select i1 %cmp119.7, float 0.000000e+00, float 0.000000e+00\n %cmp119.8 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.48.2 = select i1 %cmp119.8, float 0.000000e+00, float 0.000000e+00\n %cmp119.9 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.54.2 = select i1 %cmp119.9, float 0.000000e+00, float 0.000000e+00\n %cmp119.10 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.66.1 = select i1 %cmp119.10, float 0.000000e+00, float 0.000000e+00\n %val.sroa.60.2 = select i1 %cmp119.10, float 0.000000e+00, float 0.000000e+00\n br label %do.body\n}\n```\nCrash is occurring on [SLPVectorizer.cpp:16251](https://github.com/llvm/llvm-project/blob/ad1ca5f4a2bc09f99fd82e5444f5da37c2985e97/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp#L16251).\nAt the time `VF:12` and `Scalars.size():16`.\n",
47
+ "author": "macurtis-amd",
48
+ "labels": [
49
+ "llvm:SLPVectorizer",
50
+ "crash-on-valid"
51
+ ],
52
+ "comments": [
53
+ {
54
+ "author": "macurtis-amd",
55
+ "body": "@alexey-bataev Thanks!"
56
+ }
57
+ ]
58
+ },
59
+ "verified": true
60
+ }
dataset/134696.json ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "134696",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/134696",
4
+ "bug_type": "crash",
5
+ "base_commit": "b71123f1272ee081b18b8ced1925d6e9300e7310",
6
+ "knowledge_cutoff": "2025-04-07T17:26:23Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "995fd47944f471e985e34d7da8c0667059decbac",
12
+ "components": [
13
+ "LoopAccessAnalysis"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Analysis/LoopAccessAnalysis.cpp": [
17
+ [
18
+ 1781,
19
+ 1787
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Analysis/LoopAccessAnalysis.cpp": [
25
+ "MemoryDepChecker::couldPreventStoreLoadForward"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit 995fd47944f471e985e34d7da8c0667059decbac\nAuthor: Florian Hahn <[email protected]>\nDate: Sat Apr 12 20:05:37 2025 +0100\n\n [LAA] Make sure MaxVF for Store-Load forward safe dep distances is pow2.\n \n MaxVF computed in couldPreventStoreLoadFowrard may not be a power of 2,\n as CommonStride may not be a power-of-2.\n \n This can cause crashes after 78777a20. Use bit_floor to make sure it is\n a suitable power-of-2.\n \n Fixes https://github.com/llvm/llvm-project/issues/134696.\n\ndiff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp\nindex a37ed5c706bd..0cb1332eb337 100644\n--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp\n+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp\n@@ -1781,7 +1781,8 @@ bool MemoryDepChecker::couldPreventStoreLoadForward(uint64_t Distance,\n MaxStoreLoadForwardSafeDistanceInBits &&\n MaxVFWithoutSLForwardIssuesPowerOf2 !=\n VectorizerParams::MaxVectorWidth * TypeByteSize) {\n- uint64_t MaxVF = MaxVFWithoutSLForwardIssuesPowerOf2 / CommonStride;\n+ uint64_t MaxVF =\n+ bit_floor(MaxVFWithoutSLForwardIssuesPowerOf2 / CommonStride);\n uint64_t MaxVFInBits = MaxVF * TypeByteSize * 8;\n MaxStoreLoadForwardSafeDistanceInBits =\n std::min(MaxStoreLoadForwardSafeDistanceInBits, MaxVFInBits);\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/LoopVectorize/RISCV/safe-dep-distance.ll",
33
+ "commands": [
34
+ "opt < %s -passes=loop-vectorize -scalable-vectorization=on -riscv-v-vector-bits-min=-1 -mtriple riscv64-linux-gnu -mattr=+v,+f -S"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "safe_load_store_distance_not_pow_of_2",
39
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n64-S128\"\ntarget triple = \"riscv64\"\n\n@a = external global [10 x [12 x i16]]\n\ndefine void @safe_load_store_distance_not_pow_of_2(i64 %N) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %gep = getelementptr [10 x [12 x i16]], ptr @a, i64 0, i64 0, i64 %iv\n %0 = load i16, ptr %gep, align 2\n %gep.off = getelementptr [10 x [12 x i16]], ptr @a, i64 0, i64 8, i64 %iv\n store i16 0, ptr %gep.off, align 2\n %iv.next = add nsw i64 %iv, 3\n %cmp = icmp ult i64 %iv, %N\n br i1 %cmp, label %loop, label %exit\n\nexit: ; preds = %loop\n ret void\n}\n"
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "issue": {
45
+ "title": "[LoopVectorize] Assertion `isPowerOf2_32(End.getKnownMinValue()) && \"Expected End to be a power of 2\"' failed.",
46
+ "body": "Testcase:\n```llvm ir\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\n@a = external global [0 x [12 x i16]]\n\ndefine void @b(i64 %0) #0 {\nentry:\n br label %for.cond3.preheader\n\nfor.cond3.preheader: ; preds = %for.cond3.preheader, %entry\n %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.cond3.preheader ]\n %arrayidx9 = getelementptr [0 x [12 x i16]], ptr @a, i64 0, i64 0, i64 %indvars.iv\n %1 = load i16, ptr %arrayidx9, align 2\n %arrayidx9.2 = getelementptr [0 x [12 x i16]], ptr @a, i64 0, i64 8, i64 %indvars.iv\n store i16 0, ptr %arrayidx9.2, align 2\n %indvars.iv.next = add nsw i64 %indvars.iv, 3\n %cmp = icmp ult i64 %indvars.iv, %0\n br i1 %cmp, label %for.cond3.preheader, label %for.cond.cleanup.loopexit\n\nfor.cond.cleanup.loopexit: ; preds = %for.cond3.preheader\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+v\" }\n```\n\nCommands/backtrace\n```\n$ /scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt reduced.ll --passes=loop-vectorize\nWARNING: You're attempting to print out a bitcode file.\nThis is inadvisable as it may cause display problems. If\nyou REALLY want to taste LLVM bitcode first-hand, you\ncan force output with the `-f' option.\n\nopt: /scratch/ewlu/daily-upstream-build/llvm/llvm/lib/Transforms/Vectorize/VPlanHelpers.h:87: llvm::VFRange::VFRange(const llvm::ElementCount&, const llvm::ElementCount&): Assertion `isPowerOf2_32(End.getKnownMinValue()) && \"Expected End to be a power of 2\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0. Program arguments: /scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt reduced.ll --passes=loop-vectorize\n1. Running pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"reduced.ll\"\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"b\"\n #0 0x00005c0c5d95b1a2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x349c1a2)\n #1 0x00005c0c5d95820f llvm::sys::RunSignalHandlers() (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x349920f)\n #2 0x00005c0c5d958354 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #3 0x0000774312045330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)\n #4 0x000077431209eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #5 0x000077431209eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #6 0x000077431209eb2c pthread_kill ./nptl/pthread_kill.c:89:10\n #7 0x000077431204527e raise ./signal/../sysdeps/posix/raise.c:27:6\n #8 0x00007743120288ff abort ./stdlib/abort.c:81:7\n #9 0x000077431202881b _nl_load_domain ./intl/loadmsgcat.c:1177:9\n#10 0x000077431203b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)\n#11 0x00005c0c5c7b1baf llvm::LoopVectorizationPlanner::buildVPlansWithVPRecipes(llvm::ElementCount, llvm::ElementCount) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x22f2baf)\n#12 0x00005c0c5c7b210d llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x22f310d)\n#13 0x00005c0c5c7b4105 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x22f5105)\n#14 0x00005c0c5c7b7511 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x22f8511)\n#15 0x00005c0c5c7b7ad7 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x22f8ad7)\n#16 0x00005c0c5b484b75 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0xfc5b75)\n#17 0x00005c0c5d74633a llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x328733a)\n#18 0x00005c0c5b4872b5 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0xfc82b5)\n#19 0x00005c0c5d744c14 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x3285c14)\n#20 0x00005c0c5b483265 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0xfc4265)\n#21 0x00005c0c5d74522d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x328622d)\n#22 0x00005c0c5ac19391 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x75a391)\n#23 0x00005c0c5ac0aeac optMain (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x74beac)\n#24 0x000077431202a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3\n#25 0x000077431202a28b call_init ./csu/../csu/libc-start.c:128:20\n#26 0x000077431202a28b __libc_start_main ./csu/../csu/libc-start.c:347:5\n#27 0x00005c0c5ac014f5 _start (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x7424f5)\nAborted (core dumped)\n```\n\ngodbolt: https://godbolt.org/z/rKd5sx7xW\n\nFound via fuzzer (C program before reduction)",
47
+ "author": "ewlu",
48
+ "labels": [
49
+ "vectorizers",
50
+ "crash",
51
+ "generated by fuzzer"
52
+ ],
53
+ "comments": []
54
+ },
55
+ "verified": true
56
+ }
dataset/136430.json ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "136430",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/136430",
4
+ "bug_type": "miscompilation",
5
+ "base_commit": "1f69d6354a4b088bda5ee62c31411a75eead8b0c",
6
+ "knowledge_cutoff": "2025-04-19T13:06:10Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/InstCombine"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "a0c4876eede8e68de22dc5296b037556c7cca981",
12
+ "components": [
13
+ "InstCombine"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": [
17
+ [
18
+ 3929,
19
+ 3944
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": [
25
+ "InstCombinerImpl::visitSelectInst"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit a0c4876eede8e68de22dc5296b037556c7cca981\nAuthor: Yingwei Zheng <[email protected]>\nDate: Mon Apr 28 17:24:46 2025 +0800\n\n [InstCombine] Fix ninf propagation for fcmp+sel -> minmax (#136433)\n \n Proof: https://alive2.llvm.org/ce/z/nCrvfr\n Closes https://github.com/llvm/llvm-project/issues/136430\n\ndiff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp\nindex 5a42a5c996da..b5a40892694c 100644\n--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp\n+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp\n@@ -3929,16 +3929,20 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {\n if (match(&SI, m_OrdOrUnordFMax(m_Value(X), m_Value(Y)))) {\n Value *BinIntr =\n Builder.CreateBinaryIntrinsic(Intrinsic::maxnum, X, Y, &SI);\n- if (auto *BinIntrInst = dyn_cast<Instruction>(BinIntr))\n+ if (auto *BinIntrInst = dyn_cast<Instruction>(BinIntr)) {\n BinIntrInst->setHasNoNaNs(FCmp->hasNoNaNs());\n+ BinIntrInst->setHasNoInfs(FCmp->hasNoInfs());\n+ }\n return replaceInstUsesWith(SI, BinIntr);\n }\n \n if (match(&SI, m_OrdOrUnordFMin(m_Value(X), m_Value(Y)))) {\n Value *BinIntr =\n Builder.CreateBinaryIntrinsic(Intrinsic::minnum, X, Y, &SI);\n- if (auto *BinIntrInst = dyn_cast<Instruction>(BinIntr))\n+ if (auto *BinIntrInst = dyn_cast<Instruction>(BinIntr)) {\n BinIntrInst->setHasNoNaNs(FCmp->hasNoNaNs());\n+ BinIntrInst->setHasNoInfs(FCmp->hasNoInfs());\n+ }\n return replaceInstUsesWith(SI, BinIntr);\n }\n }\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/InstCombine/fcmp-fadd-select.ll",
33
+ "commands": [
34
+ "opt < %s -passes=instcombine -S"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "test_fcmp_ogt_fadd_select_rewrite_flags2",
39
+ "test_body": "define float @test_fcmp_ogt_fadd_select_rewrite_flags2(float %in) {\n %cmp1 = fcmp ogt float %in, 0.000000e+00\n %add = fadd float %in, 1.000000e+00\n %sel = select nnan nsz i1 %cmp1, float %add, float 1.000000e+00\n ret float %sel\n}\n"
40
+ },
41
+ {
42
+ "test_name": "test_fcmp_ogt_fadd_select_rewrite_and_fastmath",
43
+ "test_body": "define float @test_fcmp_ogt_fadd_select_rewrite_and_fastmath(float %in) {\n %cmp1 = fcmp nnan ogt float %in, 0.000000e+00\n %add = fadd nnan ninf nsz float %in, 1.000000e+00\n %sel = select nnan ninf nsz i1 %cmp1, float %add, float 1.000000e+00\n ret float %sel\n}\n"
44
+ }
45
+ ]
46
+ },
47
+ {
48
+ "file": "llvm/test/Transforms/InstCombine/minmax-fp.ll",
49
+ "commands": [
50
+ "opt -S -passes=instcombine < %s"
51
+ ],
52
+ "tests": [
53
+ {
54
+ "test_name": "maxnum_ogt_fmf_on_select",
55
+ "test_body": "define float @maxnum_ogt_fmf_on_select(float %a, float %b) {\n %cond = fcmp ogt float %a, %b\n %f = select nnan nsz i1 %cond, float %a, float %b\n ret float %f\n}\n"
56
+ },
57
+ {
58
+ "test_name": "maxnum_oge_fmf_on_select",
59
+ "test_body": "define <2 x float> @maxnum_oge_fmf_on_select(<2 x float> %a, <2 x float> %b) {\n %cond = fcmp oge <2 x float> %a, %b\n %f = select nnan ninf nsz <2 x i1> %cond, <2 x float> %a, <2 x float> %b\n ret <2 x float> %f\n}\n"
60
+ },
61
+ {
62
+ "test_name": "minnum_olt_fmf_on_select_both_ninf",
63
+ "test_body": "define float @minnum_olt_fmf_on_select_both_ninf(float %a, float %b) {\n %cond = fcmp ninf olt float %a, %b\n %f = select nnan ninf nsz i1 %cond, float %a, float %b\n ret float %f\n}\n"
64
+ },
65
+ {
66
+ "test_name": "minnum_ole_fmf_on_select",
67
+ "test_body": "define <2 x float> @minnum_ole_fmf_on_select(<2 x float> %a, <2 x float> %b) {\n %cond = fcmp ole <2 x float> %a, %b\n %f = select nnan ninf nsz <2 x i1> %cond, <2 x float> %a, <2 x float> %b\n ret <2 x float> %f\n}\n"
68
+ },
69
+ {
70
+ "test_name": "minnum_olt_fmf_on_select",
71
+ "test_body": "define float @minnum_olt_fmf_on_select(float %a, float %b) {\n %cond = fcmp olt float %a, %b\n %f = select nnan nsz i1 %cond, float %a, float %b\n ret float %f\n}\n"
72
+ },
73
+ {
74
+ "test_name": "maxnum_no_nnan",
75
+ "test_body": "define float @maxnum_no_nnan(float %a, float %b) {\n %cond = fcmp oge float %a, %b\n %f = select nsz i1 %cond, float %a, float %b\n ret float %f\n}\n"
76
+ }
77
+ ]
78
+ },
79
+ {
80
+ "file": "llvm/test/Transforms/InstCombine/unordered-fcmp-select.ll",
81
+ "commands": [
82
+ "opt -S -passes=instcombine < %s"
83
+ ],
84
+ "tests": [
85
+ {
86
+ "test_name": "select_max_ugt_2_use_cmp",
87
+ "test_body": "declare void @foo(i1)\n\ndefine float @select_max_ugt_2_use_cmp(float %a, float %b) {\n %cmp = fcmp ugt float %a, %b\n call void @foo(i1 %cmp)\n %sel = select nnan ninf nsz i1 %cmp, float %a, float %b\n ret float %sel\n}\n"
88
+ }
89
+ ]
90
+ }
91
+ ],
92
+ "issue": {
93
+ "title": "[InstCombine] ninf should not be propagated",
94
+ "body": "Reproducer: https://alive2.llvm.org/ce/z/cmneUX\n```\ndefine half @test_fcmp_select_maxnum(half %x) {\n#0:\n %cmp2 = fcmp ogt half %x, 0x5bf8\n %sel2 = select nnan ninf nsz i1 %cmp2, half %x, half 0x5bf8\n ret half %sel2\n}\n=>\ndefine half @test_fcmp_select_maxnum(half %x) {\n#0:\n %sel2 = fmax ninf nsz half %x, 0x5bf8\n ret half %sel2\n}\nTransformation doesn't verify!\n\nERROR: Target is more poisonous than source\n\nExample:\nhalf %x = #xfc00 (-oo)\n\nSource:\ni1 %cmp2 = #x0 (0)\nhalf %sel2 = #x5bf8 (255)\n\nTarget:\nhalf %sel2 = poison\nSource value: #x5bf8 (255)\nTarget value: poison\n\nSummary:\n 0 correct transformations\n 1 incorrect transformations\n 0 failed-to-prove transformations\n 0 Alive2 errors\n```",
95
+ "author": "dtcxzyw",
96
+ "labels": [
97
+ "miscompilation",
98
+ "llvm:instcombine",
99
+ "floating-point"
100
+ ],
101
+ "comments": []
102
+ },
103
+ "verified": true
104
+ }
dataset/136646.json ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "136646",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/136646",
4
+ "bug_type": "miscompilation",
5
+ "base_commit": "2ae9a74bf1421950bd404fec099b1f9998093916",
6
+ "knowledge_cutoff": "2025-04-22T02:58:58Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/InstCombine"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "3e1e4062e1e95031c32c0ed9786647ef1a4141aa",
12
+ "components": [
13
+ "InstCombine"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": [
17
+ [
18
+ 2793,
19
+ 2799
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": [
25
+ "foldSelectWithFCmpToFabs"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit 3e1e4062e1e95031c32c0ed9786647ef1a4141aa\nAuthor: Yingwei Zheng <[email protected]>\nDate: Sat Apr 26 14:03:12 2025 +0800\n\n [InstCombine] Preserve signbit semantics of NaN with fold to fabs (#136648)\n \n As per the LangRef and IEEE 754-2008 standard, the sign bit of NaN is\n preserved if there is no floating-point operation being performed.\n See also\n https://github.com/llvm/llvm-project/commit/862e35e25a68502433da0a8d0819448ff5745339\n for reference.\n \n Alive2: https://alive2.llvm.org/ce/z/QYtEGj\n Closes https://github.com/llvm/llvm-project/issues/136646\n\ndiff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp\nindex 4bba2f406b4c..5a42a5c996da 100644\n--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp\n+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp\n@@ -2793,7 +2793,14 @@ static Instruction *foldSelectWithFCmpToFabs(SelectInst &SI,\n \n // fold (X <= +/-0.0) ? (0.0 - X) : X to fabs(X), when 'Swap' is false\n // fold (X > +/-0.0) ? X : (0.0 - X) to fabs(X), when 'Swap' is true\n- if (match(TrueVal, m_FSub(m_PosZeroFP(), m_Specific(X)))) {\n+ // Note: We require \"nnan\" for this fold because fcmp ignores the signbit\n+ // of NAN, but IEEE-754 specifies the signbit of NAN values with\n+ // fneg/fabs operations.\n+ if (match(TrueVal, m_FSub(m_PosZeroFP(), m_Specific(X))) &&\n+ (cast<FPMathOperator>(CondVal)->hasNoNaNs() || SI.hasNoNaNs() ||\n+ isKnownNeverNaN(X, /*Depth=*/0,\n+ IC.getSimplifyQuery().getWithInstruction(\n+ cast<Instruction>(CondVal))))) {\n if (!Swap && (Pred == FCmpInst::FCMP_OLE || Pred == FCmpInst::FCMP_ULE)) {\n Value *Fabs = IC.Builder.CreateUnaryIntrinsic(Intrinsic::fabs, X, &SI);\n return IC.replaceInstUsesWith(SI, Fabs);\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/InstCombine/fabs.ll",
33
+ "commands": [
34
+ "opt -mtriple=x86_64-unknown-linux-gnu < %s -passes=instcombine -S"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "select_fcmp_ogt_zero",
39
+ "test_body": "define half @select_fcmp_ogt_zero(half %x) {\n %gtzero = fcmp nnan ogt half %x, 0.000000e+00\n %negx = fsub half 0.000000e+00, %x\n %fabs = select i1 %gtzero, half %x, half %negx\n ret half %fabs\n}\n"
40
+ },
41
+ {
42
+ "test_name": "select_fcmp_ole_zero_no_nnan",
43
+ "test_body": "define half @select_fcmp_ole_zero_no_nnan(half %x) {\n %lezero = fcmp ole half %x, 0.000000e+00\n %negx = fsub half 0.000000e+00, %x\n %fabs = select i1 %lezero, half %negx, half %x\n ret half %fabs\n}\n"
44
+ },
45
+ {
46
+ "test_name": "select_fcmp_nnan_ule_zero",
47
+ "test_body": "define half @select_fcmp_nnan_ule_zero(half %x) {\n %lezero = fcmp nnan ule half %x, 0.000000e+00\n %negx = fsub nnan half 0.000000e+00, %x\n %fabs = select i1 %lezero, half %negx, half %x\n ret half %fabs\n}\n"
48
+ },
49
+ {
50
+ "test_name": "select_fcmp_ole_zero_select_nnan",
51
+ "test_body": "define half @select_fcmp_ole_zero_select_nnan(half %x) {\n %lezero = fcmp ole half %x, 0.000000e+00\n %negx = fsub half 0.000000e+00, %x\n %fabs = select nnan i1 %lezero, half %negx, half %x\n ret half %fabs\n}\n"
52
+ },
53
+ {
54
+ "test_name": "select_fcmp_ole_zero",
55
+ "test_body": "define half @select_fcmp_ole_zero(half %x) {\n %lezero = fcmp nnan ole half %x, 0.000000e+00\n %negx = fsub half 0.000000e+00, %x\n %fabs = select i1 %lezero, half %negx, half %x\n ret half %fabs\n}\n"
56
+ },
57
+ {
58
+ "test_name": "select_fcmp_nnan_ogt_zero",
59
+ "test_body": "define half @select_fcmp_nnan_ogt_zero(half %x) {\n %gtzero = fcmp nnan ogt half %x, 0.000000e+00\n %negx = fsub nnan half 0.000000e+00, %x\n %fabs = select i1 %gtzero, half %x, half %negx\n ret half %fabs\n}\n"
60
+ },
61
+ {
62
+ "test_name": "select_nnan_fcmp_nnan_ole_zero",
63
+ "test_body": "define half @select_nnan_fcmp_nnan_ole_zero(half %x) {\n %lezero = fcmp nnan ole half %x, 0.000000e+00\n %negx = fsub nnan half 0.000000e+00, %x\n %fabs = select nnan i1 %lezero, half %negx, half %x\n ret half %fabs\n}\n"
64
+ },
65
+ {
66
+ "test_name": "select_fcmp_nnan_ogt_negzero",
67
+ "test_body": "define half @select_fcmp_nnan_ogt_negzero(half %x) {\n %gtzero = fcmp nnan ogt half %x, 0xH8000\n %negx = fsub nnan half 0xH0000, %x\n %fabs = select i1 %gtzero, half %x, half %negx\n ret half %fabs\n}\n"
68
+ },
69
+ {
70
+ "test_name": "select_fcmp_nnan_ugt_negzero",
71
+ "test_body": "define half @select_fcmp_nnan_ugt_negzero(half %x) {\n %gtzero = fcmp nnan ugt half %x, 0xH8000\n %negx = fsub nnan half 0xH0000, %x\n %fabs = select i1 %gtzero, half %x, half %negx\n ret half %fabs\n}\n"
72
+ },
73
+ {
74
+ "test_name": "select_nnan_fcmp_nnan_ole_negzero",
75
+ "test_body": "define <2 x float> @select_nnan_fcmp_nnan_ole_negzero(<2 x float> %x) {\n %lezero = fcmp nnan ole <2 x float> %x, splat (float -0.000000e+00)\n %negx = fsub nnan <2 x float> <float 0.000000e+00, float poison>, %x\n %fabs = select nnan <2 x i1> %lezero, <2 x float> %negx, <2 x float> %x\n ret <2 x float> %fabs\n}\n"
76
+ },
77
+ {
78
+ "test_name": "select_nnan_fcmp_nnan_ogt_negzero",
79
+ "test_body": "define half @select_nnan_fcmp_nnan_ogt_negzero(half %x) {\n %gtzero = fcmp nnan ogt half %x, 0xH8000\n %negx = fsub nnan half 0xH0000, %x\n %fabs = select nnan i1 %gtzero, half %x, half %negx\n ret half %fabs\n}\n"
80
+ },
81
+ {
82
+ "test_name": "select_fcmp_nnan_ole_zero",
83
+ "test_body": "define half @select_fcmp_nnan_ole_zero(half %x) {\n %lezero = fcmp nnan ole half %x, 0.000000e+00\n %negx = fsub nnan half 0.000000e+00, %x\n %fabs = select i1 %lezero, half %negx, half %x\n ret half %fabs\n}\n"
84
+ },
85
+ {
86
+ "test_name": "select_fcmp_nnan_ole_negzero",
87
+ "test_body": "define <2 x float> @select_fcmp_nnan_ole_negzero(<2 x float> %x) {\n %lezero = fcmp nnan ole <2 x float> %x, splat (float -0.000000e+00)\n %negx = fsub nnan <2 x float> <float 0.000000e+00, float poison>, %x\n %fabs = select <2 x i1> %lezero, <2 x float> %negx, <2 x float> %x\n ret <2 x float> %fabs\n}\n"
88
+ },
89
+ {
90
+ "test_name": "select_nnan_fcmp_nnan_ogt_zero",
91
+ "test_body": "define half @select_nnan_fcmp_nnan_ogt_zero(half %x) {\n %gtzero = fcmp nnan ogt half %x, 0.000000e+00\n %negx = fsub nnan half 0.000000e+00, %x\n %fabs = select nnan i1 %gtzero, half %x, half %negx\n ret half %fabs\n}\n"
92
+ },
93
+ {
94
+ "test_name": "select_fcmp_ole_zero_no_nnan_input_nofpclass_nan",
95
+ "test_body": "define half @select_fcmp_ole_zero_no_nnan_input_nofpclass_nan(half nofpclass(nan) %x) {\n %lezero = fcmp ole half %x, 0.000000e+00\n %negx = fsub half 0.000000e+00, %x\n %fabs = select i1 %lezero, half %negx, half %x\n ret half %fabs\n}\n"
96
+ }
97
+ ]
98
+ }
99
+ ],
100
+ "issue": {
101
+ "title": "[InstCombine] The sign bit of NaN is not preserved when folding `(X <= +/-0.0) ? (0.0 - X) : X to fabs(X)`",
102
+ "body": "Reproducer: https://alive2.llvm.org/ce/z/2JaLU9\n```\n\n----------------------------------------\ndefine half @src(half %x) {\n#0:\n %gtzero = fcmp ugt half %x, 0x0000\n %negx = fsub half 0x0000, %x\n %fabs = select i1 %gtzero, half %x, half %negx\n ret half %fabs\n}\n=>\ndefine half @src(half %x) nofree willreturn memory(none) {\n#0:\n %fabs = fabs half %x\n ret half %fabs\n}\nTransformation doesn't verify!\n\nERROR: Value mismatch\n\nExample:\nhalf %x = #xfd00 (SNaN)\n\nSource:\ni1 %gtzero = #x1 (1)\nhalf %negx = #xff00 (QNaN)\nhalf %fabs = #xfd00 (SNaN)\n\nTarget:\nhalf %fabs = #x7d00 (SNaN)\nSource value: #xfd00 (SNaN)\nTarget value: #x7d00 (SNaN)\n\nSummary:\n 0 correct transformations\n 1 incorrect transformations\n 0 failed-to-prove transformations\n 0 Alive2 errors\n```\nRelated issues:\nhttps://github.com/AliveToolkit/alive2/pull/1155\nhttps://github.com/llvm/llvm-project/issues/59279\n",
103
+ "author": "dtcxzyw",
104
+ "labels": [
105
+ "miscompilation",
106
+ "llvm:instcombine"
107
+ ],
108
+ "comments": []
109
+ },
110
+ "verified": true
111
+ }
dataset/87407.json ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "87407",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/87407",
4
+ "bug_type": "crash",
5
+ "base_commit": "980d027a3f2fbce173ad813a3f01bb51c2c2bc4b",
6
+ "knowledge_cutoff": "2024-04-02T20:25:12Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "49842426f3fc70af756f9e6fe80ecf829178a1b2",
12
+ "components": [
13
+ "LoopVectorize",
14
+ "VectorUtils"
15
+ ],
16
+ "bug_location_lineno": {
17
+ "llvm/lib/Analysis/VectorUtils.cpp": [
18
+ [
19
+ 827,
20
+ 832
21
+ ],
22
+ [
23
+ 882,
24
+ 888
25
+ ]
26
+ ],
27
+ "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
28
+ [
29
+ 1639,
30
+ 1645
31
+ ],
32
+ [
33
+ 1712,
34
+ 1718
35
+ ]
36
+ ]
37
+ },
38
+ "bug_location_funcname": {
39
+ "llvm/lib/Analysis/VectorUtils.cpp": [
40
+ "llvm::computeMinimumValueSizes"
41
+ ],
42
+ "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
43
+ "VPlanTransforms::truncateToMinimalBitwidths"
44
+ ]
45
+ }
46
+ },
47
+ "patch": "commit 49842426f3fc70af756f9e6fe80ecf829178a1b2\nAuthor: Ramkumar Ramachandra <[email protected]>\nDate: Tue Apr 29 09:47:38 2025 +0100\n\n [LV] Fix MinBWs in WidenIntrinsic case (#137005)\n \n There is a bug in the computation and handling of MinBWs in the case of\n VPWidenIntrinsicRecipe: a crash is observed in\n VPlanTransforms::truncateToMinimalBitwidths due to a mismatch between\n the number of recipes processed and the number of entries in MinBWs. Fix\n handling of calls in llvm::computeMinimumValueSizes, and handle\n VPWidenIntrinsicRecipe in truncateToMinimalBitwidths, fixing the bug.\n \n Fixes #87407.\n\ndiff --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp\nindex 6448c372f5d5..4d394ea4d99c 100644\n--- a/llvm/lib/Analysis/VectorUtils.cpp\n+++ b/llvm/lib/Analysis/VectorUtils.cpp\n@@ -827,6 +827,11 @@ llvm::computeMinimumValueSizes(ArrayRef<BasicBlock *> Blocks, DemandedBits &DB,\n if (isa<PHINode>(I))\n continue;\n \n+ // Don't modify the types of operands of a call, as doing that would cause a\n+ // signature mismatch.\n+ if (isa<CallBase>(I))\n+ continue;\n+\n if (DBits[Leader] == ~0ULL)\n // All bits demanded, no point continuing.\n continue;\n@@ -882,7 +887,9 @@ llvm::computeMinimumValueSizes(ArrayRef<BasicBlock *> Blocks, DemandedBits &DB,\n \n // If any of M's operands demand more bits than MinBW then M cannot be\n // performed safely in MinBW.\n- if (any_of(MI->operands(), [&DB, MinBW](Use &U) {\n+ auto *Call = dyn_cast<CallBase>(MI);\n+ auto Ops = Call ? Call->args() : MI->operands();\n+ if (any_of(Ops, [&DB, MinBW](Use &U) {\n auto *CI = dyn_cast<ConstantInt>(U);\n // For constants shift amounts, check if the shift would result in\n // poison.\ndiff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp\nindex 8e43d856c277..7093d378d8c3 100644\n--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp\n+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp\n@@ -1639,7 +1639,8 @@ void VPlanTransforms::truncateToMinimalBitwidths(\n vp_depth_first_deep(Plan.getVectorLoopRegion()))) {\n for (VPRecipeBase &R : make_early_inc_range(*VPBB)) {\n if (!isa<VPWidenRecipe, VPWidenCastRecipe, VPReplicateRecipe,\n- VPWidenSelectRecipe, VPWidenLoadRecipe>(&R))\n+ VPWidenSelectRecipe, VPWidenLoadRecipe, VPWidenIntrinsicRecipe>(\n+ &R))\n continue;\n \n VPValue *ResultVPV = R.getVPSingleValue();\n@@ -1712,7 +1713,7 @@ void VPlanTransforms::truncateToMinimalBitwidths(\n }\n \n assert(!isa<VPWidenStoreRecipe>(&R) && \"stores cannot be narrowed\");\n- if (isa<VPWidenLoadRecipe>(&R))\n+ if (isa<VPWidenLoadRecipe, VPWidenIntrinsicRecipe>(&R))\n continue;\n \n // Shrink operands by introducing truncates as needed.\n",
48
+ "tests": [
49
+ {
50
+ "file": "llvm/test/Transforms/LoopVectorize/pr87407-trunc-with-intrinsic.ll",
51
+ "commands": [
52
+ "opt -passes=loop-vectorize -force-vector-width=4 -S %s"
53
+ ],
54
+ "tests": [
55
+ {
56
+ "test_name": "<module>",
57
+ "test_body": "\ndefine i8 @pr87407(i8 %x, i64 %y, i64 %n) {\n;\nentry:\n %zext.x = zext i8 %x to i64\n br label %loop\n\nloop:\n %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]\n %max = tail call i64 @llvm.umax.i64(i64 %zext.x, i64 %y)\n %cmp.max.0 = icmp ne i64 %max, 0\n %zext.cmp = zext i1 %cmp.max.0 to i64\n %trunc = trunc i64 %zext.cmp to i32\n %shl = shl i32 %trunc, 8\n %res = trunc i32 %shl to i8\n %iv.next = add i64 %iv, 1\n %exit.cond = icmp ne i64 %iv.next, %n\n br i1 %exit.cond, label %loop, label %exit\n\nexit:\n ret i8 %res\n}"
58
+ }
59
+ ]
60
+ }
61
+ ],
62
+ "issue": {
63
+ "title": "[LoopVectorize][VPlan] Assertion `MinBWs.size() == NumProcessedRecipes && \"some entries in MinBWs haven't been processed\"' failed.",
64
+ "body": "Reduced LLVM IR:\r\n``` llvm ir\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine i32 @main() #0 {\r\nentry:\r\n %conv21.us.i = sext i16 0 to i32\r\n br label %for.cond3.preheader.us.i\r\n\r\nfor.cond3.preheader.us.i: ; preds = %for.cond3.preheader.us.i, %entry\r\n %indvars.iv.i = phi i64 [ %indvars.iv.next.i, %for.cond3.preheader.us.i ], [ 0, %entry ]\r\n %add67.lcssa7984.us.i = phi i8 [ %2, %for.cond3.preheader.us.i ], [ 0, %entry ]\r\n %.conv21.us99.i = tail call i32 @llvm.smax.i32(i32 0, i32 %conv21.us.i)\r\n %cmp35.us100.i = icmp eq i32 %.conv21.us99.i, 0\r\n %conv36.us101.i = zext i1 %cmp35.us100.i to i32\r\n %0 = lshr i32 %conv36.us101.i, 1\r\n %1 = trunc i32 %0 to i8\r\n %2 = or i8 %add67.lcssa7984.us.i, %1\r\n %indvars.iv.next.i = add i64 %indvars.iv.i, 1\r\n %cmp.us.i = icmp slt i64 %indvars.iv.i, 1\r\n br i1 %cmp.us.i, label %for.cond3.preheader.us.i, label %for.cond.for.cond.cleanup_crit_edge.split.us.i\r\n\r\nfor.cond.for.cond.cleanup_crit_edge.split.us.i: ; preds = %for.cond3.preheader.us.i\r\n store i8 %2, ptr null, align 1\r\n ret i32 0\r\n}\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\r\ndeclare i32 @llvm.smax.i32(i32, i32) #1\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\r\nattributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\r\n```\r\n\r\nBacktrace:\r\n```\r\nopt: /scratch/tc-testing/tc-apr-2/llvm/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp:1061: static void llvm::VPlanTransforms::truncateToMinimalBitwidths(llvm::VPlan&, const llvm::MapVector<llvm::Instruction*, long unsigned int>&, llvm\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt --passes=loop-vectorize reduced.ll\r\n #0 0x0000596ae80c5b60 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2d84b60)\r\n #1 0x0000596ae80c2f6f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2d81f6f)\r\n #2 0x0000596ae80c30c5 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007a0a45642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007a0a456969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007a0a456969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007a0a456969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x00007a0a45642476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007a0a456287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x00007a0a4562871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x00007a0a45639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x0000596ae7260af2 llvm::VPlanTransforms::truncateToMinimalBitwidths(llvm::VPlan&, llvm::MapVector<llvm::Instruction*, unsigned long, llvm::DenseMap<llvm::Instruction*, unsigned int, llvm::DenseMapInfo<llvm::Instruction*, void>, llvm::detail::DenseMapPair<llvm::Instruction*, unsigned int>>, llvm::SmallVector<std::pair<llvm::Instruction*, unsigned long>, 0u>> const&, llvm::LLVMContext&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1f1faf2)\r\n#12 0x0000596ae7135f3e llvm::LoopVectorizationPlanner::buildVPlansWithVPRecipes(llvm::ElementCount, llvm::ElementCount) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1df4f3e)\r\n#13 0x0000596ae713c319 llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1dfb319)\r\n#14 0x0000596ae713f8a9 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1dfe8a9)\r\n#15 0x0000596ae714273e llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1e0173e)\r\n#16 0x0000596ae714388d llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1e0288d)\r\n#17 0x0000596ae604a276 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0xd09276)\r\n#18 0x0000596ae7eec141 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2bab141)\r\n#19 0x0000596ae6041bd6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0xd00bd6)\r\n#20 0x0000596ae7eeae3b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2ba9e3b)\r\n#21 0x0000596ae6049dc6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0xd08dc6)\r\n#22 0x0000596ae7ee8cb1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2ba7cb1)\r\n#23 0x0000596ae58c3ce5 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x582ce5)\r\n#24 0x0000596ae58b6316 optMain (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x575316)\r\n#25 0x00007a0a45629d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#26 0x00007a0a45629e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#27 0x00007a0a45629e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#28 0x0000596ae58abf95 _start (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x56af95)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt\r\n```\r\n\r\nGodbolt: https://godbolt.org/z/6TxWGMz6e\r\n\r\nAssert: https://github.com/llvm/llvm-project/blob/c403a478076a16172d9b50e16c288b0d360f42ce/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp#L1061-L1063\r\n\r\nFound via fuzzer.",
65
+ "author": "patrick-rivos",
66
+ "labels": [
67
+ "vectorizers",
68
+ "crash"
69
+ ],
70
+ "comments": [
71
+ {
72
+ "author": "patrick-rivos",
73
+ "body": "Partially cleaned up testcase:\r\n```llvm ir\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine i32 @main() #0 {\r\nentry:\r\n %sext.0 = sext i16 0 to i32\r\n br label %loop.preheader\r\n\r\nloop.preheader: ; preds = %loop.preheader, %entry\r\n %iv.i = phi i64 [ %iv.next.i, %loop.preheader ], [ 0, %entry ]\r\n %phi.0 = phi i8 [ %or.0, %loop.preheader ], [ 0, %entry ]\r\n %max.0 = tail call i32 @llvm.smax.i32(i32 0, i32 %sext.0)\r\n %cmp = icmp eq i32 %max.0, 0\r\n %zext.true = zext i1 %cmp to i32\r\n %0 = lshr i32 %zext.true, 1\r\n %1 = trunc i32 %0 to i8\r\n %or.0 = or i8 %phi.0, %1\r\n %iv.next.i = add i64 %iv.i, 1\r\n %cmp.us.i = icmp slt i64 %iv.i, 1\r\n br i1 %cmp.us.i, label %loop.preheader, label %loop.exit\r\n\r\nloop.exit: ; preds = %loop.preheader\r\n store i8 %or.0, ptr null, align 1\r\n ret i32 0\r\n}\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\r\ndeclare i32 @llvm.smax.i32(i32, i32) #1\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\r\n```\r\n\r\nBasic analysis:\r\n\r\nThe issue is caused by:\r\nhttps://github.com/llvm/llvm-project/blob/39bfdb7f33f7f53ab662c5cea25129c45a9b4c11/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp#L1074-L1076\r\nwhen `%sext.0 = sext i16 0 to i32` is the only unaccounted for MinBWs entry.\r\n\r\n`Op->getLiveInIRValue()` returns a _Constant_ `i32 0`, so the dynamic cast to _Instruction_ returns a null pointer which does not exist in MinBWs.\r\n\r\nI think the _Constant_ is an optimized `sext i16 0 to i32` so I'll try to find where the constant comes from next."
74
+ },
75
+ {
76
+ "author": "patrick-rivos",
77
+ "body": "Alright I _think_ I understand everything that's going on here\r\n\r\nUsing this testcase:\r\n```llvm ir\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\n\r\ndefine i32 @main() #1 {\r\nentry:\r\n %zext.0 = zext i8 0 to i64\r\n br label %loop\r\n\r\nloop: ; preds = %loop, %entry\r\n %phi.0 = phi i64 [ %incrementor, %loop ], [ 0, %entry ]\r\n %incrementor = add i64 %phi.0, 1\r\n %max.0 = tail call i64 @llvm.umax.i64(i64 %zext.0, i64 0)\r\n %cmp.0 = icmp ne i64 %max.0, 0\r\n %zext.1 = zext i1 %cmp.0 to i64\r\n %trunc.0 = trunc i64 %zext.1 to i32\r\n %shl.0 = shl i32 %trunc.0, 8 ; Truncate and shift to make all bits dead\r\n %trunc.1 = trunc i32 %shl.0 to i8\r\n %exitcond6 = icmp ne i64 %phi.0, 16\r\n br i1 %exitcond6, label %loop, label %loop.exit\r\n\r\nloop.exit: ; preds = %loop\r\n store i8 %trunc.1, ptr null, align 1\r\n ret i32 0\r\n}\r\n\r\nattributes #1 = { \"target-features\"=\"+v\" }\r\n```\r\n\r\ncomputeMinimumValueSizes operates on a region, but a chain terminated with one instruction outside the bounds of the region is still considered valid. This compounded with weirdness with WIDEN-CALL causes issues in truncateToMinimalBitwidths where this range is considered:\r\n```\r\n<x1> vector loop: {\r\n vector.body:\r\n EMIT vp<%2> = CANONICAL-INDUCTION ir<0>, vp<%3>\r\n WIDEN-INDUCTION %phi.0 = phi %incrementor, 0, ir<1>\r\n CLONE ir<%incrementor> = add ir<%phi.0>, ir<1>\r\n WIDEN-CALL ir<%max.0> = call @llvm.umax.i64(ir<%zext.0>, ir<0>) (using vector intrinsic)\r\n WIDEN ir<%cmp.0> = icmp ne ir<%max.0>, ir<0>\r\n WIDEN-CAST ir<%zext.1> = zext ir<%cmp.0> to i64\r\n WIDEN-CAST ir<%trunc.0> = trunc ir<%zext.1> to i32\r\n WIDEN ir<%shl.0> = shl ir<%trunc.0>, ir<8>\r\n WIDEN-CAST ir<%trunc.1> = trunc ir<%shl.0> to i8\r\n CLONE ir<%exitcond6> = icmp ne ir<%phi.0>, ir<16>\r\n Successor(s):\r\n\r\n :\r\n Successor(s): vector.latch\r\n\r\n vector.latch:\r\n EMIT vp<%3> = add nuw vp<%2>, vp<%0>\r\n EMIT branch-on-count vp<%3>, vp<%1>\r\n No successors\r\n}\r\nSuccessor(s): middle.block\r\n```\r\n\r\nThe MinBWs are:\r\n```\r\n%cmp.0 = icmp ne i64 %max.0, 0 Size: 1\r\n%zext.0 = zext i8 0 to i64 Size: 1\r\n```\r\n\r\ncomp.0 is found easily but zext.0 isn't in the region. Normally chains outside the region are handled\r\nby [this](https://github.com/llvm/llvm-project/blob/eae7554d3f1fb1546c629a9a2ae0654b1001ab41/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp#L1056) which pulls in arguments.\r\n\r\nWe don't consider WIDEN-CALL since it doesn't have an [entry in MinBW](https://github.com/llvm/llvm-project/blob/eae7554d3f1fb1546c629a9a2ae0654b1001ab41/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp#L984-L986) (and isn't [allowed](https://github.com/llvm/llvm-project/blob/eae7554d3f1fb1546c629a9a2ae0654b1001ab41/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp#L978-L979)).\r\nIt doesn't have an entry since the function call uses a ptr which cannot be truncated so [that op fails to truncate](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Analysis/VectorUtils.cpp#L682-L693).\r\n\r\nDemandedBits understands a [subset of all intrinsics](https://github.com/llvm/llvm-project/blob/49bb993959668b3f319e9ea5fa0c97a41ab0890e/llvm/lib/Analysis/DemandedBits.cpp#L87-L149) while VPlanAnalysis doesn't handle any of them (for the pointer reason).\r\n\r\n## Fix\r\n\r\nThis can be fixed by ignoring the call function pointer argument for all intrinsic cases that DemandedBits handles.\r\n\r\nVPWidenCallRecipe also needs a way to specify a new return type when executed so I added getResultType and setResultType methods.\r\n\r\nI'll submit a PR soon.\r\n"
78
+ }
79
+ ]
80
+ },
81
+ "verified": true
82
+ }
scripts/extract_from_issues.py CHANGED
@@ -34,7 +34,7 @@ session.headers.update(
34
  )
35
 
36
  issue_id_begin = 76663 # Since 2024-01-01
37
- issue_id_end = 137922
38
 
39
 
40
  def wait(progress):
 
34
  )
35
 
36
  issue_id_begin = 76663 # Since 2024-01-01
37
+ issue_id_end = 138449
38
 
39
 
40
  def wait(progress):
scripts/postfix_extract.py CHANGED
@@ -128,11 +128,13 @@ fix_commit_map = {
128
  "130082": None, # Non-deterministic bug
129
  "130632": None, # Reverts #108535
130
  "131355": None, # Non-deterministic bug
 
131
  "134411": None, # Reverted
132
  "135113": None, # Not supported by Alive2
133
  "135410": None, # Cannot reproduce with Alive2
134
  "135531": None, # Cannot reproduce with Alive2
135
  "137164": None, # Cannot reproduce the crash as it requires llvm to build with hardened libc++
 
136
  }
137
 
138
  if issue_id in fix_commit_map:
 
128
  "130082": None, # Non-deterministic bug
129
  "130632": None, # Reverts #108535
130
  "131355": None, # Non-deterministic bug
131
+ "133984": None, # Not supported by Alive2
132
  "134411": None, # Reverted
133
  "135113": None, # Not supported by Alive2
134
  "135410": None, # Cannot reproduce with Alive2
135
  "135531": None, # Cannot reproduce with Alive2
136
  "137164": None, # Cannot reproduce the crash as it requires llvm to build with hardened libc++
137
+ "138178": None, # Cannot reproduce the crash as it requires llvm to build with hardened libc++
138
  }
139
 
140
  if issue_id in fix_commit_map: