Datasets:

Modalities:
Text
Formats:
json
Size:
< 1K
Tags:
code
DOI:
Libraries:
Datasets
pandas
License:
dtcxzyw commited on
Commit
3588ce3
·
1 Parent(s): 27f15f9
dataset.jsonl CHANGED
The diff for this file is too large to render. See raw diff
 
dataset/115744.json ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "115744",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/115744",
4
+ "bug_type": "crash",
5
+ "base_commit": "28002dd50fb7ec97da1770a11f9c6a99dd9aecb9",
6
+ "knowledge_cutoff": "2024-11-11T17:12:17Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "8009c1fd81ad0b6ac65724d2b134a92db48f8fbf",
12
+ "components": [
13
+ "LoopVectorize"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
17
+ [
18
+ 7291,
19
+ 7297
20
+ ],
21
+ [
22
+ 7311,
23
+ 7317
24
+ ]
25
+ ]
26
+ },
27
+ "bug_location_funcname": {
28
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
29
+ "LoopVectorizationPlanner::precomputeCosts"
30
+ ]
31
+ }
32
+ },
33
+ "patch": "commit 8009c1fd81ad0b6ac65724d2b134a92db48f8fbf\nAuthor: Elvis Wang <[email protected]>\nDate: Tue Feb 25 11:09:09 2025 +0800\n\n [LV][VPlan] Prevent calculate cost for skiped instructions in precomputeCosts(). (#127966)\n \n Skip calculating instruction costs for exit conditions in\n precomputeCosts() when it should be skipped.\n \n Reported from:\n https://github.com/llvm/llvm-project/issues/115744#issuecomment-2670479463\n Godbolt for reduced test cases: https://godbolt.org/z/fr4YMeqcv\n\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\nindex 4d2df9179aa3..0bf2d71a63ef 100644\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n@@ -7291,7 +7291,7 @@ LoopVectorizationPlanner::precomputeCosts(VPlan &Plan, ElementCount VF,\n // Collect all exit conditions.\n for (BasicBlock *EB : Exiting) {\n auto *Term = dyn_cast<BranchInst>(EB->getTerminator());\n- if (!Term)\n+ if (!Term || CostCtx.skipCostComputation(Term, VF.isVector()))\n continue;\n if (auto *CondI = dyn_cast<Instruction>(Term->getOperand(0))) {\n ExitInstrs.insert(CondI);\n@@ -7311,7 +7311,8 @@ LoopVectorizationPlanner::precomputeCosts(VPlan &Plan, ElementCount VF,\n Cost += CondICost;\n for (Value *Op : CondI->operands()) {\n auto *OpI = dyn_cast<Instruction>(Op);\n- if (!OpI || any_of(OpI->users(), [&ExitInstrs, this](User *U) {\n+ if (!OpI || CostCtx.skipCostComputation(OpI, VF.isVector()) ||\n+ any_of(OpI->users(), [&ExitInstrs, this](User *U) {\n return OrigLoop->contains(cast<Instruction>(U)->getParent()) &&\n !ExitInstrs.contains(cast<Instruction>(U));\n }))\n",
34
+ "tests": [
35
+ {
36
+ "file": "llvm/test/Transforms/LoopVectorize/X86/cost-model.ll",
37
+ "commands": [
38
+ "opt < %s -passes=loop-vectorize -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7-avx -S"
39
+ ],
40
+ "tests": [
41
+ {
42
+ "test_name": "g",
43
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-apple-macosx10.8.0\"\n\ndefine i32 @g(i64 %n) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %select = phi i32 [ 0, %entry ], [ %select.next, %loop ]\n %iv.widen = zext i32 %iv to i64\n %exitcond = icmp eq i64 %n, %iv.widen\n %select.i = select i1 %exitcond, i32 0, i32 2\n %select.next = or i32 %select.i, %select\n %iv.next = add i32 %iv, 1\n br i1 %exitcond, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i32 %select.next\n}\n"
44
+ }
45
+ ]
46
+ }
47
+ ],
48
+ "issue": {
49
+ "title": "[VPlan] Assertion \"VPlan cost model and legacy cost model disagreed\"' failed.",
50
+ "body": "C program:\r\n```c\r\nsigned char a;\r\nshort b;\r\nint c, g;\r\nlong d, e, f;\r\nvoid h(long i[][2], long j[][2][2], short k[][2]) {\r\n for (unsigned l = g; l; l += 4) {\r\n a *= (signed char)((f ? 0 : k[l][l]) ?: (_Bool)(d << j[8][l][e]) ? i[l][l] : c);\r\n b = ~i[e][l];\r\n }\r\n}\r\n```\r\n`/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/clang -march=rv64gcv -O3 red.c -o rv64gcv.bc -w -emit-llvm -c`\r\n\r\nLLVM IR:\r\n```llvm ir\r\n; ModuleID = 'reduced.bc'\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 void @h(ptr %i, ptr %k, i64 %idxprom.us) #0 {\r\nentry:\r\n br label %for.body.us\r\n\r\nfor.body.us: ; preds = %cond.end23.us, %entry\r\n %l.046.us = phi i32 [ %add.us, %cond.end23.us ], [ 0, %entry ]\r\n %conv284345.us = phi i8 [ %conv28.us, %cond.end23.us ], [ 0, %entry ]\r\n %idxprom.us1 = zext i32 %l.046.us to i64\r\n %arrayidx3.us = getelementptr [2 x i16], ptr %k, i64 %idxprom.us1, i64 %idxprom.us\r\n %0 = load i16, ptr %arrayidx3.us, align 2\r\n %tobool4.not.us = icmp eq i16 %0, 0\r\n br i1 %tobool4.not.us, label %cond.false7.us, label %cond.end23.us\r\n\r\ncond.false7.us: ; preds = %for.body.us\r\n %1 = load i64, ptr %i, align 8\r\n %shl.us = shl i64 0, %1\r\n %tobool12.not.us = icmp eq i64 %shl.us, 0\r\n br i1 %tobool12.not.us, label %cond.end23.us, label %cond.true14.us\r\n\r\ncond.true14.us: ; preds = %cond.false7.us\r\n %2 = load i64, ptr %i, align 8\r\n %3 = trunc i64 %2 to i32\r\n br label %cond.end23.us\r\n\r\ncond.end23.us: ; preds = %cond.true14.us, %cond.false7.us, %for.body.us\r\n %cond24.us = phi i32 [ %3, %cond.true14.us ], [ 0, %for.body.us ], [ 0, %cond.false7.us ]\r\n %4 = trunc i32 %cond24.us to i8\r\n %conv28.us = mul i8 0, %4\r\n %arrayidx31.us = getelementptr [2 x i64], ptr %i, i64 0, i64 %idxprom.us1\r\n %5 = load i64, ptr %arrayidx31.us, align 8\r\n %6 = trunc i64 %5 to i16\r\n %conv32.us = xor i16 %6, 0\r\n store i16 %conv32.us, ptr null, align 2\r\n %add.us = add i32 %l.046.us, 4\r\n %tobool.not.us = icmp eq i32 %add.us, 0\r\n br i1 %tobool.not.us, label %for.cond.for.cond.cleanup_crit_edge, label %for.body.us\r\n\r\nfor.cond.for.cond.cleanup_crit_edge: ; preds = %cond.end23.us\r\n store i8 %4, ptr null, align 1\r\n ret void\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-b,-e,-experimental-smctr,-experimental-ssctr,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-experimental-zvbc32e,-experimental-zvkgs,-h,-sha,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smdbltrp,-smepmp,-smmpm,-smnpm,-smrnmi,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssdbltrp,-ssnpm,-sspm,-ssqosid,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-supm,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-svvptc,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zaamo,-zabha,-zacas,-zalrsc,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-ztso,-zvbb,-zvbc,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\n```\r\n\r\nCommand/backtrace:\r\n```\r\n> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt --passes \"loop-vectorize\" reduced.ll -f\r\nopt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7522: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop) || planContainsAdditionalSimplifications(getPlanFor(LegacyVF.Width), CostCtx, OrigLoop)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\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-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt --passes loop-vectorize reduced.ll -f\r\n1. Running pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"reduced.ll\"\r\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"h\"\r\n #0 0x000062cc6ec1de70 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x319de70)\r\n #1 0x000062cc6ec1b27f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x319b27f)\r\n #2 0x000062cc6ec1b3d5 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x000074efe9a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x000074efe9a969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x000074efe9a969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x000074efe9a969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x000074efe9a42476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x000074efe9a287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x000074efe9a2871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x000074efe9a39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x000062cc6db65039 llvm::LoopVectorizationPlanner::computeBestVF() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20e5039)\r\n#12 0x000062cc6db7c50c llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20fc50c)\r\n#13 0x000062cc6db7f1e1 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20ff1e1)\r\n#14 0x000062cc6db7f857 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20ff857)\r\n#15 0x000062cc6c963a06 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xee3a06)\r\n#16 0x000062cc6ea24b0f llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2fa4b0f)\r\n#17 0x000062cc6c966b96 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-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xee6b96)\r\n#18 0x000062cc6ea22e9b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2fa2e9b)\r\n#19 0x000062cc6c962ac6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xee2ac6)\r\n#20 0x000062cc6ea239fd llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2fa39fd)\r\n#21 0x000062cc6c15c33d 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-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x6dc33d)\r\n#22 0x000062cc6c14e1c1 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x6ce1c1)\r\n#23 0x000074efe9a29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#24 0x000074efe9a29e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#25 0x000074efe9a29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#26 0x000062cc6c144725 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x6c4725)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\n\r\nGodbolt: https://godbolt.org/z/v5K5Wbxcn\r\n\r\nFound via fuzzer\r\n\r\ncc @fhahn ",
51
+ "author": "patrick-rivos",
52
+ "labels": [
53
+ "release:backport",
54
+ "vectorizers",
55
+ "crash"
56
+ ],
57
+ "comments": [
58
+ {
59
+ "author": "patrick-rivos",
60
+ "body": "Bisected to b3edc764f70f4e56807af60abdcfbef4dbdc5d95\r\ncc @ElvisWang123 "
61
+ },
62
+ {
63
+ "author": "ElvisWang123",
64
+ "body": "> Bisected to [b3edc76](https://github.com/llvm/llvm-project/commit/b3edc764f70f4e56807af60abdcfbef4dbdc5d95) cc @ElvisWang123\r\n\r\nI will take a look."
65
+ },
66
+ {
67
+ "author": "ElvisWang123",
68
+ "body": "The main difference of this case is that \r\n`LV: Found an estimated cost of 3 for VF vscale x 2 For instruction: %3 = trunc i64 %2 to i32` from legacy cost model and `Cost of 1 for VF vscale x 2: WIDEN-CAST ir<%3> = trunc ir<%2> to i32` from VPlan-based cost model.\r\n\r\nLegacy cost model will consider the new type after MinBW by `canTruncateToMinimalBitwidth()`. And finds that `i32` can further truncate to `i8`. So the legacy cost model will calculate the cost from `i64` to `i8`.\r\n But in the VPTransforms, the result type of this recipe cannot be shrunk from `i32` to `i8`. So the final recipes will only calculate the cost from `i64` to `i32`.\r\n\r\nI think this might be the MinBW transformation issue which cannot further truncate the type.\r\n\r\nBTW, the cost from the VPlan-based cost model is closer to the generated vector loop.\r\n\r\nSome cost model information:\r\nLegacy cost\r\n```\r\nLV: Found an estimated cost of 0 for VF vscale x 2 For instruction: %l.046.us = phi i32 [ %add.us, %cond.end23.us ], [ 0, %entry ]\r\nLV: Found an estimated cost of 2 for VF vscale x 2 For instruction: %conv284345.us = phi i8 [ %conv28.us, %cond.end23.us ], [ 0, %entr\r\ny ]\r\nLV: Found an estimated cost of 2 for VF vscale x 2 For instruction: %idxprom.us1 = zext i32 %l.046.us to i64\r\nLV: Found an estimated cost of 0 for VF vscale x 2 For instruction: %arrayidx3.us = getelementptr [2 x i16], ptr %k, i64 %idxprom.us1,\r\n i64 %idxprom.us\r\nLV: Found an estimated cost of 4 for VF vscale x 2 For instruction: %0 = load i16, ptr %arrayidx3.us, align 2\r\nLV: Found an estimated cost of 1 for VF vscale x 2 For instruction: %tobool4.not.us = icmp eq i16 %0, 0\r\nLV: Found an estimated cost of 0 for VF vscale x 2 For instruction: br i1 %tobool4.not.us, label %cond.false7.us, label %cond.end23.us\r\nLV: Found an estimated cost of 4 for VF vscale x 2 For instruction: %1 = load i64, ptr %i, align 8\r\nLV: Found an estimated cost of 2 for VF vscale x 2 For instruction: %shl.us = shl i64 0, %1\r\nLV: Found an estimated cost of 2 for VF vscale x 2 For instruction: %tobool12.not.us = icmp eq i64 %shl.us, 0\r\nLV: Found an estimated cost of 0 for VF vscale x 2 For instruction: br i1 %tobool12.not.us, label %cond.end23.us, label %cond.true14.u\r\ns\r\nLV: Found an estimated cost of 4 for VF vscale x 2 For instruction: %2 = load i64, ptr %i, align 8\r\n====> LV: Found an estimated cost of 3 for VF vscale x 2 For instruction: %3 = trunc i64 %2 to i32 <=====\r\nLV: Found an estimated cost of 0 for VF vscale x 2 For instruction: br label %cond.end23.us\r\nLV: Found an estimated cost of 2 for VF vscale x 2 For instruction: %cond24.us = phi i32 [ %3, %cond.true14.us ], [ 0, %for.body.us ],\r\n [ 0, %cond.false7.us ]\r\nLV: Found an estimated cost of 2 for VF vscale x 2 For instruction: %4 = trunc i32 %cond24.us to i8\r\nLV: Found an estimated cost of 1 for VF vscale x 2 For instruction: %conv28.us = mul i8 0, %4\r\nLV: Found an estimated cost of 0 for VF vscale x 2 For instruction: %arrayidx31.us = getelementptr [2 x i64], ptr %i, i64 0, i64 %idxp\r\nrom.us1\r\nLV: Found an estimated cost of 4 for VF vscale x 2 For instruction: %5 = load i64, ptr %arrayidx31.us, align 8\r\nLV: Found an estimated cost of 2 for VF vscale x 2 For instruction: %6 = trunc i64 %5 to i16\r\nLV: Found an estimated cost of 1 for VF vscale x 2 For instruction: %conv32.us = xor i16 %6, 0\r\nLV: Found an estimated cost of 3 for VF vscale x 2 For instruction: store i16 %conv32.us, ptr null, align 2\r\nLV: Found an estimated cost of 1 for VF vscale x 2 For instruction: %add.us = add i32 %l.046.us, 4\r\nLV: Found an estimated cost of 1 for VF vscale x 2 For instruction: %tobool.not.us = icmp eq i32 %add.us, 0\r\nLV: Found an estimated cost of 0 for VF vscale x 2 For instruction: br i1 %tobool.not.us, label %for.cond.for.cond.cleanup_crit_edge, \r\nlabel %for.body.us\r\nLV: Vector loop of width vscale x 2 costs: 10 (assuming a minimum vscale of 2).\r\n```\r\n\r\nVPlan-based\r\n```\r\nCost of 1 for VF vscale x 2: induction instruction %add.us = add i32 %l.046.us, 4\r\nCost of 0 for VF vscale x 2: induction instruction %l.046.us = phi i32 [ %add.us, %cond.end23.us ], [ 0, %entry ]\r\nCost of 1 for VF vscale x 2: exit condition instruction %tobool.not.us = icmp eq i32 %add.us, 0\r\nCost of 0 for VF vscale x 2: EMIT vp<%3> = CANONICAL-INDUCTION ir<0>, vp<%index.next>\r\nCost of 0 for VF vscale x 2: WIDEN-INDUCTION %l.046.us = phi %add.us, 0, ir<4>, vp<%0>\r\nCost of 2 for VF vscale x 2: FIRST-ORDER-RECURRENCE-PHI ir<%conv284345.us> = phi ir<0>, ir<%conv28.us>\r\nCost of 2 for VF vscale x 2: WIDEN-CAST ir<%idxprom.us1> = zext ir<%l.046.us> to i64\r\nCost of 0 for VF vscale x 2: WIDEN-GEP Inv[Var][Inv] ir<%arrayidx3.us> = getelementptr ir<%k>, ir<%idxprom.us1>, ir<%idxprom.us>\r\nCost of 4 for VF vscale x 2: WIDEN ir<%0> = load ir<%arrayidx3.us>\r\nCost of 1 for VF vscale x 2: WIDEN ir<%tobool4.not.us> = icmp eq ir<%0>, ir<0>\r\nCost of 4 for VF vscale x 2: WIDEN ir<%1> = load ir<%i>, ir<%tobool4.not.us>\r\nCost of 2 for VF vscale x 2: WIDEN ir<%shl.us> = shl ir<0>, ir<%1>\r\nCost of 2 for VF vscale x 2: WIDEN ir<%tobool12.not.us> = icmp eq ir<%shl.us>, ir<0>\r\nCost of 0 for VF vscale x 2: EMIT vp<%4> = not ir<%tobool12.not.us>\r\nCost of 0 for VF vscale x 2: EMIT vp<%5> = logical-and ir<%tobool4.not.us>, vp<%4>\r\nCost of 4 for VF vscale x 2: WIDEN ir<%2> = load ir<%i>, vp<%5>\r\n====> Cost of 1 for VF vscale x 2: WIDEN-CAST ir<%3> = trunc ir<%2> to i32 <=======\r\nCost of 0 for VF vscale x 2: EMIT vp<%6> = not ir<%tobool4.not.us>\r\nCost of 2 for VF vscale x 2: BLEND ir<%cond24.us> = ir<0> ir<%3>/vp<%5> ir<0>/vp<%6>\r\nCost of 2 for VF vscale x 2: WIDEN-CAST ir<%4> = trunc ir<%cond24.us> to i8\r\nCost of 1 for VF vscale x 2: WIDEN ir<%conv28.us> = mul ir<0>, ir<%4>\r\nCost of 0 for VF vscale x 2: WIDEN-GEP Inv[Inv][Var] ir<%arrayidx31.us> = getelementptr ir<%i>, ir<0>, ir<%idxprom.us1>\r\nCost of 4 for VF vscale x 2: WIDEN ir<%5> = load ir<%arrayidx31.us>\r\nCost of 2 for VF vscale x 2: WIDEN-CAST ir<%6> = trunc ir<%5> to i16\r\nCost of 1 for VF vscale x 2: WIDEN ir<%conv32.us> = xor ir<%6>, ir<0>\r\nCost of 3 for VF vscale x 2: REPLICATE store ir<%conv32.us>, ir<null>\r\nCost of 0 for VF vscale x 2: EMIT vp<%index.next> = add nuw vp<%3>, vp<%1>\r\nCost of 0 for VF vscale x 2: EMIT branch-on-count vp<%index.next>, vp<%2>\r\nCost of 0 for VF vscale x 2: vector loop backedge\r\nCost for VF vscale x 2: 39\r\n```\r\nGenerated vector.body\r\n``` \r\nvector.body: ; preds = %vector.body, %vector.ph\r\n %index = phi i32 [ 0, %vector.ph ]\r\n %vec.ind = phi <vscale x 2 x i32> [ %induction, %vector.ph ], [ %vec.ind.next, %vector.ph ]\r\n %vector.recur = phi <vscale x 2 x i8> [ %vector.recur.init, %vector.ph ]\r\n %vec.ind.next = add <vscale x 2 x i32> %vec.ind, %.splat\r\n %15 = zext <vscale x 2 x i32> %vec.ind to <vscale x 2 x i64>\r\n %16 = getelementptr [2 x i16], ptr %k, <vscale x 2 x i64> %15, i64 %idxprom.us\r\n %wide.masked.gather = call <vscale x 2 x i16> @llvm.masked.gather.nxv2i16.nxv2p0(<vscale x 2 x ptr> %16, i32 2, <vscale x 2 x i1> shufflevector (<vscale x 2 x i1> insertelement (<vscale x 2 x i1> poison, i1 true, i64 0), <vscale x 2 x i1> poison, <vscale x 2 x i32> zeroinitializer), <vscale x 2 x i16> poison)\r\n %17 = icmp eq <vscale x 2 x i16> %wide.masked.gather, zeroinitializer\r\n %wide.masked.gather1 = call <vscale x 2 x i64> @llvm.masked.gather.nxv2i64.nxv2p0(<vscale x 2 x ptr> %broadcast.splat, i32 8, <vscale x 2 x i1> %17, <vscale x 2 x i64> poison)\r\n %18 = shl <vscale x 2 x i64> zeroinitializer, %wide.masked.gather1\r\n %19 = icmp eq <vscale x 2 x i64> %18, zeroinitializer\r\n %20 = xor <vscale x 2 x i1> %19, shufflevector (<vscale x 2 x i1> insertelement (<vscale x 2 x i1> poison, i1 true, i64 0), <vscale x 2 x i1> poison, <vscale x 2 x i32> zeroinitializer)\r\n %21 = select <vscale x 2 x i1> %17, <vscale x 2 x i1> %20, <vscale x 2 x i1> zeroinitializer\r\n %wide.masked.gather2 = call <vscale x 2 x i64> @llvm.masked.gather.nxv2i64.nxv2p0(<vscale x 2 x ptr> %broadcast.splat, i32 8, <vscale x 2 x i1> %21, <vscale x 2 x i64> poison)\r\n %22 = trunc <vscale x 2 x i64> %wide.masked.gather2 to <vscale x 2 x i32> <================\r\n %23 = xor <vscale x 2 x i1> %17, shufflevector (<vscale x 2 x i1> insertelement (<vscale x 2 x i1> poison, i1 true, i64 0), <vscale x 2 x i1> poison, <vscale x 2 x i32> zeroinitializer)\r\n %predphi = select <vscale x 2 x i1> %21, <vscale x 2 x i32> %22, <vscale x 2 x i32> zeroinitializer\r\n %predphi3 = select <vscale x 2 x i1> %23, <vscale x 2 x i32> zeroinitializer, <vscale x 2 x i32> %predphi\r\n %24 = trunc <vscale x 2 x i32> %predphi3 to <vscale x 2 x i8>\r\n %25 = mul <vscale x 2 x i8> zeroinitializer, %24\r\n %26 = getelementptr [2 x i64], ptr %i, i64 0, <vscale x 2 x i64> %15\r\n %wide.masked.gather4 = call <vscale x 2 x i64> @llvm.masked.gather.nxv2i64.nxv2p0(<vscale x 2 x ptr> %26, i32 8, <vscale x 2 x i1> shufflevector (<vscale x 2 x i1> insertelement (<vscale x 2 x i1> poison, i1 true, i64 0), <vscale x 2 x i1> poison, <vscale x 2 x i32> zeroinitializer), <vscale x 2 x i64> poison)\r\n %27 = trunc <vscale x 2 x i64> %wide.masked.gather4 to <vscale x 2 x i16>\r\n %28 = xor <vscale x 2 x i16> %27, zeroinitializer\r\n %29 = call i32 @llvm.vscale.i32()\r\n%30 = mul i32 %29, 2\r\n %31 = sub i32 %30, 1\r\n %32 = extractelement <vscale x 2 x i16> %28, i32 %31\r\n store i16 %32, ptr null, align 2\r\n %index.next = add nuw i32 %index, %7\r\n %33 = icmp eq i32 %index.next, %n.vec\r\n br i1 %33, <null operand!>, label %vector.body\r\n..."
69
+ },
70
+ {
71
+ "author": "ElvisWang123",
72
+ "body": "In this case, we can find that all the following recipes can be shrinkage to `i8`.\n```\n====> Cost of 1 for VF vscale x 2: WIDEN-CAST ir<%3> = trunc ir<%2> to i32 <=======\nCost of 0 for VF vscale x 2: EMIT vp<%6> = not ir<%tobool4.not.us>\nCost of 2 for VF vscale x 2: BLEND ir<%cond24.us> = ir<0> ir<%3>/vp<%5> ir<0>/vp<%6>\nCost of 2 for VF vscale x 2: WIDEN-CAST ir<%4> = trunc ir<%cond24.us> to i8\nCost of 1 for VF vscale x 2: WIDEN ir<%conv28.us> = mul ir<0>, ir<%4>\n```\nBut in current minimal-bit-width analysis, there are some checks prevent this type shrinkage.\n1. If any of instructions in the EC (equivalent class) is PHI node, minimal-bit-width wont narrow the type.\n\nTo support type shrinkage for this case. We need to change the MinBW which is the analysis based on the scalar instructions.\n\nModify current minimal-bit-width architecture (Analysis scalar instructions). This implementation may not be accurate since the VPlan may contains some of the recipe without underlying instructions.\n1. Support Phi node in the EC. Although induction phi should not be modified and the recurrence descriptor will handle the type shrinkage. We still need the information from MinBW to shrinkage the non-header phis.\n2. Add the support of `VPBlendRecipe` in `truncateToMinimalBitWidth()` in VPTransform.\n\nOr rewrite a new minimal-bit-width analysis based on Vplan. This implementation will be more accurate than the current analysis but will be more works.\n\n1. To support Vplan-based MinBW, we may need to rewrite a new VPlan-based DemandedBits analysis.\n\n\n@fhahn What do you think about the these two implementations, modify current MinBW or rewrite a new vplan-based MinBW. Or do you have a better implementation to make MinBW more accurate on Vplan?\n\n@patrick-rivos BTW, the C program in this issue is a little bit weird. Without initializing `a`, loop vectorizer cannot recognize the reduction pattern of the `a *= (signed char)((f ? 0 : k[l][l]) ?: (_Bool)(d << j[8][l][e]) ? i[l][l] : c);`. However, we still have some issue on the minimal-bit-width analysis."
73
+ },
74
+ {
75
+ "author": "cardigan1008",
76
+ "body": "Hi, there's another case that triggers this crash:\n\n```c\nint a;\nint b(int c) {\n int d = 0;\n for (; d < c; d++) {\n a++;\n if (d != c - 1)\n a++;\n }\n}\nint *e;\nint f;\nvoid g() {\n for (; e[f]; f++)\n e[b(f + 9)];\n}\n```\n\nCompiler Explorer: https://godbolt.org/z/16Tr15KGx\n\nHope this helps :)"
77
+ },
78
+ {
79
+ "author": "ElvisWang123",
80
+ "body": "@cardigan1008 Thanks for your test case. I will take a look."
81
+ }
82
+ ]
83
+ },
84
+ "verified": true
85
+ }
dataset/121518.json ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "121518",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/121518",
4
+ "bug_type": "crash",
5
+ "base_commit": "2a5050aa5ef56b01cf4a8f73e0d0eddd6d9ce2a9",
6
+ "knowledge_cutoff": "2025-01-02T20:14:01Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "e258bca9505f35e0a22cb213a305eea9b76d11ea",
12
+ "components": [
13
+ "LoopVectorize",
14
+ "ScalarEvolution"
15
+ ],
16
+ "bug_location_lineno": {
17
+ "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": [
18
+ [
19
+ 1451,
20
+ 1457
21
+ ]
22
+ ],
23
+ "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": [
24
+ [
25
+ 3404,
26
+ 3410
27
+ ]
28
+ ],
29
+ "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": [
30
+ [
31
+ 30,
32
+ 40
33
+ ]
34
+ ]
35
+ },
36
+ "bug_location_funcname": {
37
+ "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": [
38
+ "SCEVExpander::expandCodeFor"
39
+ ],
40
+ "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": [
41
+ "VPExpandSCEVRecipe::execute"
42
+ ],
43
+ "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": [
44
+ "vputils::getOrCreateVPValueForSCEVExpr"
45
+ ]
46
+ }
47
+ },
48
+ "patch": "commit e258bca9505f35e0a22cb213a305eea9b76d11ea\nAuthor: Florian Hahn <[email protected]>\nDate: Tue Feb 11 13:03:12 2025 +0100\n\n [VPlan] Only skip expansion for SCEVUnknown if it isn't an instruction. (#125235)\n \n Update getOrCreateVPValueForSCEVExpr to only skip expansion of\n SCEVUnknown if the underlying value isn't an instruction. Instructions\n may be defined in a loop and using them without expansion may break\n LCSSA form. SCEVExpander will take care of preserving LCSSA if needed.\n \n We could also try to pass LoopInfo, but there are some users of the\n function where it won't be available and main benefit from skipping\n expansion is slightly more concise VPlans.\n \n Note that SCEVExpander is now used to expand SCEVUnknown with floats.\n Adjust the check in expandCodeFor to only check the types and casts if\n the type of the value is different to the requested type. Otherwise we\n crash when trying to expand a float and requesting a float type.\n \n Fixes https://github.com/llvm/llvm-project/issues/121518.\n \n PR: https://github.com/llvm/llvm-project/pull/125235\n\ndiff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp\nindex 3a761bc4e811..d429fe96f9be 100644\n--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp\n+++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp\n@@ -1451,7 +1451,7 @@ Value *SCEVExpander::expandCodeFor(const SCEV *SH, Type *Ty) {\n // Expand the code for this SCEV.\n Value *V = expand(SH);\n \n- if (Ty) {\n+ if (Ty && Ty != V->getType()) {\n assert(SE.getTypeSizeInBits(Ty) == SE.getTypeSizeInBits(SH->getType()) &&\n \"non-trivial casts should be done with the SCEVs directly!\");\n V = InsertNoopCastOfTo(V, Ty);\ndiff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp\nindex 618c8aef3840..1855fb67aa54 100644\n--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp\n+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp\n@@ -3404,7 +3404,7 @@ void VPExpandSCEVRecipe::execute(VPTransformState &State) {\n }\n \n const DataLayout &DL = State.CFG.PrevBB->getDataLayout();\n- SCEVExpander Exp(SE, DL, \"induction\");\n+ SCEVExpander Exp(SE, DL, \"induction\", /*PreserveLCSSA=*/true);\n \n Value *Res = Exp.expandCodeFor(Expr, Expr->getType(),\n &*State.Builder.GetInsertPoint());\ndiff --git a/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp b/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp\nindex e40af3e2e3d3..1a7322ec0aff 100644\n--- a/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp\n+++ b/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp\n@@ -30,11 +30,18 @@ VPValue *vputils::getOrCreateVPValueForSCEVExpr(VPlan &Plan, const SCEV *Expr,\n VPValue *Expanded = nullptr;\n if (auto *E = dyn_cast<SCEVConstant>(Expr))\n Expanded = Plan.getOrAddLiveIn(E->getValue());\n- else if (auto *E = dyn_cast<SCEVUnknown>(Expr))\n- Expanded = Plan.getOrAddLiveIn(E->getValue());\n else {\n- Expanded = new VPExpandSCEVRecipe(Expr, SE);\n- Plan.getEntry()->appendRecipe(Expanded->getDefiningRecipe());\n+ auto *U = dyn_cast<SCEVUnknown>(Expr);\n+ // Skip SCEV expansion if Expr is a SCEVUnknown wrapping a non-instruction\n+ // value. Otherwise the value may be defined in a loop and using it directly\n+ // will break LCSSA form. The SCEV expansion takes care of preserving LCSSA\n+ // form.\n+ if (U && !isa<Instruction>(U->getValue())) {\n+ Expanded = Plan.getOrAddLiveIn(U->getValue());\n+ } else {\n+ Expanded = new VPExpandSCEVRecipe(Expr, SE);\n+ Plan.getEntry()->appendRecipe(Expanded->getDefiningRecipe());\n+ }\n }\n Plan.addSCEVExpansion(Expr, Expanded);\n return Expanded;\n",
49
+ "tests": [
50
+ {
51
+ "file": "llvm/test/Transforms/LoopVectorize/X86/scev-checks-unprofitable.ll",
52
+ "commands": [
53
+ "opt -p loop-vectorize -vectorizer-min-trip-count=8 -mcpu=skylake-avx512 -S %s"
54
+ ],
55
+ "tests": [
56
+ {
57
+ "test_name": "<module>",
58
+ "test_body": "\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n; Test case for https://github.com/llvm/llvm-project/issues/121518. Make sure\n; that we preserve LCSSA form when using %iv.1 from loop.1 in the trip count\n; expression when vectorizing loop.2\ndefine void @value_defined_in_loop1_used_for_trip_counts(i32 %start, i1 %c, ptr %dst) {\n;\nentry:\n %select = select i1 %c, i32 0, i32 7\n %zext = zext i32 %select to i64\n br label %loop.1\n\nloop.1:\n %iv.1 = phi i64 [ 0, %entry ], [ %zext, %loop.1 ]\n br i1 false, label %loop.1.exit, label %loop.1\n\nloop.1.exit:\n br i1 %c, label %loop.2, label %loop.3\n\nloop.2:\n %iv.2 = phi i64 [ 0, %loop.1.exit ], [ %iv.2.next, %loop.2 ]\n %iv.3 = phi i32 [ %start, %loop.1.exit ], [ %iv.3.next, %loop.2 ]\n %iv.3.next = add i32 %iv.3, 1\n %iv.2.next = add i64 %iv.2, 1\n %shl = shl i32 %iv.3, 1\n %zext8 = zext i32 %shl to i64\n %gep.dst = getelementptr i8, ptr %dst, i64 %zext8\n store i16 0, ptr %gep.dst, align 2\n %ec.2 = icmp ult i64 %iv.2, %iv.1\n br i1 %ec.2, label %loop.2, label %exit.1\n\nloop.3:\n %iv.4 = phi i64 [ 0, %loop.1.exit ], [ %iv.4.next, %loop.3 ]\n %gep.dst.2 = getelementptr i8, ptr %dst, i64 %iv.4\n store i8 0, ptr %gep.dst.2, align 1\n %iv.4.next = add i64 %iv.4, 1\n %ec.3 = icmp ult i64 %iv.4.next, %iv.1\n br i1 %ec.3, label %loop.3, label %exit.1\n\nexit.1:\n ret void\n}\n;.\n;."
59
+ }
60
+ ]
61
+ },
62
+ {
63
+ "file": "llvm/test/Transforms/LoopVectorize/float-induction.ll",
64
+ "commands": [
65
+ "opt < %s -passes=loop-vectorize,dce,instcombine -force-vector-interleave=1 -force-vector-width=4 -S",
66
+ "opt < %s -passes=loop-vectorize,dce,instcombine -force-vector-interleave=2 -force-vector-width=4 -S",
67
+ "opt < %s -passes=loop-vectorize,dce,instcombine -force-vector-interleave=2 -force-vector-width=1 -S",
68
+ "opt < %s -passes=loop-vectorize,dce,simplifycfg,instcombine,simplifycfg -force-vector-interleave=1 -force-vector-width=2 -simplifycfg-require-and-preserve-domtree=1 -keep-loops=false -S"
69
+ ],
70
+ "tests": [
71
+ {
72
+ "test_name": "fp_iv_loop3",
73
+ "test_body": "@fp_inc = external global float, align 4\n\ndefine void @fp_iv_loop3(float %init, ptr noalias captures(none) %A, ptr noalias captures(none) %B, ptr noalias captures(none) %C, i32 %N) {\nentry:\n %cmp9 = icmp sgt i32 %N, 0\n br i1 %cmp9, label %for.body.lr.ph, label %for.end\n\nfor.body.lr.ph: ; preds = %entry\n %0 = load float, ptr @fp_inc, align 4\n br label %for.body\n\nfor.body: ; preds = %for.body, %for.body.lr.ph\n %indvars.iv = phi i64 [ 0, %for.body.lr.ph ], [ %indvars.iv.next, %for.body ]\n %y.012 = phi float [ 0x3FB99999A0000000, %for.body.lr.ph ], [ %conv1, %for.body ]\n %x.011 = phi float [ %init, %for.body.lr.ph ], [ %add, %for.body ]\n %arrayidx = getelementptr inbounds float, ptr %A, i64 %indvars.iv\n store float %x.011, ptr %arrayidx, align 4\n %add = fadd fast float %x.011, %0\n %conv1 = fadd fast float %y.012, -5.000000e-01\n %add2 = fadd fast float %conv1, %add\n %arrayidx4 = getelementptr inbounds float, ptr %B, i64 %indvars.iv\n store float %add2, ptr %arrayidx4, align 4\n %arrayidx6 = getelementptr inbounds float, ptr %C, i64 %indvars.iv\n store float %conv1, ptr %arrayidx6, align 4\n %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1\n %lftr.wideiv = trunc i64 %indvars.iv.next to i32\n %exitcond = icmp eq i32 %lftr.wideiv, %N\n br i1 %exitcond, label %for.end.loopexit, label %for.body\n\nfor.end.loopexit: ; preds = %for.body\n br label %for.end\n\nfor.end: ; preds = %for.end.loopexit, %entry\n ret void\n}\n\n!llvm.module.flags = !{!0}\n\n!0 = !{i32 2, !\"Debug Info Version\", i32 3}\n"
74
+ }
75
+ ]
76
+ }
77
+ ],
78
+ "issue": {
79
+ "title": "Assertion `all_of(I->users(), [&InsertedSet](Value *U) { return InsertedSet.contains(cast<Instruction>(U)); }) && \"removed instruction should only be used by instructions inserted \" \"during expansion\"' failed.",
80
+ "body": "To reproduce run opt with the test below (-passes=loop-vectorize ):\n```\n; ModuleID = './reduced.ll'\nsource_filename = \"./reduced.ll\"\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-ni:1-p2:32:8:8:32-ni:2\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine ptr addrspace(1) @wombat(i32 %arg) gc \"statepoint-example\" {\nbb:\n %select = select i1 false, i32 0, i32 8\n br label %bb3\n\nbb1: ; preds = %bb3\n br i1 false, label %bb4, label %bb9\n\nbb2: ; No predecessors!\n %zext = zext i32 %select to i64\n br label %bb3\n\nbb3: ; preds = %bb3, %bb2, %bb\n %phi = phi i64 [ %zext, %bb2 ], [ 0, %bb3 ], [ 0, %bb ]\n br i1 false, label %bb1, label %bb3\n\nbb4: ; preds = %bb4, %bb1\n %phi5 = phi i64 [ %add7, %bb4 ], [ 0, %bb1 ]\n %phi6 = phi i32 [ %add, %bb4 ], [ %arg, %bb1 ]\n %add = add i32 %phi6, 1\n %add7 = add i64 %phi5, 1\n %shl = shl i32 %phi6, 1\n %zext8 = zext i32 %shl to i64\n %getelementptr = getelementptr i8, ptr addrspace(1) null, i64 %zext8\n store i16 0, ptr addrspace(1) %getelementptr, align 2\n %icmp = icmp ult i64 %phi5, %phi\n br i1 %icmp, label %bb4, label %bb15\n\nbb9: ; preds = %bb9, %bb1\n %phi10 = phi i64 [ %add12, %bb9 ], [ 0, %bb1 ]\n %getelementptr11 = getelementptr i8, ptr addrspace(1) null, i64 %phi10\n store i8 0, ptr addrspace(1) %getelementptr11, align 1\n %add12 = add i64 %phi10, 1\n %icmp13 = icmp ult i64 %add12, %phi\n br i1 %icmp13, label %bb9, label %bb14\n\nbb14: ; preds = %bb9\n ret ptr addrspace(1) null\n\nbb15: ; preds = %bb4\n ret ptr addrspace(1) null\n}\n```\nReproducer: https://godbolt.org/z/67vadzMbr\nStack dump:\n```\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=loop-vectorize <source>\n1.\tRunning pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"<source>\"\n2.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"wombat\"\n #0 0x000000000525d5d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x525d5d8)\n #1 0x000000000525afdc SignalHandler(int) Signals.cpp:0:0\n #2 0x00007cf6f6042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007cf6f60969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x00007cf6f6042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007cf6f60287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x00007cf6f602871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x00007cf6f6039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x00000000045a6237 llvm::SCEVExpanderCleaner::cleanup() (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x45a6237)\n #9 0x00000000041cf7df (anonymous namespace)::GeneratedRTChecks::~GeneratedRTChecks() LoopVectorize.cpp:0:0\n#10 0x0000000004227f36 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4227f36)\n#11 0x0000000004229cc9 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4229cc9)\n#12 0x000000000422a303 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x422a303)\n#13 0x0000000003029e0e llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3029e0e)\n#14 0x000000000505b4d0 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x505b4d0)\n#15 0x0000000000e6bc0e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe6bc0e)\n#16 0x0000000005059deb llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5059deb)\n#17 0x0000000000e6b29e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe6b29e)\n#18 0x00000000050597f0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x50597f0)\n#19 0x0000000000941fba 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) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x941fba)\n#20 0x0000000000934559 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x934559)\n#21 0x00007cf6f6029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#22 0x00007cf6f6029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#23 0x000000000092be35 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x92be35)\nProgram terminated with signal: SIGSEGV\n```",
81
+ "author": "TatyanaDoubts",
82
+ "labels": [
83
+ "release:backport",
84
+ "vectorizers",
85
+ "llvm:SCEV",
86
+ "crash"
87
+ ],
88
+ "comments": [
89
+ {
90
+ "author": "TatyanaDoubts",
91
+ "body": "Triage on our side found the fault commit\n\ncommit 6dc23b70097e4135ecde33f49550b1f473a5c385\n\nAuthor: Nikita Popov <[[email protected]](mailto:[email protected])>\n\nDate: Mon Nov 11 12:36:29 2024 +0100\n\n \n\n [SCEVExpander] Don't try to reuse SCEVUnknown values (#115141)\n\n \n\n The expansion of a SCEVUnknown is trivial (it's just the wrapped value).\n\n If we try to reuse an existing value it might be a more complex\n\n expression that simplifies to the SCEVUnknown.\n\n \n\n This is inspired by [WRONG code: GVN? Loop opts? \u00b7 Issue #114879 \u00b7 llvm/llvm-project](https://github.com/llvm/llvm-project/issues/114879) ,\n\n because SCEVExpander replacing a constant with a phi node is just silly.\n\n (I don't consider this a fix for that issue though.)\n\n@nikic , could you please have a look? Thank you!"
92
+ },
93
+ {
94
+ "author": "danilaml",
95
+ "body": "Looks like when `FindValueInExprValueMap` returns a `nullptr` (like it does for a phi in reproducer after `SCEVUnknown` changes) the code runs `fixupLCSSAFormFor`. This function runs `llvm::formLCSSAForInstructions` that can insert a new LCSSA phi and more importantly can rewrite the uses of instructions in the worklist. So what happens is this function is run, new phi is added, some old phi uses are replaced with this new phi, then the changes are \"rolled back\", i.e. the cleanup is called on SCEVExpander, it tries to remove the inserted lcssa phi but it doesn't know how to rewrite the uses back so it just asserts (since those users were not inserted by the expander itself, they were already there - they just had their arguments replaced to use instruction from expander).\n\n@nikic this looks like an old issue, although I wasn't yet able to figure out how to trigger it before `SCEVUnknown` changes (and if it even practically possible or just theoretically)."
96
+ },
97
+ {
98
+ "author": "danilaml",
99
+ "body": "`fixupLCSSAFormFor` was introduced by @fhahn so perhaps they have a better understanding where the issue lies."
100
+ },
101
+ {
102
+ "author": "nikic",
103
+ "body": "I think there are two issues here:\n1. It looks like LV is generating references to the TC that break LCSSA form.\n2. SCEVExpander cleanup can't handle the case where LCSSA formation modified existing uses."
104
+ },
105
+ {
106
+ "author": "nikic",
107
+ "body": "This is a possible fix for the SCEVExpander issue: https://github.com/nikic/llvm-project/commit/3217b044ce2b153621f91f8edaaa90984c0998e7\n\nBut after thinking about this, I'm not convinced that SCEVExpander really needs fixing. It is being invoked in PreserveLCSSA mode, so it should be able to rely on the original IR being in LCSSA form.\n\nNote that the `[[N_RND_UP:%.*]] = add i64 [[PHI]], 15` in https://github.com/nikic/llvm-project/commit/3217b044ce2b153621f91f8edaaa90984c0998e7#diff-9e3a00a1cffe1764ee50ab6c79bdea53cd1847cf7b77810a4cdc6835bfc79a52R44 doesn't satisfy LCSSA form, it should be using `PHI_LCSSA`.\n\nMaybe @fhahn could take a look at the LoopVectorize issue?\n\nI could also be convinced to land the SCEVExpander change, as it seems harmless even if LV is fixed..."
108
+ },
109
+ {
110
+ "author": "fhahn",
111
+ "body": "Yep, I'll take a look in the next few days"
112
+ },
113
+ {
114
+ "author": "fhahn",
115
+ "body": "https://github.com/llvm/llvm-project/pull/125235 should fix the place where LCSSA is broken"
116
+ }
117
+ ]
118
+ },
119
+ "verified": true
120
+ }
dataset/124759.json ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "124759",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/124759",
4
+ "bug_type": "crash",
5
+ "base_commit": "b923f6cf8faca82b8df2a936d8ff36a6125aedcc",
6
+ "knowledge_cutoff": "2025-01-28T14:48:43Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Analysis/LoopAccessAnalysis"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "275baedfde9dcd344bc4f11f552b046a69a4bf3f",
12
+ "components": [
13
+ "LoopAccessAnalysis"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Analysis/LoopAccessAnalysis.cpp": [
17
+ [
18
+ 1362,
19
+ 1369
20
+ ],
21
+ [
22
+ 1443,
23
+ 1450
24
+ ]
25
+ ]
26
+ },
27
+ "bug_location_funcname": {
28
+ "llvm/lib/Analysis/LoopAccessAnalysis.cpp": [
29
+ "AccessAnalysis::processMemAccesses"
30
+ ]
31
+ }
32
+ },
33
+ "patch": "commit 275baedfde9dcd344bc4f11f552b046a69a4bf3f\nAuthor: Florian Hahn <[email protected]>\nDate: Fri Feb 28 20:56:12 2025 +0000\n\n [LAA] Consider accessed addrspace when mapping underlying obj to access. (#129087)\n \n In some cases, it is possible for the same underlying object to be\n accessed via pointers to different address spaces. This could lead to\n pointers from different address spaces ending up in the same dependency\n set, which isn't allowed (and triggers an assertion).\n \n Update the mapping from underlying object -> last access to also include\n the accessing address space.\n \n Fixes https://github.com/llvm/llvm-project/issues/124759.\n \n PR: https://github.com/llvm/llvm-project/pull/129087\n\ndiff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp\nindex cf3bb6a8eae1..38ee82b77a94 100644\n--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp\n+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp\n@@ -1362,8 +1362,10 @@ void AccessAnalysis::processMemAccesses() {\n \n bool SetHasWrite = false;\n \n- // Map of pointers to last access encountered.\n- typedef DenseMap<const Value*, MemAccessInfo> UnderlyingObjToAccessMap;\n+ // Map of (pointer to underlying objects, accessed address space) to last\n+ // access encountered.\n+ typedef DenseMap<std::pair<const Value *, unsigned>, MemAccessInfo>\n+ UnderlyingObjToAccessMap;\n UnderlyingObjToAccessMap ObjToLastAccess;\n \n // Set of access to check after all writes have been processed.\n@@ -1443,8 +1445,10 @@ void AccessAnalysis::processMemAccesses() {\n UnderlyingObj->getType()->getPointerAddressSpace()))\n continue;\n \n- auto [It, Inserted] =\n- ObjToLastAccess.try_emplace(UnderlyingObj, Access);\n+ auto [It, Inserted] = ObjToLastAccess.try_emplace(\n+ {UnderlyingObj,\n+ cast<PointerType>(Ptr->getType())->getAddressSpace()},\n+ Access);\n if (!Inserted) {\n DepCands.unionSets(Access, It->second);\n It->second = Access;\n",
34
+ "tests": [
35
+ {
36
+ "file": "llvm/test/Analysis/LoopAccessAnalysis/underlying-object-different-address-spaces.ll",
37
+ "commands": [
38
+ "opt -passes='print<access-info>' -disable-output %s 2>&1"
39
+ ],
40
+ "tests": [
41
+ {
42
+ "test_name": "<module>",
43
+ "test_body": "\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\"\n\n; Test case for https://github.com/llvm/llvm-project/issues/124759. The same\n; underlying object is access through pointers with different address spaces.\ndefine void @same_underlying_object_different_address_spaces(ptr %dst1.as1, ptr %dst2.as1) {\n;\nentry:\n %alloc = alloca i8, i64 0, align 128\n %as3 = addrspacecast ptr %alloc to ptr addrspace(3)\n %as4 = addrspacecast ptr %alloc to ptr addrspace(4)\n br label %loop\n\nloop:\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n store i32 0, ptr addrspace(4) %as4, align 4\n store i32 0, ptr %dst1.as1, align 4\n %l = load i64, ptr addrspace(3) %as3, align 4\n store i64 %l, ptr %dst2.as1, align 4\n %iv.next = add i64 %iv, 1\n %c = icmp eq i64 %iv.next, 100\n br i1 %c, label %loop, label %exit\n\nexit:\n ret void\n}"
44
+ }
45
+ ]
46
+ }
47
+ ],
48
+ "issue": {
49
+ "title": "LoopVectorizer `assert(AddressSpace == AS && with addrspacecast` is hit",
50
+ "body": "The following code produces an assert in RuntimeCheckingPtrGroup::addPointer()\n\n\n``` llvm\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-elf\"\n\ndefine void @__mux_host_0(ptr addrspace(1) %_arg_resultPtr, ptr addrspace(1) %add.ptr.i.sroa_idx.i.i.i.i) {\nloopIR.i.preheader:\n %0 = alloca i8, i64 0, align 128\n %_arg_localAccessor = addrspacecast ptr %0 to ptr addrspace(3)\n %arrayidx.ascast.i.i.i.i.i.i = addrspacecast ptr %0 to ptr addrspace(4)\n br label %loopIR2.i\n\nloopIR2.i: ; preds = %loopIR2.i, %loopIR.i.preheader\n %1 = phi i64 [ 0, %loopIR.i.preheader ], [ %3, %loopIR2.i ]\n store i32 0, ptr addrspace(4) %arrayidx.ascast.i.i.i.i.i.i, align 4\n store float 0.000000e+00, ptr addrspace(1) %add.ptr.i.sroa_idx.i.i.i.i, align 4\n %2 = load i64, ptr addrspace(3) %_arg_localAccessor, align 4\n store i64 0, ptr addrspace(1) %_arg_resultPtr, align 4\n %3 = add i64 %1, 1\n br i1 false, label %loopIR2.i, label %exitIR.i\n\nexitIR.i: ; preds = %loopIR2.i\n ret void\n}\n```\n\nThis crashes with `opt --passes loop-vectorize /tmp/reduced.ll -S -o -` as follows:\n\n```\n./bin/opt --passes loop-vectorize /tmp/reduced.ll -S -o -\nopt: /home/colin/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp:423: bool llvm::RuntimeCheckingPtrGroup::addPointer(unsigned int, const llvm::SCEV*, const llvm::SCEV*, unsigned int, bool, llvm::ScalarEvolution&): Assertion `AddressSpace == AS && \"all pointers in a checking group must be in the same address space\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0. Program arguments: ./bin/opt --passes loop-vectorize /tmp/reduced.ll -S -o -\n1. Running pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"/tmp/reduced.ll\"\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"__mux_host_0\"\n #0 0x00005a58a99c2ddc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/colin/llvm-project/llvm/lib/Support/Unix/Signals.inc:798:22\n #1 0x00005a58a99c31fd PrintStackTraceSignalHandler(void*) /home/colin/llvm-project/llvm/lib/Support/Unix/Signals.inc:874:1\n #2 0x00005a58a99c0663 llvm::sys::RunSignalHandlers() /home/colin/llvm-project/llvm/lib/Support/Signals.cpp:105:20\n #3 0x00005a58a99c2674 SignalHandler(int) /home/colin/llvm-project/llvm/lib/Support/Unix/Signals.inc:415:1\n #4 0x00007c96b3242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #5 0x00007c96b32969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #6 0x00007c96b32969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #7 0x00007c96b32969fc pthread_kill ./nptl/pthread_kill.c:89:10\n #8 0x00007c96b3242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\n #9 0x00007c96b32287f3 abort ./stdlib/abort.c:81:7\n#10 0x00007c96b322871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\n#11 0x00007c96b3239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n#12 0x00005a58a8936a8b llvm::RuntimeCheckingPtrGroup::addPointer(unsigned int, llvm::SCEV const*, llvm::SCEV const*, unsigned int, bool, llvm::ScalarEvolution&) /home/colin/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp:429:37\n#13 0x00005a58a8936a20 llvm::RuntimeCheckingPtrGroup::addPointer(unsigned int, llvm::RuntimePointerChecking const&) /home/colin/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp:413:20\n#14 0x00005a58a8936f8d llvm::RuntimePointerChecking::groupChecks(llvm::EquivalenceClasses<llvm::PointerIntPair<llvm::Value*, 1u, bool, llvm::PointerLikeTypeTraits<llvm::Value*>, llvm::PointerIntPairInfo<llvm::Value*, 1u, llvm::PointerLikeTypeTraits<llvm::Value*>>>, std::less<llvm::PointerIntPair<llvm::Value*, 1u, bool, llvm::PointerLikeTypeTraits<llvm::Value*>, llvm::PointerIntPairInfo<llvm::Value*, 1u, llvm::PointerLikeTypeTraits<llvm::Value*>>>>>&, bool) /home/colin/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp:554:11\n#15 0x00005a58a893678d llvm::RuntimePointerChecking::generateChecks(llvm::EquivalenceClasses<llvm::PointerIntPair<llvm::Value*, 1u, bool, llvm::PointerLikeTypeTraits<llvm::Value*>, llvm::PointerIntPairInfo<llvm::Value*, 1u, llvm::PointerLikeTypeTraits<llvm::Value*>>>, std::less<llvm::PointerIntPair<llvm::Value*, 1u, bool, llvm::PointerLikeTypeTraits<llvm::Value*>, llvm::PointerIntPairInfo<llvm::Value*, 1u, llvm::PointerLikeTypeTraits<llvm::Value*>>>>>&, bool) /home/colin/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp:389:26\n#16 0x00005a58a893a016 (anonymous namespace)::AccessAnalysis::canCheckPtrAtRT(llvm::RuntimePointerChecking&, llvm::ScalarEvolution*, llvm::Loop*, llvm::DenseMap<llvm::Value*, llvm::SCEV const*, llvm::DenseMapInfo<llvm::Value*, void>, llvm::detail::DenseMapPair<llvm::Value*, llvm::SCEV const*>> const&, llvm::Value*&, bool) /home/colin/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp:1243:3\n#17 0x00005a58a8940750 llvm::LoopAccessInfo::analyzeLoop(llvm::AAResults*, llvm::LoopInfo const*, llvm::TargetLibraryInfo const*, llvm::DominatorTree*) /home/colin/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp:2638:31\n#18 0x00005a58a89422b3 llvm::LoopAccessInfo::LoopAccessInfo(llvm::Loop*, llvm::ScalarEvolution*, llvm::TargetTransformInfo const*, llvm::TargetLibraryInfo const*, llvm::AAResults*, llvm::DominatorTree*, llvm::LoopInfo*) /home/colin/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp:3028:15\n#19 0x00005a58a894ae40 std::_MakeUniq<llvm::LoopAccessInfo>::__single_object std::make_unique<llvm::LoopAccessInfo, llvm::Loop*, llvm::ScalarEvolution*, llvm::TargetTransformInfo*&, llvm::TargetLibraryInfo const*&, llvm::AAResults*, llvm::DominatorTree*, llvm::LoopInfo*>(llvm::Loop*&&, llvm::ScalarEvolution*&&, llvm::TargetTransformInfo*&, llvm::TargetLibraryInfo const*&, llvm::AAResults*&&, llvm::DominatorTree*&&, llvm::LoopInfo*&&) /usr/include/c++/11/bits/unique_ptr.h:962:30\n#20 0x00005a58a8942883 llvm::LoopAccessInfoManager::getInfo(llvm::Loop&) /home/colin/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp:3084:41\n#21 0x00005a58a831900e llvm::LoopVectorizationLegality::canVectorizeMemory() /home/colin/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp:1208:7\n#22 0x00005a58a831bc45 llvm::LoopVectorizationLegality::canVectorize(bool) /home/colin/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp:1840:7\n#23 0x00005a58a800b8b5 llvm::LoopVectorizePass::processLoop(llvm::Loop*) /home/colin/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10349:7\n#24 0x00005a58a800dde6 llvm::LoopVectorizePass::runImpl(llvm::Function&) /home/colin/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10779:27\n#25 0x00005a58a800e133 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/colin/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10816:39\n#26 0x00005a58a65ef71b llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/colin/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:92:3\n#27 0x00005a58a96e6133 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/colin/llvm-project/llvm/include/llvm/IR/PassManagerImpl.h:85:18\n#28 0x00005a58a4a21a65 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/colin/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:92:3\n#29 0x00005a58a96e513e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /home/colin/llvm-project/llvm/lib/IR/PassManager.cpp:129:23\n#30 0x00005a58a4a21995 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /home/colin/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:92:3\n#31 0x00005a58a96e5d5f llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /home/colin/llvm-project/llvm/include/llvm/IR/PassManagerImpl.h:85:18\n#32 0x00005a58a476e632 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) /home/colin/llvm-project/llvm/tools/opt/NewPMDriver.cpp:541:10\n#33 0x00005a58a473c69f optMain /home/colin/llvm-project/llvm/tools/opt/optdriver.cpp:739:27\n#34 0x00005a58a4739e81 main /home/colin/llvm-project/llvm/tools/opt/opt.cpp:25:64\n#35 0x00007c96b3229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\n#36 0x00007c96b3229e40 call_init ./csu/../csu/libc-start.c:128:20\n#37 0x00007c96b3229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\n#38 0x00005a58a4739d65 _start (./bin/opt+0xb93d65)\n```\n\nI've done some debugging and in `RuntimeCheckingPtrGroup::addPointer()` II can see the first two elements if RTCheck have the same dependency set but different address spaces.\n\nI did try removing the dependency set being equal continuing the loop here https://github.com/llvm/llvm-project/blob/main/llvm/lib/Analysis/LoopAccessAnalysis.cpp#L1219\n\n``` cpp\n // Only need to check pointers between two different dependency sets.\n if (RtCheck.Pointers[i].DependencySetId ==\n RtCheck.Pointers[j].DependencySetId)\n continue;\n```\nThis does seem to fix the issue but I was wary on whether this was just another symptom rather than the proper fix.\n",
51
+ "author": "coldav",
52
+ "labels": [
53
+ "release:backport",
54
+ "release:cherry-pick-failed",
55
+ "crash",
56
+ "llvm:analysis"
57
+ ],
58
+ "comments": [
59
+ {
60
+ "author": "coldav",
61
+ "body": "Since nobody is looking at this, and it shows up as an assert for this, I'll try upstreaming my fix."
62
+ },
63
+ {
64
+ "author": "fhahn",
65
+ "body": "@coldav sorry I missed this one. I think skipping the check you mentioned is probably not the right fix. I am looking into avoiding grouping pointers with different address spaces in the same dependency set.\n\nI am not super familiar with address space semantics, I am not sure if it is valid to access the same object with pointers to different address spaces?"
66
+ },
67
+ {
68
+ "author": "hvdijk",
69
+ "body": "> I am not super familiar with address space semantics, I am not sure if it is valid to access the same object with pointers to different address spaces?\n\nIt depends on the address spaces. Address spaces may or may not overlap. If they do not overlap, then LLVM can assume that an object accessed from one address space and an object accessed from another do not alias. If the address spaces do overlap, however, that assumption is not valid. For the X86 target, address spaces 1-255 are reserved for user-defined code (https://llvm.org/docs/CodeGenerator.html#x86-address-spaces-supported) and interpreted for codegen purposes as aliases for address space zero, meaning all these address spaces overlap exactly."
70
+ },
71
+ {
72
+ "author": "fhahn",
73
+ "body": "Put up https://github.com/llvm/llvm-project/pull/129087 to avoid adding pointers from different addrspaces in the same dependency set"
74
+ },
75
+ {
76
+ "author": "coldav",
77
+ "body": "Thanks @fhahn "
78
+ },
79
+ {
80
+ "author": "fhahn",
81
+ "body": "Manual PR to pick https://github.com/llvm/llvm-project/pull/129317"
82
+ }
83
+ ]
84
+ },
85
+ "verified": true
86
+ }
dataset/126304.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "126304",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/126304",
4
+ "bug_type": "crash",
5
+ "base_commit": "fcbf04e40e66014f455a38b59993be865bc6cdfd",
6
+ "knowledge_cutoff": "2025-02-07T20:48:01Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/SLPVectorizer"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "10844fb9b0b78695243391e091e17ec29295872a",
12
+ "components": [
13
+ "SLPVectorizer"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
17
+ [
18
+ 5596,
19
+ 5601
20
+ ],
21
+ [
22
+ 5626,
23
+ 5632
24
+ ]
25
+ ]
26
+ },
27
+ "bug_location_funcname": {
28
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
29
+ "BoUpSLP::getReorderingData"
30
+ ]
31
+ }
32
+ },
33
+ "patch": "commit 10844fb9b0b78695243391e091e17ec29295872a\nAuthor: Alexey Bataev <[email protected]>\nDate: Tue Feb 11 13:23:55 2025 -0800\n\n [SLP]Fix attempt to build the reorder mask for non-adjusted reuse mask\n \n When building the reorder for non-single use reuse mask, need to check\n if the size of the mask is multiple of the number of unique scalars.\n Otherwise, the compiler may crash when trying to reorder nodes.\n \n Fixes #126304\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex e1c08077126d..fb1054ee30aa 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -5596,6 +5596,8 @@ BoUpSLP::getReorderingData(const TreeEntry &TE, bool TopToBottom) {\n ::getNumberOfParts(*TTI, getWidenedType(TE.Scalars.front()->getType(),\n 2 * TE.getVectorFactor())) == 1)\n return std::nullopt;\n+ if (TE.ReuseShuffleIndices.size() % Sz != 0)\n+ return std::nullopt;\n if (!ShuffleVectorInst::isOneUseSingleSourceMask(TE.ReuseShuffleIndices,\n Sz)) {\n SmallVector<int> ReorderMask(Sz, PoisonMaskElem);\n@@ -5626,7 +5628,7 @@ BoUpSLP::getReorderingData(const TreeEntry &TE, bool TopToBottom) {\n UsedVals.set(Val);\n for (unsigned K = 0; K < NumParts; ++K) {\n unsigned Idx = Val + Sz * K;\n- if (Idx < VF)\n+ if (Idx < VF && I + K < VF)\n ResOrder[Idx] = I + K;\n }\n }\n",
34
+ "tests": [
35
+ {
36
+ "file": "llvm/test/Transforms/SLPVectorizer/SystemZ/reuse-non-power-of-2-reorder.ll",
37
+ "commands": [
38
+ "opt -S --passes=slp-vectorizer -mtriple=systemz -mcpu=z15 < %s -slp-threshold=-100"
39
+ ],
40
+ "tests": [
41
+ {
42
+ "test_name": "<module>",
43
+ "test_body": "\ndefine void @test(i32 %0, i64 %1, i32 %2, i32 %3, ptr %4) {\n;\n %6 = trunc i64 %1 to i32\n %7 = xor i32 %6, 1\n %8 = xor i32 %6, 1\n %9 = or i32 %7, %8\n %10 = xor i32 %6, 1\n %11 = or i32 %9, %10\n %12 = xor i32 %6, 1\n %13 = or i32 %11, %12\n %14 = xor i32 %6, 1\n %15 = or i32 %13, %14\n %16 = xor i32 %6, 1\n %17 = or i32 %15, %16\n %18 = xor i32 %6, 1\n %19 = or i32 %17, %18\n %20 = xor i32 %6, 1\n %21 = or i32 %19, %20\n %22 = trunc i64 %1 to i32\n %23 = xor i32 %22, 1\n %24 = or i32 %23, %21\n %25 = xor i32 %22, 1\n %26 = or i32 %24, %25\n %27 = xor i32 %22, 1\n %28 = or i32 %26, %27\n %29 = xor i32 %22, 1\n %30 = or i32 %28, %29\n %31 = xor i32 %22, 1\n %32 = or i32 %30, %31\n %33 = xor i32 %22, 1\n %34 = or i32 %32, %33\n %35 = xor i32 %22, 1\n %36 = or i32 %34, %35\n %37 = xor i32 %22, 1\n %38 = or i32 %36, %37\n %39 = trunc i64 %1 to i32\n %40 = xor i32 %39, 1\n %41 = or i32 %40, %38\n %42 = xor i32 %39, 1\n %43 = or i32 %41, %42\n %44 = xor i32 %39, 1\n %45 = or i32 %43, %44\n %46 = xor i32 %39, 1\n %47 = or i32 %45, %46\n %48 = xor i32 %39, 1\n %49 = or i32 %47, %48\n %50 = xor i32 %39, 1\n %51 = or i32 %49, %50\n %52 = xor i32 %39, 1\n %53 = or i32 %51, %52\n %54 = xor i32 %39, 1\n %55 = or i32 %53, %54\n %56 = trunc i64 %1 to i32\n %57 = xor i32 %56, 1\n %58 = or i32 %57, %55\n %59 = xor i32 %56, 1\n %60 = or i32 %58, %59\n %61 = xor i32 %56, 1\n %62 = or i32 %60, %61\n %63 = xor i32 %56, 1\n %64 = or i32 %62, %63\n %65 = xor i32 %56, 1\n %66 = or i32 %64, %65\n %67 = xor i32 %56, 1\n %68 = or i32 %66, %67\n %69 = xor i32 %56, 1\n %70 = or i32 %68, %69\n %71 = xor i32 %56, 1\n %72 = or i32 %70, %71\n %73 = trunc i64 %1 to i32\n %74 = xor i32 %73, 1\n %75 = or i32 %74, %72\n %76 = xor i32 %73, 1\n %77 = or i32 %75, %76\n %78 = xor i32 %73, 1\n %79 = or i32 %77, %78\n %80 = xor i32 %73, 1\n %81 = or i32 %79, %80\n %82 = xor i32 %73, 1\n %83 = or i32 %81, %82\n %84 = xor i32 %73, 1\n %85 = or i32 %83, %84\n %86 = xor i32 %73, 1\n %87 = or i32 %85, %86\n %88 = xor i32 %0, %73\n %89 = or i32 %87, %88\n %90 = xor i32 %0, %2\n %91 = or i32 %90, %89\n %92 = xor i32 %0, %2\n %93 = or i32 %91, %92\n %94 = xor i32 %0, %2\n %95 = or i32 %93, %94\n %96 = xor i32 %0, %2\n %97 = or i32 %95, %96\n %98 = trunc i64 %1 to i32\n %99 = xor i32 %98, 1\n %100 = xor i32 %98, 1\n %101 = or i32 %99, %100\n %102 = xor i32 %98, 1\n %103 = or i32 %101, %102\n %104 = xor i32 %98, 1\n %105 = or i32 %103, %104\n %106 = xor i32 %98, 1\n %107 = or i32 %105, %106\n %108 = xor i32 %98, 1\n %109 = or i32 %107, %108\n %110 = xor i32 %98, 1\n %111 = or i32 %109, %110\n %112 = xor i32 %0, %98\n %113 = or i32 %111, %112\n %114 = xor i32 %0, %3\n %115 = or i32 %113, %114\n %116 = xor i32 %0, %3\n %117 = or i32 %115, %116\n %118 = xor i32 %0, %3\n %119 = or i32 %117, %118\n %120 = xor i32 %0, %3\n %121 = or i32 %119, %120\n %122 = xor i32 %0, %3\n %123 = or i32 %121, %122\n %124 = xor i32 %0, %3\n %125 = or i32 %123, %124\n %126 = xor i32 %0, %3\n %127 = or i32 %125, %126\n %128 = xor i32 %0, %3\n %129 = or i32 %127, %128\n %130 = or i32 %129, %97\n store i32 %130, ptr %4, align 4\n ret void\n}\n"
44
+ }
45
+ ]
46
+ }
47
+ ],
48
+ "issue": {
49
+ "title": "[SLP] llvm::BitVector::set(unsigned int): Assertion `Idx < Size && \"access in bound\"' failed.",
50
+ "body": "[crash41.tar.gz](https://github.com/user-attachments/files/18712696/crash41.tar.gz)\n\nclang -O3 -march=z15 crash41.i -o a.out -w -mllvm -inline-threshold=450\n\nllvm/include/llvm/ADT/BitVector.h:358: llvm::BitVector& llvm::BitVector::set(unsigned int): Assertion `Idx < Size && \"access in bound\"' failed.\n\n#11 0x000002aa03b45768 llvm::SLPVectorizerPass::vectorizeHorReduction\n\n@alexey-bataev \n",
51
+ "author": "JonPsson1",
52
+ "labels": [
53
+ "llvm:SLPVectorizer",
54
+ "crash"
55
+ ],
56
+ "comments": []
57
+ },
58
+ "verified": true
59
+ }
dataset/126581.json ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "126581",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/126581",
4
+ "bug_type": "crash",
5
+ "base_commit": "c81139f417a209dbd2a4e06465483d4b0951a9ac",
6
+ "knowledge_cutoff": "2025-02-10T19:26:42Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/SLPVectorizer"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "d18b1ebef5f5e355d6cee2b2f48789a159a5d616",
12
+ "components": [
13
+ "SLPVectorizer"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
17
+ [
18
+ 18467,
19
+ 18474
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
25
+ "BoUpSLP::computeMinimumValueSizes"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit d18b1ebef5f5e355d6cee2b2f48789a159a5d616\nAuthor: Alexey Bataev <[email protected]>\nDate: Thu Feb 13 09:39:56 2025 -0800\n\n [SLP]Check if vector user exist before accessing it\n \n Need to check if vector user exist before accessing it to avoid compiler\n crash.\n Fixes #126581\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex a337ab7410f7..fb72a112b9ac 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -18467,8 +18467,8 @@ void BoUpSLP::computeMinimumValueSizes() {\n any_of(\n VectorizableTree[NodeIdx]->UserTreeIndices,\n [&](const EdgeInfo &EI) {\n- return (EI.UserTE->hasState() &&\n- EI.UserTE->getOpcode() == Instruction::ICmp) &&\n+ return EI.UserTE && EI.UserTE->hasState() &&\n+ EI.UserTE->getOpcode() == Instruction::ICmp &&\n any_of(EI.UserTE->Scalars, [&](Value *V) {\n auto *IC = dyn_cast<ICmpInst>(V);\n return IC &&\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/SLPVectorizer/RISCV/check-node-without-vector-user.ll",
33
+ "commands": [
34
+ "opt -S --passes=slp-vectorizer -mtriple=riscv64-unknown-linux-gnu -mattr=+v < %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "<module>",
39
+ "test_body": "\n@r = external global [8 x i8]\n\ndefine void @test(i64 %0, ptr %1) {\n;\n %3 = load i8, ptr @r, align 1\n %4 = trunc i8 %3 to i1\n %5 = select i1 %4, i64 %0, i64 0\n %6 = getelementptr i8, ptr @r, i64 %5\n %7 = load i8, ptr %6, align 1\n %8 = icmp ule i8 %3, %7\n %9 = sext i1 %8 to i32\n %10 = load i8, ptr getelementptr (i8, ptr @r, i64 -8049), align 1\n %11 = trunc i8 %10 to i1\n %12 = select i1 %11, i64 %0, i64 0\n %13 = getelementptr i8, ptr @r, i64 %12\n %14 = load i8, ptr %13, align 1\n %15 = icmp ule i8 %10, %14\n %16 = sext i1 %15 to i32\n %17 = add i32 %9, %16\n %18 = load i8, ptr getelementptr (i8, ptr @r, i64 -16098), align 1\n %19 = trunc i8 %18 to i1\n %20 = select i1 %19, i64 %0, i64 0\n %21 = getelementptr i8, ptr @r, i64 %20\n %22 = load i8, ptr %21, align 1\n %23 = icmp ule i8 %18, %22\n %24 = sext i1 %23 to i32\n %25 = add i32 %17, %24\n %26 = load i8, ptr getelementptr (i8, ptr @r, i64 -24147), align 1\n %27 = trunc i8 %26 to i1\n %28 = select i1 %27, i64 %0, i64 0\n %29 = getelementptr i8, ptr @r, i64 %28\n %30 = load i8, ptr %29, align 1\n %31 = icmp ule i8 %26, %30\n %32 = sext i1 %31 to i32\n %33 = add i32 %25, %32\n store i32 %33, ptr %1, align 4\n ret void\n}"
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "issue": {
45
+ "title": "[SLPVectorizer] Segmentation Fault using opt \"-passes=lto<O3>\"",
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 i32\n@g = internal global i16 -8049\n@r = external global [8 x i8]\n\ndefine internal void @c(i16 %g, ptr %r) #0 {\nentry:\n br label %for.cond16.preheader.us.us.us.us\n\nfor.cond16.preheader.us.us.us.us: ; preds = %for.cond.cleanup20.split.us.us.us.us.us, %entry\n %indvars.iv133 = phi i64 [ %indvars.iv.next134, %for.cond.cleanup20.split.us.us.us.us.us ], [ 0, %entry ]\n br label %for.body21.us.us.us.us.us\n\nfor.body21.us.us.us.us.us: ; preds = %for.body21.us.us.us.us.us, %for.cond16.preheader.us.us.us.us\n %sub74.us.us.us.us124.us = phi i32 [ 0, %for.cond16.preheader.us.us.us.us ], [ %sub74.us.us.us.us.us, %for.body21.us.us.us.us.us ]\n %w.0109.us.us.us.us.us = phi i16 [ 0, %for.cond16.preheader.us.us.us.us ], [ %add77.us.us.us.us.us, %for.body21.us.us.us.us.us ]\n %idxprom38.us.us.us.us.us = sext i16 %w.0109.us.us.us.us.us to i64\n %arrayidx48.us.us.us.us.us = getelementptr i8, ptr %r, i64 %idxprom38.us.us.us.us.us\n %0 = load i8, ptr %arrayidx48.us.us.us.us.us, align 1\n %loadedv49.us.us.us.us.us = trunc i8 %0 to i1\n %cond71.in.in.v.us.us.us.us.us = select i1 %loadedv49.us.us.us.us.us, i64 %indvars.iv133, i64 0\n %cond71.in.in.us.us.us.us.us = getelementptr i8, ptr %r, i64 %cond71.in.in.v.us.us.us.us.us\n %cond71.in.us.us.us.us.us = load i8, ptr %cond71.in.in.us.us.us.us.us, align 1\n %cmp72.us.us.us.us.us = icmp ule i8 %0, %cond71.in.us.us.us.us.us\n %conv73.neg.us.us.us.us.us = sext i1 %cmp72.us.us.us.us.us to i32\n %sub74.us.us.us.us.us = add i32 %sub74.us.us.us.us124.us, %conv73.neg.us.us.us.us.us\n store i32 %sub74.us.us.us.us124.us, ptr @a, align 4\n %add77.us.us.us.us.us = add i16 %w.0109.us.us.us.us.us, %g\n %cmp18.us.us.us.us.us = icmp slt i16 %add77.us.us.us.us.us, 0\n br i1 %cmp18.us.us.us.us.us, label %for.body21.us.us.us.us.us, label %for.cond.cleanup20.split.us.us.us.us.us\n\nfor.cond.cleanup20.split.us.us.us.us.us: ; preds = %for.body21.us.us.us.us.us\n %indvars.iv.next134 = add i64 %indvars.iv133, 1\n %1 = and i64 %indvars.iv133, 2147483648\n %cmp12.us.us.us.us = icmp eq i64 %1, 0\n br i1 %cmp12.us.us.us.us, label %for.cond16.preheader.us.us.us.us, label %for.cond5.loopexit.split.us.us.us.us\n\nfor.cond5.loopexit.split.us.us.us.us: ; preds = %for.cond.cleanup20.split.us.us.us.us.us\n ret void\n}\n\ndefine i32 @main() {\nentry:\n %0 = load i16, ptr @g, align 2\n call void @c(i16 %0, ptr @r)\n ret i32 0\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zaamo,+zalrsc,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl256b,+zvl32b,+zvl64b,-b,-e,-experimental-sdext,-experimental-sdtrig,-experimental-smctr,-experimental-ssctr,-experimental-svukte,-experimental-xqcia,-experimental-xqciac,-experimental-xqcicli,-experimental-xqcicm,-experimental-xqcics,-experimental-xqcicsr,-experimental-xqciint,-experimental-xqcilo,-experimental-xqcilsm,-experimental-xqcisls,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-experimental-zvbc32e,-experimental-zvkgs,-h,-sha,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smdbltrp,-smepmp,-smmpm,-smnpm,-smrnmi,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssdbltrp,-ssnpm,-sspm,-ssqosid,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-supm,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-svvptc,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xmipscmove,-xmipslsp,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zabha,-zacas,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-ztso,-zvbb,-zvbc,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\n```\n\n\nCommand/backtrace:\n```\n$ /scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt \"-passes=lto<O3>\" reduced.ll\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\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 -passes=lto<O3> reduced.ll\n1. Running pass \"function<eager-inv>(loop-mssa(licm<allowspeculation>),gvn<>,memcpyopt,dse,move-auto-init,mldst-motion<no-split-footer-bb>,loop(indvars,loop-deletion,loop-unroll-full),loop-distribute,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-unroll<O3>,transform-warning,sroa<preserve-cfg>,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>,sccp,instcombine<max-iterations=1;no-verify-fixpoint>,bdce,slp-vectorizer,vector-combine,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,jump-threading)\" on module \"reduced.ll\"\n2. Running pass \"slp-vectorizer\" on function \"c\"\n #0 0x000064a320d6dd02 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x34a8d02)\n #1 0x000064a320d6ad3f llvm::sys::RunSignalHandlers() (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x34a5d3f)\n #2 0x000064a320d6ae84 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #3 0x00007fe3fee45330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)\n #4 0x000064a31fc28b80 llvm::slpvectorizer::BoUpSLP::computeMinimumValueSizes()::'lambda1'(llvm::slpvectorizer::BoUpSLP::EdgeInfo const&)::operator()(llvm::slpvectorizer::BoUpSLP::EdgeInfo const&) const (.isra.0) SLPVectorizer.cpp:0:0\n #5 0x000064a31fcdc0bb llvm::slpvectorizer::BoUpSLP::computeMinimumValueSizes() (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x24170bb)\n #6 0x000064a31fcf9808 (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&, llvm::AssumptionCache*) SLPVectorizer.cpp:0:0\n #7 0x000064a31fcfc9ae llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x24379ae)\n #8 0x000064a31fd00c41 llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x243bc41)\n #9 0x000064a31fd04e32 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x243fe32)\n#10 0x000064a31fd0c6e0 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x24476e0)\n#11 0x000064a31fd0d336 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x2448336)\n#12 0x000064a31e87b285 llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0xfb6285)\n#13 0x000064a320b5976a 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+0x329476a)\n#14 0x000064a31e87d0d5 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+0xfb80d5)\n#15 0x000064a320b5807c llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x329307c)\n#16 0x000064a31e879675 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+0xfb4675)\n#17 0x000064a320b5865d 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+0x329365d)\n#18 0x000064a31e01d465 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+0x758465)\n#19 0x000064a31e00d6ee optMain (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x7486ee)\n#20 0x00007fe3fee2a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3\n#21 0x00007fe3fee2a28b call_init ./csu/../csu/libc-start.c:128:20\n#22 0x00007fe3fee2a28b __libc_start_main ./csu/../csu/libc-start.c:347:5\n#23 0x000064a31e003f45 _start (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x73ef45)\nSegmentation fault (core dumped)\n```\n\nGodbolt: https://godbolt.org/z/P3sGYsGYc\n\nFound via fuzzer (C program before reduction)",
47
+ "author": "ewlu",
48
+ "labels": [
49
+ "llvm:SLPVectorizer",
50
+ "crash"
51
+ ],
52
+ "comments": []
53
+ },
54
+ "verified": true
55
+ }
dataset/127739.json ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "127739",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/127739",
4
+ "bug_type": "crash",
5
+ "base_commit": "d6301b218c6698ceb0db1753c8de480d37d11cf8",
6
+ "knowledge_cutoff": "2025-02-19T03:17:57Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/Scalarizer"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "1440f02259abf585f0c2965bd4ececf0f3499405",
12
+ "components": [
13
+ "Scalarizer"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Scalar/Scalarizer.cpp": [
17
+ [
18
+ 719,
19
+ 731
20
+ ],
21
+ [
22
+ 1083,
23
+ 1088
24
+ ]
25
+ ]
26
+ },
27
+ "bug_location_funcname": {
28
+ "llvm/lib/Transforms/Scalar/Scalarizer.cpp": [
29
+ "ScalarizerVisitor::splitCall",
30
+ "ScalarizerVisitor::visitExtractValueInst"
31
+ ]
32
+ }
33
+ },
34
+ "patch": "commit 1440f02259abf585f0c2965bd4ececf0f3499405\nAuthor: Deric C. <[email protected]>\nDate: Tue Mar 4 13:10:31 2025 -0800\n\n [Scalarizer] Ensure valid VectorSplits for each struct element in `visitExtractValueInst` (#128538)\n \n Fixes #127739\n \n The `visitExtractValueInst` is missing a check that was present in\n `splitCall` / `visitCallInst`.\n This check ensures that each struct element has a VectorSplit, and that\n each VectorSplit contains the same number of elements packed per\n fragment.\n \n ---------\n \n Co-authored-by: Jay Foad <[email protected]>\n\ndiff --git a/llvm/lib/Transforms/Scalar/Scalarizer.cpp b/llvm/lib/Transforms/Scalar/Scalarizer.cpp\nindex 2b27150112ad..820c8e12d244 100644\n--- a/llvm/lib/Transforms/Scalar/Scalarizer.cpp\n+++ b/llvm/lib/Transforms/Scalar/Scalarizer.cpp\n@@ -719,13 +719,12 @@ bool ScalarizerVisitor::splitCall(CallInst &CI) {\n for (unsigned I = 1; I < CallType->getNumContainedTypes(); I++) {\n std::optional<VectorSplit> CurrVS =\n getVectorSplit(cast<FixedVectorType>(CallType->getContainedType(I)));\n- // This case does not seem to happen, but it is possible for\n- // VectorSplit.NumPacked >= NumElems. If that happens a VectorSplit\n- // is not returned and we will bailout of handling this call.\n- // The secondary bailout case is if NumPacked does not match.\n- // This can happen if ScalarizeMinBits is not set to the default.\n- // This means with certain ScalarizeMinBits intrinsics like frexp\n- // will only scalarize when the struct elements have the same bitness.\n+ // It is possible for VectorSplit.NumPacked >= NumElems. If that happens a\n+ // VectorSplit is not returned and we will bailout of handling this call.\n+ // The secondary bailout case is if NumPacked does not match. This can\n+ // happen if ScalarizeMinBits is not set to the default. This means with\n+ // certain ScalarizeMinBits intrinsics like frexp will only scalarize when\n+ // the struct elements have the same bitness.\n if (!CurrVS || CurrVS->NumPacked != VS->NumPacked)\n return false;\n if (isVectorIntrinsicWithStructReturnOverloadAtField(ID, I, TTI))\n@@ -1083,6 +1082,18 @@ bool ScalarizerVisitor::visitExtractValueInst(ExtractValueInst &EVI) {\n std::optional<VectorSplit> VS = getVectorSplit(VecType);\n if (!VS)\n return false;\n+ for (unsigned I = 1; I < OpTy->getNumContainedTypes(); I++) {\n+ std::optional<VectorSplit> CurrVS =\n+ getVectorSplit(cast<FixedVectorType>(OpTy->getContainedType(I)));\n+ // It is possible for VectorSplit.NumPacked >= NumElems. If that happens a\n+ // VectorSplit is not returned and we will bailout of handling this call.\n+ // The secondary bailout case is if NumPacked does not match. This can\n+ // happen if ScalarizeMinBits is not set to the default. This means with\n+ // certain ScalarizeMinBits intrinsics like frexp will only scalarize when\n+ // the struct elements have the same bitness.\n+ if (!CurrVS || CurrVS->NumPacked != VS->NumPacked)\n+ return false;\n+ }\n IRBuilder<> Builder(&EVI);\n Scatterer Op0 = scatter(&EVI, Op, *VS);\n assert(!EVI.getIndices().empty() && \"Make sure an index exists\");\n",
35
+ "tests": [
36
+ {
37
+ "file": "llvm/test/Transforms/Scalarizer/min-bits.ll",
38
+ "commands": [
39
+ "opt %s -passes='function(scalarizer<load-store;min-bits=16>,dce)' -S",
40
+ "opt %s -passes='function(scalarizer<load-store;min-bits=32>,dce)' -S",
41
+ "opt %s -passes='function(scalarizer<load-store;min-bits=64>,dce)' -S"
42
+ ],
43
+ "tests": [
44
+ {
45
+ "test_name": "load_add_store_v2i16",
46
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine void @load_add_store_v2i16(ptr %pa, ptr %pb) {\n %a = load <2 x i16>, ptr %pa, align 8\n %b = load <2 x i16>, ptr %pb, align 8\n %c = add <2 x i16> %a, %b\n store <2 x i16> %c, ptr %pa, align 8\n ret void\n}\n"
47
+ },
48
+ {
49
+ "test_name": "select_uniform_condition_v3f16",
50
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine <3 x half> @select_uniform_condition_v3f16(<3 x half> %a, <3 x half> %b, i1 %cc) {\n %r = select i1 %cc, <3 x half> %a, <3 x half> %b\n ret <3 x half> %r\n}\n"
51
+ },
52
+ {
53
+ "test_name": "call_v4f16",
54
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine <4 x half> @call_v4f16(<4 x half> %a, <4 x half> %b) {\n %r = call <4 x half> @llvm.minnum.v4f16(<4 x half> %a, <4 x half> %b)\n ret <4 x half> %r\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x half> @llvm.minnum.v4f16(<4 x half>, <4 x half>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"
55
+ },
56
+ {
57
+ "test_name": "unary_v4f16",
58
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine <4 x half> @unary_v4f16(<4 x half> %a) {\n %r = fneg <4 x half> %a\n ret <4 x half> %r\n}\n"
59
+ },
60
+ {
61
+ "test_name": "gep1_v4",
62
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine <4 x ptr> @gep1_v4(ptr %base, <4 x i16> %a) {\n %p = getelementptr i32, ptr %base, <4 x i16> %a\n ret <4 x ptr> %p\n}\n"
63
+ },
64
+ {
65
+ "test_name": "fptosi_v3f16",
66
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine <3 x i16> @fptosi_v3f16(<3 x half> %a) {\n %r = fptosi <3 x half> %a to <3 x i16>\n ret <3 x i16> %r\n}\n"
67
+ },
68
+ {
69
+ "test_name": "binary_v2f16",
70
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine <2 x half> @binary_v2f16(<2 x half> %a, <2 x half> %b) {\n %r = fadd <2 x half> %a, %b\n ret <2 x half> %r\n}\n"
71
+ },
72
+ {
73
+ "test_name": "gep3_v4",
74
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine <4 x ptr> @gep3_v4(<4 x ptr> %base, <4 x i16> %a) {\n %p = getelementptr i32, <4 x ptr> %base, <4 x i16> %a\n ret <4 x ptr> %p\n}\n"
75
+ },
76
+ {
77
+ "test_name": "fptosi_v4f16",
78
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine <4 x i16> @fptosi_v4f16(<4 x half> %a) {\n %r = fptosi <4 x half> %a to <4 x i16>\n ret <4 x i16> %r\n}\n"
79
+ },
80
+ {
81
+ "test_name": "binary_v3f16",
82
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine <3 x half> @binary_v3f16(<3 x half> %a, <3 x half> %b) {\n %r = fadd <3 x half> %a, %b\n ret <3 x half> %r\n}\n"
83
+ },
84
+ {
85
+ "test_name": "load_add_store_v4i16",
86
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine void @load_add_store_v4i16(ptr %pa, ptr %pb) {\n %a = load <4 x i16>, ptr %pa, align 8\n %b = load <4 x i16>, ptr %pb, align 8\n %c = add <4 x i16> %a, %b\n store <4 x i16> %c, ptr %pa, align 8\n ret void\n}\n"
87
+ },
88
+ {
89
+ "test_name": "select_uniform_condition_v2f16",
90
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine <2 x half> @select_uniform_condition_v2f16(<2 x half> %a, <2 x half> %b, i1 %cc) {\n %r = select i1 %cc, <2 x half> %a, <2 x half> %b\n ret <2 x half> %r\n}\n"
91
+ },
92
+ {
93
+ "test_name": "shufflevector_shrink",
94
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine void @shufflevector_shrink(ptr %pa) {\n %a = load <4 x i16>, ptr %pa, align 8\n %r = shufflevector <4 x i16> %a, <4 x i16> poison, <2 x i32> <i32 1, i32 2>\n store <2 x i16> %r, ptr %pa, align 4\n ret void\n}\n"
95
+ },
96
+ {
97
+ "test_name": "phi_v2f16",
98
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine void @phi_v2f16(ptr %base, i64 %bound) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %x = phi <2 x half> [ zeroinitializer, %entry ], [ %x.next, %loop ]\n %idx = phi i64 [ 0, %entry ], [ %idx.next, %loop ]\n %p = getelementptr <2 x half>, ptr %base, i64 %idx\n %a = load <2 x half>, ptr %p, align 2\n %x.next = fadd <2 x half> %x, %a\n %idx.next = add i64 %idx, 1\n %cc = icmp ult i64 %idx.next, %bound\n br i1 %cc, label %loop, label %end\n\nend: ; preds = %loop\n store <2 x half> %x.next, ptr %base, align 4\n ret void\n}\n"
99
+ },
100
+ {
101
+ "test_name": "frexp_v2f16",
102
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine noundef <2 x half> @frexp_v2f16(<2 x half> noundef %h) {\n %r = call { <2 x half>, <2 x i32> } @llvm.frexp.v2f16.v2i32(<2 x half> %h)\n %e0 = extractvalue { <2 x half>, <2 x i32> } %r, 0\n ret <2 x half> %e0\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare { <2 x half>, <2 x i32> } @llvm.frexp.v2f16.v2i32(<2 x half>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"
103
+ },
104
+ {
105
+ "test_name": "load_insertelement_v3i16",
106
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine <3 x i16> @load_insertelement_v3i16(ptr %pa, i16 %b) {\n %a = load <3 x i16>, ptr %pa, align 8\n %r = insertelement <3 x i16> %a, i16 %b, i64 2\n ret <3 x i16> %r\n}\n"
107
+ },
108
+ {
109
+ "test_name": "load_add_store_v3i16",
110
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine void @load_add_store_v3i16(ptr %pa, ptr %pb) {\n %a = load <3 x i16>, ptr %pa, align 8\n %b = load <3 x i16>, ptr %pb, align 8\n %c = add <3 x i16> %a, %b\n store <3 x i16> %c, ptr %pa, align 8\n ret void\n}\n"
111
+ },
112
+ {
113
+ "test_name": "fptosi_v2f16",
114
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine <2 x i16> @fptosi_v2f16(<2 x half> %a) {\n %r = fptosi <2 x half> %a to <2 x i16>\n ret <2 x i16> %r\n}\n"
115
+ },
116
+ {
117
+ "test_name": "insertelement_v4i16",
118
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine void @insertelement_v4i16(ptr %p, <4 x i16> %a, i16 %b) {\n %r = insertelement <4 x i16> %a, i16 %b, i64 3\n store <4 x i16> %r, ptr %p, align 8\n ret void\n}\n"
119
+ },
120
+ {
121
+ "test_name": "load_insertelement_v2i16",
122
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine <2 x i16> @load_insertelement_v2i16(ptr %pa, i16 %b) {\n %a = load <2 x i16>, ptr %pa, align 4\n %r = insertelement <2 x i16> %a, i16 %b, i64 1\n ret <2 x i16> %r\n}\n"
123
+ },
124
+ {
125
+ "test_name": "load_insertelement_v4i16",
126
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine <4 x i16> @load_insertelement_v4i16(ptr %pa, i16 %b) {\n %a = load <4 x i16>, ptr %pa, align 8\n %r = insertelement <4 x i16> %a, i16 %b, i64 3\n ret <4 x i16> %r\n}\n"
127
+ },
128
+ {
129
+ "test_name": "insertelement_v2i16",
130
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine void @insertelement_v2i16(ptr %p, <2 x i16> %a, i16 %b) {\n %r = insertelement <2 x i16> %a, i16 %b, i64 1\n store <2 x i16> %r, ptr %p, align 4\n ret void\n}\n"
131
+ },
132
+ {
133
+ "test_name": "shufflevector_grow",
134
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine void @shufflevector_grow(ptr %pa, ptr %pb) {\n %a = load <2 x i16>, ptr %pa, align 4\n %b = load <2 x i16>, ptr %pb, align 4\n %r = shufflevector <2 x i16> %a, <2 x i16> %b, <4 x i32> <i32 0, i32 1, i32 2, i32 3>\n store <4 x i16> %r, ptr %pa, align 8\n ret void\n}\n"
135
+ },
136
+ {
137
+ "test_name": "uadd_with_overflow_v3i32",
138
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine <3 x i32> @uadd_with_overflow_v3i32(<3 x i32> %a, <3 x i32> %b) {\n %t = call { <3 x i32>, <3 x i1> } @llvm.uadd.with.overflow.v3i32(<3 x i32> %a, <3 x i32> %b)\n %r = extractvalue { <3 x i32>, <3 x i1> } %t, 0\n ret <3 x i32> %r\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare { <3 x i32>, <3 x i1> } @llvm.uadd.with.overflow.v3i32(<3 x i32>, <3 x i32>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"
139
+ },
140
+ {
141
+ "test_name": "insertelement_v3i16",
142
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine void @insertelement_v3i16(ptr %p, <3 x i16> %a, i16 %b) {\n %r = insertelement <3 x i16> %a, i16 %b, i64 2\n store <3 x i16> %r, ptr %p, align 8\n ret void\n}\n"
143
+ },
144
+ {
145
+ "test_name": "call_v2f16",
146
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine <2 x half> @call_v2f16(<2 x half> %a, <2 x half> %b) {\n %r = call <2 x half> @llvm.minnum.v2f16(<2 x half> %a, <2 x half> %b)\n ret <2 x half> %r\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <2 x half> @llvm.minnum.v2f16(<2 x half>, <2 x half>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"
147
+ },
148
+ {
149
+ "test_name": "phi_v3f16",
150
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine void @phi_v3f16(ptr %base, i64 %bound) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %x = phi <3 x half> [ zeroinitializer, %entry ], [ %x.next, %loop ]\n %idx = phi i64 [ 0, %entry ], [ %idx.next, %loop ]\n %p = getelementptr <3 x half>, ptr %base, i64 %idx\n %a = load <3 x half>, ptr %p, align 2\n %x.next = fadd <3 x half> %x, %a\n %idx.next = add i64 %idx, 1\n %cc = icmp ult i64 %idx.next, %bound\n br i1 %cc, label %loop, label %end\n\nend: ; preds = %loop\n store <3 x half> %x.next, ptr %base, align 8\n ret void\n}\n"
151
+ },
152
+ {
153
+ "test_name": "phi_v4f16",
154
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine void @phi_v4f16(ptr %base, i64 %bound) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %x = phi <4 x half> [ zeroinitializer, %entry ], [ %x.next, %loop ]\n %idx = phi i64 [ 0, %entry ], [ %idx.next, %loop ]\n %p = getelementptr <4 x half>, ptr %base, i64 %idx\n %a = load <4 x half>, ptr %p, align 2\n %x.next = fadd <4 x half> %x, %a\n %idx.next = add i64 %idx, 1\n %cc = icmp ult i64 %idx.next, %bound\n br i1 %cc, label %loop, label %end\n\nend: ; preds = %loop\n store <4 x half> %x.next, ptr %base, align 8\n ret void\n}\n"
155
+ },
156
+ {
157
+ "test_name": "call_v3f16",
158
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine <3 x half> @call_v3f16(<3 x half> %a, <3 x half> %b) {\n %r = call <3 x half> @llvm.minnum.v3f16(<3 x half> %a, <3 x half> %b)\n ret <3 x half> %r\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <3 x half> @llvm.minnum.v3f16(<3 x half>, <3 x half>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"
159
+ },
160
+ {
161
+ "test_name": "binary_v4f16",
162
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine <4 x half> @binary_v4f16(<4 x half> %a, <4 x half> %b) {\n %r = fadd <4 x half> %a, %b\n ret <4 x half> %r\n}\n"
163
+ },
164
+ {
165
+ "test_name": "fpext_v4f16",
166
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine <4 x float> @fpext_v4f16(<4 x half> %a) {\n %r = fpext <4 x half> %a to <4 x float>\n ret <4 x float> %r\n}\n"
167
+ },
168
+ {
169
+ "test_name": "load_add_store_v4i10",
170
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine void @load_add_store_v4i10(ptr %pa, ptr %pb) {\n %a = load <4 x i10>, ptr %pa, align 8\n %b = load <4 x i10>, ptr %pb, align 8\n %c = add <4 x i10> %a, %b\n store <4 x i10> %c, ptr %pa, align 8\n ret void\n}\n"
171
+ },
172
+ {
173
+ "test_name": "unary_v3f16",
174
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine <3 x half> @unary_v3f16(<3 x half> %a) {\n %r = fneg <3 x half> %a\n ret <3 x half> %r\n}\n"
175
+ },
176
+ {
177
+ "test_name": "unary_v2f16",
178
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine <2 x half> @unary_v2f16(<2 x half> %a) {\n %r = fneg <2 x half> %a\n ret <2 x half> %r\n}\n"
179
+ },
180
+ {
181
+ "test_name": "select_uniform_condition_v4f16",
182
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine <4 x half> @select_uniform_condition_v4f16(<4 x half> %a, <4 x half> %b, i1 %cc) {\n %r = select i1 %cc, <4 x half> %a, <4 x half> %b\n ret <4 x half> %r\n}\n"
183
+ }
184
+ ]
185
+ }
186
+ ],
187
+ "issue": {
188
+ "title": "[Scalarizer] Test *_with_overflow crash with min-bits=32 and min-bits=16",
189
+ "body": "first reported here: https://github.com/llvm/llvm-project/pull/127520\nintroduced by: https://github.com/llvm/llvm-project/pull/126815\n\n```llvm\n; RUN: opt %s -passes='function(scalarizer<load-store;min-bits=16>,dce)' -S | FileCheck %s --check-prefixes=CHECK,MIN16\n; RUN: opt %s -passes='function(scalarizer<load-store;min-bits=32>,dce)' -S | FileCheck %s --check-prefixes=CHECK,MIN32\n\ndefine <3 x i32> @call_v3i32(<3 x i32> %a, <3 x i32> %b) {\n; CHECK-LABEL: @call_v3i32(\n; CHECK-NEXT: [[T:%.*]] = call { <3 x i32>, <3 x i1> } @llvm.uadd.with.overflow.v3i32(<3 x i32> [[A:%.*]], <3 x i32> [[B:%.*]])\n; CHECK-NEXT: [[R:%.*]] = extractvalue { <3 x i32>, <3 x i1> } [[T]], 0\n; CHECK-NEXT: ret <3 x i32> [[R]]\n;\n %t = call { <3 x i32>, <3 x i1> } @llvm.uadd.with.overflow.v3i32(<3 x i32> %a, <3 x i32> %b)\n %r = extractvalue { <3 x i32>, <3 x i1> } %t, 0\n ret <3 x i32> %r\n}\n\n```\n\n```bash\nopt: include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From *) [To = llvm::VectorType, From = llvm::Type]: Assertion `isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\"' 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 -passes=function(scalarizer<load-store;min-bits=16>,dce) -S\n1.\tRunning pass \"function(scalarizer,dce)\" on module \"<stdin>\"\n2.\tRunning pass \"scalarizer\" on function \"call_v3i32\"\n #0 0x0000000004028908 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (opt+0x4028908)\n #1 0x000000000402643e llvm::sys::RunSignalHandlers() (opt+0x402643e)\n #2 0x0000000004029131 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #3 0x000075c457a45330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)\n #4 0x000075c457a9eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #5 0x000075c457a9eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #6 0x000075c457a9eb2c pthread_kill ./nptl/pthread_kill.c:89:10\n #7 0x000075c457a4527e raise ./signal/../sysdeps/posix/raise.c:27:6\n #8 0x000075c457a288ff abort ./stdlib/abort.c:81:7\n #9 0x000075c457a2881b _nl_load_domain ./intl/loadmsgcat.c:1177:9\n#10 0x000075c457a3b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)\n#11 0x0000000004143bea (opt+0x4143bea)\n#12 0x00000000049addf4 (anonymous namespace)::Scatterer::operator[](unsigned int) Scalarizer.cpp:0:0\n#13 0x00000000049aa142 (anonymous namespace)::ScalarizerVisitor::visit(llvm::Function&) Scalarizer.cpp:0:0\n#14 0x00000000049a5419 llvm::ScalarizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (opt+0x49a5419)\n```\n\nNo line numbers, Looks like we have some missing debug symbols I suspect the assert is coming from `ScalarizerVisitor::visitExtractValueInst`\n\nThere is a use of Scatterer::operator[] as part of creating the ExtractValue IR.\n\n```cpp\nfor (unsigned OpIdx = 0; OpIdx < Op0.size(); ++OpIdx) {\n Value *ResElem = Builder.CreateExtractValue(\n Op0[OpIdx], Index, EVI.getName() + \".elem\" + Twine(Index));\n Res.push_back(ResElem);\n }\n```\n\nWe likely need to check `VS.NumPacked` before calling `Scatterer::operator[]`\n\nBecause that operator is using `Frag * VS.NumPacked` to create the exrtractElement instruction.\n\n```cpp\n CV[Frag] = Builder.CreateExtractElement(V, Frag * VS.NumPacked,\n V->getName() + \".i\" + Twine(Frag))\n```\n\n ",
190
+ "author": "farzonl",
191
+ "labels": [
192
+ "crash-on-valid",
193
+ "llvm:analysis"
194
+ ],
195
+ "comments": [
196
+ {
197
+ "author": "farzonl",
198
+ "body": "@Icohedron can you look into this issue. I'm also noticing a second potential issue:\n\n`call { <3 x i32>, <3 x i1> }`\n\nThe struct return elements are not the same type. one is vec3 of i32 one is and one is vec3 of i1. you need to add the `*_with_overflow` intrinsics to `isVectorIntrinsicWithStructReturnOverloadAtField` if these types are not the same."
199
+ },
200
+ {
201
+ "author": "Icohedron",
202
+ "body": "I'm on it"
203
+ },
204
+ {
205
+ "author": "jayfoad",
206
+ "body": "As mentioned in #127996, note that you can also provoke this bug by adding `min-bits=64` to `test/Transforms/Scalarizer/frexp.ll`."
207
+ },
208
+ {
209
+ "author": "Icohedron",
210
+ "body": "> [@Icohedron](https://github.com/Icohedron) can you look into this issue. I'm also noticing a second potential issue:\n> \n> `call { <3 x i32>, <3 x i1> }`\n> \n> The struct return elements are not the same type. one is vec3 of i32 one is and one is vec3 of i1. you need to add the `*_with_overflow` intrinsics to `isVectorIntrinsicWithStructReturnOverloadAtField` if these types are not the same.\n\n`isVectorIntrinsicWithStructReturnOverloadAtField` appears to only be for intrinsic name-mangling when there is more than one possible type for the the 2nd element in the struct return type (see [splitCall](https://github.com/llvm/llvm-project/blob/5f8da7e7738f043dbde447e48622e9b2afb5ba92/llvm/lib/Transforms/Scalar/Scalarizer.cpp#L770) and [getOrInsertDeclaration](https://github.com/llvm/llvm-project/blob/5f8da7e7738f043dbde447e48622e9b2afb5ba92/llvm/lib/IR/Intrinsics.cpp#L763)). For the `*_with_overflow` intrinsics, the 2nd element of the return struct is always i1, so it does not need to be added to `isVectorIntrinsicWithStructReturnOverloadAtField`.\n\nAdding the `*_with_overflow` intrinsic to `isVectorIntrinsicWithStructReturnOverloadAtField` results in a broken LLVM module.\n```\nIntrinsic name not mangled correctly for type arguments! Should be: llvm.uadd.with.overflow.i32\nptr @llvm.uadd.with.overflow.i32.i1\nLLVM ERROR: Broken module found, compilation aborted!\n```"
211
+ }
212
+ ]
213
+ },
214
+ "verified": true
215
+ }
dataset/128401.json CHANGED
@@ -26,8 +26,8 @@
26
  },
27
  "bug_location_funcname": {
28
  "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
29
- "BoUpSLP::isGatherShuffledSingleRegisterEntry",
30
- "BoUpSLP::isGatherShuffledEntry"
31
  ]
32
  }
33
  },
 
26
  },
27
  "bug_location_funcname": {
28
  "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
29
+ "BoUpSLP::isGatherShuffledEntry",
30
+ "BoUpSLP::isGatherShuffledSingleRegisterEntry"
31
  ]
32
  }
33
  },
dataset/128736.json CHANGED
@@ -46,9 +46,9 @@
46
  },
47
  "bug_location_funcname": {
48
  "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
49
- "tryToReduce",
50
  "removeInstructionsAndOperands",
51
- "BoUpSLP::vectorizeTree"
52
  ]
53
  }
54
  },
 
46
  },
47
  "bug_location_funcname": {
48
  "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
49
+ "BoUpSLP::vectorizeTree",
50
  "removeInstructionsAndOperands",
51
+ "tryToReduce"
52
  ]
53
  }
54
  },
dataset/128838.json ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "128838",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/128838",
4
+ "bug_type": "crash",
5
+ "base_commit": "9c65e6ac115a7d8566c874537791125c3ace7c1a",
6
+ "knowledge_cutoff": "2025-02-26T07:25:33Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "62994c3291239f3d11f958d002319b2bd6eddbc9",
12
+ "components": [
13
+ "LoopVectorize"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
17
+ [
18
+ 7691,
19
+ 7701
20
+ ]
21
+ ],
22
+ "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
23
+ [
24
+ 2180,
25
+ 2186
26
+ ],
27
+ [
28
+ 2189,
29
+ 2206
30
+ ],
31
+ [
32
+ 2210,
33
+ 2219
34
+ ]
35
+ ],
36
+ "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": [
37
+ [
38
+ 189,
39
+ 196
40
+ ]
41
+ ]
42
+ },
43
+ "bug_location_funcname": {
44
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
45
+ "LoopVectorizationPlanner::executePlan"
46
+ ],
47
+ "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
48
+ "VPlanTransforms::handleUncountableEarlyExit",
49
+ "VPlanTransforms::materializeLiveInBroadcasts"
50
+ ]
51
+ }
52
+ },
53
+ "patch": "commit 62994c3291239f3d11f958d002319b2bd6eddbc9\nAuthor: Florian Hahn <[email protected]>\nDate: Wed Mar 12 22:03:18 2025 +0000\n\n [VPlan] Also introduce explicit broadcasts for values from entry VPBB.\n \n Update and generalize materializeBroadcasts to also introduce explicit\n broadcasts for VPValues defined in the Plans Entry block.\n \n This fixes a crash when trying to insert the broadcasts generated by\n VPTransformState::get after the generating instruction, which isn't\n possible after invoke instructions.\n \n Fixes https://github.com/llvm/llvm-project/issues/128838.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\nindex bab2c6efd403..02bacde3f60a 100644\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n@@ -7691,11 +7691,11 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(\n ((VectorizingEpilogue && ExpandedSCEVs) ||\n (!VectorizingEpilogue && !ExpandedSCEVs)) &&\n \"expanded SCEVs to reuse can only be used during epilogue vectorization\");\n- VPlanTransforms::materializeLiveInBroadcasts(BestVPlan);\n // TODO: Move to VPlan transform stage once the transition to the VPlan-based\n // cost model is complete for better cost estimates.\n VPlanTransforms::runPass(VPlanTransforms::unrollByUF, BestVPlan, BestUF,\n OrigLoop->getHeader()->getContext());\n+ VPlanTransforms::materializeBroadcasts(BestVPlan);\n VPlanTransforms::optimizeForVFAndUF(BestVPlan, BestVF, BestUF, PSE);\n VPlanTransforms::simplifyRecipes(BestVPlan, *Legal->getWidestInductionType());\n VPlanTransforms::removeDeadRecipes(BestVPlan);\ndiff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp\nindex ecf52673480e..f23795f87d46 100644\n--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp\n+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp\n@@ -2180,7 +2180,7 @@ void VPlanTransforms::handleUncountableEarlyExit(\n LatchExitingBranch->eraseFromParent();\n }\n \n-void VPlanTransforms::materializeLiveInBroadcasts(VPlan &Plan) {\n+void VPlanTransforms::materializeBroadcasts(VPlan &Plan) {\n if (Plan.hasScalarVFOnly())\n return;\n \n@@ -2189,18 +2189,25 @@ void VPlanTransforms::materializeLiveInBroadcasts(VPlan &Plan) {\n VPDT.recalculate(Plan);\n #endif\n \n+ SmallVector<VPValue *> VPValues;\n+ append_range(VPValues, Plan.getLiveIns());\n+ for (VPRecipeBase &R : *Plan.getEntry())\n+ append_range(VPValues, R.definedValues());\n+\n auto *VectorPreheader = Plan.getVectorPreheader();\n- for (VPValue *LiveIn : Plan.getLiveIns()) {\n- if (all_of(LiveIn->users(),\n- [LiveIn](VPUser *U) { return U->usesScalars(LiveIn); }) ||\n- !LiveIn->getLiveInIRValue() ||\n- isa<Constant>(LiveIn->getLiveInIRValue()))\n+ for (VPValue *VPV : VPValues) {\n+ if (all_of(VPV->users(),\n+ [VPV](VPUser *U) { return U->usesScalars(VPV); }) ||\n+ (VPV->isLiveIn() &&\n+ (!VPV->getLiveInIRValue() || isa<Constant>(VPV->getLiveInIRValue()))))\n continue;\n \n // Add explicit broadcast at the insert point that dominates all users.\n VPBasicBlock *HoistBlock = VectorPreheader;\n VPBasicBlock::iterator HoistPoint = VectorPreheader->end();\n- for (VPUser *User : LiveIn->users()) {\n+ for (VPUser *User : VPV->users()) {\n+ if (User->usesScalars(VPV))\n+ continue;\n if (cast<VPRecipeBase>(User)->getParent() == VectorPreheader)\n HoistPoint = HoistBlock->begin();\n else\n@@ -2210,10 +2217,10 @@ void VPlanTransforms::materializeLiveInBroadcasts(VPlan &Plan) {\n }\n \n VPBuilder Builder(cast<VPBasicBlock>(HoistBlock), HoistPoint);\n- auto *Broadcast = Builder.createNaryOp(VPInstruction::Broadcast, {LiveIn});\n- LiveIn->replaceUsesWithIf(\n- Broadcast, [LiveIn, Broadcast](VPUser &U, unsigned Idx) {\n- return Broadcast != &U && !U.usesScalars(LiveIn);\n- });\n+ auto *Broadcast = Builder.createNaryOp(VPInstruction::Broadcast, {VPV});\n+ VPV->replaceUsesWithIf(Broadcast,\n+ [VPV, Broadcast](VPUser &U, unsigned Idx) {\n+ return Broadcast != &U && !U.usesScalars(VPV);\n+ });\n }\n }\ndiff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.h b/llvm/lib/Transforms/Vectorize/VPlanTransforms.h\nindex 8a9a81e00fe2..2ec07eea1ecc 100644\n--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.h\n+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.h\n@@ -189,8 +189,8 @@ struct VPlanTransforms {\n optimizeInductionExitUsers(VPlan &Plan,\n DenseMap<VPValue *, VPValue *> &EndValues);\n \n- /// Add explicit broadcasts for live-ins used as vectors.\n- static void materializeLiveInBroadcasts(VPlan &Plan);\n+ /// Add explicit broadcasts for live-ins and VPValues defined in \\p Plan's entry block if they are used as vectors.\n+ static void materializeBroadcasts(VPlan &Plan);\n };\n \n } // namespace llvm\n",
54
+ "tests": [
55
+ {
56
+ "file": "llvm/test/Transforms/LoopVectorize/RISCV/illegal-type.ll",
57
+ "commands": [
58
+ "opt < %s -passes=loop-vectorize -mattr=+v -force-vector-width=4 -scalable-vectorization=on -S 2>&1"
59
+ ],
60
+ "tests": [
61
+ {
62
+ "test_name": "uniform_store_i1",
63
+ "test_body": "target triple = \"riscv64-linux-gnu\"\n\ndefine void @uniform_store_i1(ptr noalias %dst, ptr noalias %start, i64 %N) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %first.sroa = phi ptr [ %incdec.ptr, %for.body ], [ %start, %entry ]\n %iv = phi i64 [ %iv.next, %for.body ], [ 0, %entry ]\n %iv.next = add i64 %iv, 1\n %incdec.ptr = getelementptr inbounds i64, ptr %first.sroa, i64 1\n %cmp.not = icmp eq ptr %incdec.ptr, %start\n store i1 %cmp.not, ptr %dst, align 1\n %cmp = icmp ult i64 %iv, %N\n br i1 %cmp, label %for.body, label %end, !llvm.loop !0\n\nend: ; preds = %for.body\n ret void\n}\n\n!0 = distinct !{!0, !1}\n!1 = !{!\"llvm.loop.vectorize.scalable.enable\", i1 true}\n"
64
+ }
65
+ ]
66
+ },
67
+ {
68
+ "file": "llvm/test/Transforms/LoopVectorize/X86/epilog-vectorization-inductions.ll",
69
+ "commands": [
70
+ "opt -passes=loop-vectorize -mcpu=znver2 -S %s"
71
+ ],
72
+ "tests": [
73
+ {
74
+ "test_name": "test_induction_step_needs_expansion",
75
+ "test_body": "target triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @test_induction_step_needs_expansion(ptr noalias %j, ptr %k, i64 %l, i16 %off) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %p.09 = phi i16 [ 0, %entry ], [ %add, %loop ]\n %add = sub i16 %p.09, %off\n %arrayidx3 = getelementptr inbounds i16, ptr %k, i64 %iv\n store i16 %add, ptr %arrayidx3, align 2\n %iv.next = add nuw nsw i64 %iv, 1\n %ec = icmp eq i64 %iv.next, %l\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n"
76
+ }
77
+ ]
78
+ },
79
+ {
80
+ "file": "llvm/test/Transforms/LoopVectorize/X86/induction-step.ll",
81
+ "commands": [
82
+ "opt -passes=loop-vectorize -force-vector-width=4 -S %s"
83
+ ],
84
+ "tests": [
85
+ {
86
+ "test_name": "wide_add_induction_step_live_in",
87
+ "test_body": "target triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i16 @wide_add_induction_step_live_in(ptr %dst, i64 %N, i16 %off) {\nentry:\n %o.1 = add i16 %off, 2\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.2 = phi i16 [ 0, %entry ], [ %add, %loop ]\n %add = add i16 %iv.2, %o.1\n %gep.dst = getelementptr inbounds i16, ptr %dst, i64 %iv\n store i16 %add, ptr %gep.dst, align 2\n %iv.next = add nuw nsw i64 %iv, 1\n %ec = icmp eq i64 %iv.next, %N\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i16 %add\n}\n"
88
+ },
89
+ {
90
+ "test_name": "wide_sub_induction_step_live_in",
91
+ "test_body": "target triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i16 @wide_sub_induction_step_live_in(ptr %dst, i64 %N, i16 %off) {\nentry:\n %o.1 = add i16 %off, 2\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.2 = phi i16 [ 0, %entry ], [ %sub, %loop ]\n %sub = sub i16 %iv.2, %o.1\n %gep.dst = getelementptr inbounds i16, ptr %dst, i64 %iv\n store i16 %sub, ptr %gep.dst, align 2\n %iv.next = add nuw nsw i64 %iv, 1\n %ec = icmp eq i64 %iv.next, %N\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i16 %sub\n}\n"
92
+ }
93
+ ]
94
+ },
95
+ {
96
+ "file": "llvm/test/Transforms/LoopVectorize/expand-scev-after-invoke.ll",
97
+ "commands": [
98
+ "opt -p loop-vectorize -force-vector-width=4 -force-vector-interleave=2 -S %s"
99
+ ],
100
+ "tests": [
101
+ {
102
+ "test_name": "<module>",
103
+ "test_body": "\ndeclare i32 @foo()\n\n; Test case for https://github.com/llvm/llvm-project/issues/128838. Make sure\n; we do not crash when expanding %step.\ndefine void @test(ptr %dst) personality ptr null {\n;\nentry:\n %step = invoke i32 @foo()\n to label %loop unwind label %lpad\n\nloop:\n %iv.1 = phi i64 [ 0, %entry ], [ %add, %loop ]\n %iv.2 = phi i32 [ 0, %entry ], [ %iv.2.next, %loop ]\n %add = add i64 %iv.1, 1\n %gep = getelementptr inbounds i32, ptr %dst, i64 %iv.1\n store i32 %iv.2, ptr %gep, align 8\n %iv.2.next = add i32 %iv.2, %step\n %ec = icmp ult i64 %iv.1, 161\n br i1 %ec, label %loop, label %exit\n\nexit:\n ret void\n\nlpad:\n %landingpad = landingpad { ptr, i32 }\n cleanup\n ret void\n}"
104
+ }
105
+ ]
106
+ },
107
+ {
108
+ "file": "llvm/test/Transforms/LoopVectorize/float-induction.ll",
109
+ "commands": [
110
+ "opt < %s -passes=loop-vectorize,dce,instcombine -force-vector-interleave=1 -force-vector-width=4 -S",
111
+ "opt < %s -passes=loop-vectorize,dce,instcombine -force-vector-interleave=2 -force-vector-width=4 -S",
112
+ "opt < %s -passes=loop-vectorize,dce,instcombine -force-vector-interleave=2 -force-vector-width=1 -S",
113
+ "opt < %s -passes=loop-vectorize,dce,simplifycfg,instcombine,simplifycfg -force-vector-interleave=1 -force-vector-width=2 -simplifycfg-require-and-preserve-domtree=1 -keep-loops=false -S"
114
+ ],
115
+ "tests": [
116
+ {
117
+ "test_name": "fp_iv_loop1_fast_FMF",
118
+ "test_body": "@fp_inc = external global float, align 4\n\ndefine void @fp_iv_loop1_fast_FMF(float %init, ptr noalias captures(none) %A, i32 %N) {\nentry:\n %cmp4 = icmp sgt i32 %N, 0\n br i1 %cmp4, label %for.body.lr.ph, label %for.end\n\nfor.body.lr.ph: ; preds = %entry\n %fpinc = load float, ptr @fp_inc, align 4\n br label %for.body\n\nfor.body: ; preds = %for.body, %for.body.lr.ph\n %indvars.iv = phi i64 [ 0, %for.body.lr.ph ], [ %indvars.iv.next, %for.body ]\n %x.05 = phi float [ %init, %for.body.lr.ph ], [ %add, %for.body ]\n %arrayidx = getelementptr inbounds float, ptr %A, i64 %indvars.iv\n store float %x.05, ptr %arrayidx, align 4\n %add = fsub fast float %x.05, %fpinc\n %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1\n %lftr.wideiv = trunc i64 %indvars.iv.next to i32\n %exitcond = icmp eq i32 %lftr.wideiv, %N\n br i1 %exitcond, label %for.end.loopexit, label %for.body\n\nfor.end.loopexit: ; preds = %for.body\n br label %for.end\n\nfor.end: ; preds = %for.end.loopexit, %entry\n ret void\n}\n\n!llvm.module.flags = !{!0}\n\n!0 = !{i32 2, !\"Debug Info Version\", i32 3}\n"
119
+ },
120
+ {
121
+ "test_name": "fp_iv_loop3",
122
+ "test_body": "@fp_inc = external global float, align 4\n\ndefine void @fp_iv_loop3(float %init, ptr noalias captures(none) %A, ptr noalias captures(none) %B, ptr noalias captures(none) %C, i32 %N) {\nentry:\n %cmp9 = icmp sgt i32 %N, 0\n br i1 %cmp9, label %for.body.lr.ph, label %for.end\n\nfor.body.lr.ph: ; preds = %entry\n %0 = load float, ptr @fp_inc, align 4\n br label %for.body\n\nfor.body: ; preds = %for.body, %for.body.lr.ph\n %indvars.iv = phi i64 [ 0, %for.body.lr.ph ], [ %indvars.iv.next, %for.body ]\n %y.012 = phi float [ 0x3FB99999A0000000, %for.body.lr.ph ], [ %conv1, %for.body ]\n %x.011 = phi float [ %init, %for.body.lr.ph ], [ %add, %for.body ]\n %arrayidx = getelementptr inbounds float, ptr %A, i64 %indvars.iv\n store float %x.011, ptr %arrayidx, align 4\n %add = fadd fast float %x.011, %0\n %conv1 = fadd fast float %y.012, -5.000000e-01\n %add2 = fadd fast float %conv1, %add\n %arrayidx4 = getelementptr inbounds float, ptr %B, i64 %indvars.iv\n store float %add2, ptr %arrayidx4, align 4\n %arrayidx6 = getelementptr inbounds float, ptr %C, i64 %indvars.iv\n store float %conv1, ptr %arrayidx6, align 4\n %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1\n %lftr.wideiv = trunc i64 %indvars.iv.next to i32\n %exitcond = icmp eq i32 %lftr.wideiv, %N\n br i1 %exitcond, label %for.end.loopexit, label %for.body\n\nfor.end.loopexit: ; preds = %for.body\n br label %for.end\n\nfor.end: ; preds = %for.end.loopexit, %entry\n ret void\n}\n\n!llvm.module.flags = !{!0}\n\n!0 = !{i32 2, !\"Debug Info Version\", i32 3}\n"
123
+ },
124
+ {
125
+ "test_name": "fp_iv_loop1_reassoc_FMF",
126
+ "test_body": "@fp_inc = external global float, align 4\n\ndefine void @fp_iv_loop1_reassoc_FMF(float %init, ptr noalias captures(none) %A, i32 %N) {\nentry:\n %cmp4 = icmp sgt i32 %N, 0\n br i1 %cmp4, label %for.body.lr.ph, label %for.end\n\nfor.body.lr.ph: ; preds = %entry\n %fpinc = load float, ptr @fp_inc, align 4\n br label %for.body\n\nfor.body: ; preds = %for.body, %for.body.lr.ph\n %indvars.iv = phi i64 [ 0, %for.body.lr.ph ], [ %indvars.iv.next, %for.body ]\n %x.05 = phi float [ %init, %for.body.lr.ph ], [ %add, %for.body ]\n %arrayidx = getelementptr inbounds float, ptr %A, i64 %indvars.iv\n store float %x.05, ptr %arrayidx, align 4\n %add = fsub reassoc float %x.05, %fpinc\n %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1\n %lftr.wideiv = trunc i64 %indvars.iv.next to i32\n %exitcond = icmp eq i32 %lftr.wideiv, %N\n br i1 %exitcond, label %for.end.loopexit, label %for.body\n\nfor.end.loopexit: ; preds = %for.body\n br label %for.end\n\nfor.end: ; preds = %for.end.loopexit, %entry\n ret void\n}\n\n!llvm.module.flags = !{!0}\n\n!0 = !{i32 2, !\"Debug Info Version\", i32 3}\n"
127
+ }
128
+ ]
129
+ },
130
+ {
131
+ "file": "llvm/test/Transforms/LoopVectorize/induction-step.ll",
132
+ "commands": [
133
+ "opt < %s -passes=loop-vectorize -force-vector-interleave=1 -force-vector-width=8 -S"
134
+ ],
135
+ "tests": [
136
+ {
137
+ "test_name": "wide_add_induction_step_live_in",
138
+ "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\n\ndefine void @wide_add_induction_step_live_in(ptr %dst, i64 %N, i16 %off) {\nentry:\n %o.1 = add i16 %off, 2\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.2 = phi i16 [ 0, %entry ], [ %add, %loop ]\n %add = add i16 %iv.2, %o.1\n %gep.dst = getelementptr inbounds i16, ptr %dst, i64 %iv\n store i16 %add, ptr %gep.dst, align 2\n %iv.next = add nuw nsw i64 %iv, 1\n %ec = icmp eq i64 %iv.next, %N\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n"
139
+ }
140
+ ]
141
+ },
142
+ {
143
+ "file": "llvm/test/Transforms/LoopVectorize/induction.ll",
144
+ "commands": [
145
+ "opt < %s -passes=loop-vectorize -force-vector-interleave=1 -force-vector-width=2 -force-widen-divrem-via-safe-divisor=0 -S",
146
+ "opt < %s -passes=loop-vectorize,instcombine -force-vector-interleave=1 -force-vector-width=2 -force-widen-divrem-via-safe-divisor=0 -S",
147
+ "opt < %s -passes=loop-vectorize,instcombine -force-vector-interleave=2 -force-vector-width=2 -force-widen-divrem-via-safe-divisor=0 -S",
148
+ "opt < %s -passes=loop-vectorize -force-vector-interleave=2 -force-vector-width=2 -force-widen-divrem-via-safe-divisor=0 -S",
149
+ "opt < %s -passes=loop-vectorize,instcombine -force-vector-interleave=2 -force-vector-width=4 -force-widen-divrem-via-safe-divisor=0 -enable-interleaved-mem-accesses -S"
150
+ ],
151
+ "tests": [
152
+ {
153
+ "test_name": "test_optimized_cast_induction_feeding_first_order_recurrence",
154
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine void @test_optimized_cast_induction_feeding_first_order_recurrence(i64 %n, i32 %step, ptr %ptr) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %for = phi i32 [ 0, %entry ], [ %iv.2.conv, %loop ]\n %iv.1 = phi i64 [ 0, %entry ], [ %iv.1.next, %loop ]\n %iv.2 = phi i32 [ 0, %entry ], [ %iv.2.next, %loop ]\n %iv.2.ext = shl i32 %iv.2, 24\n %iv.2.conv = ashr exact i32 %iv.2.ext, 24\n %gep = getelementptr inbounds i32, ptr %ptr, i64 %iv.1\n store i32 %for, ptr %gep, align 4\n %iv.2.next = add nsw i32 %iv.2.conv, %step\n %iv.1.next = add nuw nsw i64 %iv.1, 1\n %exitcond = icmp eq i64 %iv.1.next, %n\n br i1 %exitcond, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n"
155
+ }
156
+ ]
157
+ }
158
+ ],
159
+ "issue": {
160
+ "title": "Assertion `!NodePtr->isKnownSentinel()' failed.",
161
+ "body": "To reproduce run opt with the test below, -passes=loop-vectorize\n```\n; ModuleID = './reduced.ll'\nsource_filename = \"./reduced.ll\"\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-ni:1-p2:32:8:8:32-ni:2\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @wombat() gc \"statepoint-example\" personality ptr null {\nbb:\n %invoke = invoke i32 null(ptr addrspace(1) null, i32 0, i32 0, i32 0)\n to label %bb1 unwind label %bb5\n\nbb1: ; preds = %bb1, %bb\n %phi = phi i64 [ %add, %bb1 ], [ 0, %bb ]\n %phi2 = phi i32 [ %add3, %bb1 ], [ 0, %bb ]\n %add = add i64 %phi, 1\n %sitofp = sitofp i32 %phi2 to double\n store double %sitofp, ptr addrspace(1) null, align 8\n %add3 = add i32 %phi2, %invoke\n %icmp = icmp ult i64 %phi, 161\n br i1 %icmp, label %bb1, label %bb4\n\nbb4: ; preds = %bb1\n ret void\n\nbb5: ; preds = %bb\n %landingpad = landingpad { ptr, i32 }\n cleanup\n ret void\n}\n```\nReproducer: https://godbolt.org/z/3do96adnn\n\nStack dump:\n```\nopt: /root/llvm-project/llvm/include/llvm/ADT/ilist_iterator.h:322: llvm::ilist_iterator_w_bits<OptionsT, IsReverse, IsConst>::reference llvm::ilist_iterator_w_bits<OptionsT, IsReverse, IsConst>::operator*() const [with OptionsT = llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>; bool IsReverse = false; bool IsConst = false; llvm::ilist_iterator_w_bits<OptionsT, IsReverse, IsConst>::reference = llvm::Instruction&]: Assertion `!NodePtr->isKnownSentinel()' 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=loop-vectorize <source>\n1.\tRunning pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"<source>\"\n2.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"wombat\"\n #0 0x0000000005452b98 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5452b98)\n #1 0x0000000005450554 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007b16e6242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007b16e62969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x00007b16e6242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007b16e62287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x00007b16e622871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x00007b16e6239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x00000000044f6c23 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x44f6c23)\n #9 0x000000000450ebb3 llvm::VPTransformState::get(llvm::VPValue*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x450ebb3)\n#10 0x0000000004543138 llvm::VPInstruction::generate(llvm::VPTransformState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4543138)\n#11 0x0000000004544ba4 llvm::VPInstruction::execute(llvm::VPTransformState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4544ba4)\n#12 0x00000000044f82e7 llvm::VPBasicBlock::executeRecipes(llvm::VPTransformState*, llvm::BasicBlock*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x44f82e7)\n#13 0x00000000045038f9 llvm::VPIRBasicBlock::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x45038f9)\n#14 0x0000000004510249 llvm::VPlan::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4510249)\n#15 0x00000000043cccce llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool, llvm::DenseMap<llvm::SCEV const*, llvm::Value*, llvm::DenseMapInfo<llvm::SCEV const*, void>, llvm::detail::DenseMapPair<llvm::SCEV const*, llvm::Value*>> const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43cccce)\n#16 0x00000000043e15d8 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43e15d8)\n#17 0x00000000043e2f49 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43e2f49)\n#18 0x00000000043e35c3 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43e35c3)\n#19 0x000000000318aaae llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x318aaae)\n#20 0x000000000524cd90 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x524cd90)\n#21 0x0000000000e6f54e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe6f54e)\n#22 0x000000000524b6ab llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x524b6ab)\n#23 0x0000000000e6e83e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe6e83e)\n#24 0x000000000524b0b0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x524b0b0)\n#25 0x0000000000935a3a 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) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x935a3a)\n#26 0x00000000009290ac optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9290ac)\n#27 0x00007b16e6229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#28 0x00007b16e6229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#29 0x0000000000920985 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x920985)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```",
162
+ "author": "TatyanaDoubts",
163
+ "labels": [
164
+ "vectorizers",
165
+ "crash-on-valid"
166
+ ],
167
+ "comments": [
168
+ {
169
+ "author": "fhahn",
170
+ "body": "looking "
171
+ }
172
+ ]
173
+ },
174
+ "verified": true
175
+ }
dataset/131195.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "131195",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/131195",
4
+ "bug_type": "crash",
5
+ "base_commit": "8413f4d837a96458104f63bab72c751b8285a458",
6
+ "knowledge_cutoff": "2025-03-13T19:24:54Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/SLPVectorizer"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "605a9f590d91a42ae652c2ab13487b5ad57c58a5",
12
+ "components": [
13
+ "SLPVectorizer"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
17
+ [
18
+ 14081,
19
+ 14086
20
+ ],
21
+ [
22
+ 14121,
23
+ 14126
24
+ ]
25
+ ]
26
+ },
27
+ "bug_location_funcname": {
28
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
29
+ "BoUpSLP::isGatherShuffledSingleRegisterEntry"
30
+ ]
31
+ }
32
+ },
33
+ "patch": "commit 605a9f590d91a42ae652c2ab13487b5ad57c58a5\nAuthor: Alexey Bataev <[email protected]>\nDate: Fri Mar 14 13:40:15 2025 -0700\n\n [SLP]Check if user node is same as other node and check operand order\n \n Need to check if the user node is same as other node and check operand\n order to prevent a compiler crash when trying to find matching gather\n node with user nodes, having the same last instruction.\n \n Fixes #131195\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex 9c3992b4a713..708dda9bd7f8 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -14081,6 +14081,17 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(\n }\n return true;\n };\n+ auto CheckParentNodes = [&](const TreeEntry *User1, const TreeEntry *User2,\n+ unsigned EdgeIdx) {\n+ const TreeEntry *Ptr1 = User1;\n+ while (Ptr1) {\n+ unsigned Idx = Ptr1->UserTreeIndex.EdgeIdx;\n+ Ptr1 = Ptr1->UserTreeIndex.UserTE;\n+ if (Ptr1 == User2)\n+ return Idx < EdgeIdx;\n+ }\n+ return false;\n+ };\n for (Value *V : VL) {\n if (isConstant(V) || !VisitedValue.insert(V).second)\n continue;\n@@ -14121,6 +14132,9 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(\n (TEUseEI.UserTE->Idx < UseEI.UserTE->Idx ||\n HasGatherUser(TEUseEI.UserTE)))\n continue;\n+ // If the user node is the operand of the other user node - skip.\n+ if (CheckParentNodes(TEUseEI.UserTE, UseEI.UserTE, UseEI.EdgeIdx))\n+ continue;\n }\n \n // Check if the user node of the TE comes after user node of TEPtr,\n",
34
+ "tests": [
35
+ {
36
+ "file": "llvm/test/Transforms/SLPVectorizer/X86/user-node-with-same-last-instr.ll",
37
+ "commands": [
38
+ "opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-99999 < %s"
39
+ ],
40
+ "tests": [
41
+ {
42
+ "test_name": "<module>",
43
+ "test_body": "\ndefine void @wombat(i32 %arg) {\n;\nbb:\n br label %bb1\n\nbb1:\n br i1 false, label %bb2, label %bb5\n\nbb2:\n %phi = phi i32 [ %or, %bb4 ], [ 0, %bb1 ]\n %phi3 = phi i32 [ %sub, %bb4 ], [ 0, %bb1 ]\n %or = or i32 %phi, 1\n %and = and i32 0, %phi\n %sub = sub i32 %phi3, %arg\n br label %bb4\n\nbb4:\n br i1 false, label %bb2, label %bb5\n\nbb5:\n %phi6 = phi i32 [ 0, %bb1 ], [ %and, %bb4 ]\n %phi7 = phi i32 [ 0, %bb1 ], [ %sub, %bb4 ]\n ret void\n}"
44
+ }
45
+ ]
46
+ }
47
+ ],
48
+ "issue": {
49
+ "title": "[SLPVectorizer] Instruction does not dominate all uses! ...LLVM ERROR: Broken module found, compilation aborted!",
50
+ "body": "To reproduce run opt with the test below with -passes=slp-vectorizer -slp-threshold=-99999:\n```\n; ModuleID = './reduced.ll'\nsource_filename = \"./reduced.ll\"\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-ni:1-p2:32:8:8:32-ni:2\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @wombat(i32 %arg) #0 gc \"statepoint-example\" {\nbb:\n br label %bb1\n\nbb1: ; preds = %bb\n br i1 false, label %bb2, label %bb5\n\nbb2: ; preds = %bb4, %bb1\n %phi = phi i32 [ %or, %bb4 ], [ 0, %bb1 ]\n %phi3 = phi i32 [ %sub, %bb4 ], [ 0, %bb1 ]\n %or = or i32 %phi, 1\n %and = and i32 0, %phi\n %sub = sub i32 %phi3, %arg\n br label %bb4\n\nbb4: ; preds = %bb2\n br i1 false, label %bb2, label %bb5\n\nbb5: ; preds = %bb4, %bb1\n %phi6 = phi i32 [ 0, %bb1 ], [ %and, %bb4 ]\n %phi7 = phi i32 [ 0, %bb1 ], [ %sub, %bb4 ]\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+prfchw,-cldemote,+avx,+aes,+sahf,+pclmul,-xop,+crc32,-amx-fp8,+xsaves,-avx512fp16,-usermsr,-sm4,-egpr,+sse4.1,-avx512ifma,+xsave,+sse4.2,-tsxldtrk,-sm3,-ptwrite,-widekl,-movrs,+invpcid,+64bit,+xsavec,-avx10.1-512,-avx512vpopcntdq,+cmov,-avx512vp2intersect,+avx512cd,+movbe,-avxvnniint8,-ccmp,-amx-int8,-kl,-avx10.1-256,+evex512,-avxvnni,+rtm,+adx,+avx2,-hreset,-movdiri,-serialize,-sha512,-vpclmulqdq,+avx512vl,-uintr,-cf,+clflushopt,-raoint,-cmpccxadd,+bmi,-amx-tile,+sse,-avx10.2-256,-gfni,-avxvnniint16,-amx-fp16,-zu,-ndd,+xsaveopt,+rdrnd,+avx512f,-amx-bf16,-avx512bf16,-avx512vnni,-push2pop2,+cx8,+avx512bw,+sse3,+pku,-nf,-amx-tf32,-amx-avx512,+fsgsbase,-clzero,-mwaitx,-lwp,+lzcnt,-sha,-movdir64b,-ppx,-wbnoinvd,-enqcmd,-amx-transpose,-avx10.2-512,-avxneconvert,-tbm,-pconfig,-amx-complex,+ssse3,+cx16,+bmi2,+fma,+popcnt,-avxifma,+f16c,-avx512bitalg,-rdpru,+clwb,+mmx,+sse2,+rdseed,-avx512vbmi2,-prefetchi,-amx-movrs,-rdpid,-fma4,-avx512vbmi,-shstk,-vaes,-waitpkg,-sgx,+fxsr,+avx512dq,-sse4a,-avx512f\" }\n```\nReproducer: https://godbolt.org/z/Pfa9ca1o9\n\n\n\nStack dump:\n```\nInstruction does not dominate all uses!\n %5 = insertelement <2 x i32> <i32 poison, i32 0>, i32 %arg, i32 0\n %1 = shufflevector <2 x i32> %5, <2 x i32> <i32 poison, i32 1>, <2 x i32> <i32 0, i32 3>\nLLVM ERROR: Broken module found, compilation aborted!\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 -slp-threshold=-99999 <source>\n1.\tRunning pass \"verify\" on module \"<source>\"\n #0 0x0000000005480a38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5480a38)\n #1 0x000000000547e3f4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x000072fce1242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x000072fce12969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x000072fce1242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x000072fce12287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x00000000008074fd llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0\n #7 0x00000000053bec18 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x53bec18)\n #8 0x00000000052bb868 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x52bb868)\n #9 0x000000000093768e llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x93768e)\n#10 0x000000000527a030 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x527a030)\n#11 0x0000000000941b4a 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) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x941b4a)\n#12 0x000000000093522c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x93522c)\n#13 0x000072fce1229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#14 0x000072fce1229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#15 0x000000000092cd35 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x92cd35)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```",
51
+ "author": "TatyanaDoubts",
52
+ "labels": [
53
+ "llvm:SLPVectorizer",
54
+ "crash"
55
+ ],
56
+ "comments": []
57
+ },
58
+ "verified": true
59
+ }
dataset/131281.json ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "131281",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/131281",
4
+ "bug_type": "crash",
5
+ "base_commit": "887cf1f8cea240cd50fb80bc9487b22f67d74263",
6
+ "knowledge_cutoff": "2025-03-14T05:50:22Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "166937b49dac0919fae362c0deecb723b03be764",
12
+ "components": [
13
+ "LoopVectorize"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
17
+ [
18
+ 1912,
19
+ 1917
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
25
+ "create"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit 166937b49dac0919fae362c0deecb723b03be764\nAuthor: Florian Hahn <[email protected]>\nDate: Mon Mar 17 18:41:34 2025 +0000\n\n [LV] Cleanup after expanding SCEV predicate to constant.\n \n In some cases, SCEV isn't able to prove that no wrap checks are needed,\n while constant folding in SCEVExpander can. In those cases, we may leave\n around IR for computing the trip count, which is unused at this point\n but may be re-used later, triggering an assertion when trying to clean\n up SCEVExp after vectorization.\n \n Directly run the cleaner after expanding to a constant predicate to\n prevent any generated code from being re-used.\n \n Fixes https://github.com/llvm/llvm-project/issues/131281.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\nindex 0e38ccc565ea..cbfccaab01e2 100644\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n@@ -1912,6 +1912,12 @@ public:\n \n SCEVCheckCond = SCEVExp.expandCodeForPredicate(\n &UnionPred, SCEVCheckBlock->getTerminator());\n+ if (isa<Constant>(SCEVCheckCond)) {\n+ // Clean up directly after expanding the predicate to a constant, to\n+ // avoid further expansions re-using anything left over from SCEVExp.\n+ SCEVExpanderCleaner SCEVCleaner(SCEVExp);\n+ SCEVCleaner.cleanup();\n+ }\n }\n \n const auto &RtPtrChecking = *LAI.getRuntimePointerChecking();\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/LoopVectorize/scev-predicate-reasoning.ll",
33
+ "commands": [
34
+ "opt -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -lv-strided-pointer-ivs=true -S %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "no_signed_wrap_iv_via_btc",
39
+ "test_body": "declare i1 @cond()\n\n; Function Attrs: mustprogress\ndefine void @no_signed_wrap_iv_via_btc(ptr %dst, i32 %N) #0 {\nentry:\n %sub = add i32 %N, -100\n %sub4 = add i32 %N, -99\n br label %outer\n\nouter: ; preds = %loop, %entry\n %c = call i1 @cond()\n br i1 %c, label %loop, label %exit\n\nloop: ; preds = %loop, %outer\n %iv = phi i32 [ 0, %outer ], [ %inc, %loop ]\n %add2 = add i32 %sub4, %iv\n %add.ext = sext i32 %add2 to i64\n %gep.dst = getelementptr i32, ptr %dst, i64 %add.ext\n store i32 0, ptr %gep.dst, align 4\n %inc = add i32 %iv, 1\n %add = add i32 %sub, %inc\n %ec = icmp sgt i32 %add, %N\n br i1 %ec, label %outer, label %loop\n\nexit: ; preds = %outer\n ret void\n}\n\nattributes #0 = { mustprogress }\n"
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "issue": {
45
+ "title": "[clang] Crash at -O2: Assertion `all_of(I->users()... \"during expansion\"' failed.",
46
+ "body": "This code crashes at `-O2`:\n\n```c\nint a, b, c, d;\nvoid e() {\n int *f = 0;\n for (;;)\n for (; c - 100 + d <= b; d++) {\n f[d + a] = 1;\n a = 1 + c - 100;\n }\n}\nvoid main() {}\n```\n\nCompiler Explorer: https://godbolt.org/z/P3f6ef98P\n\nBisected to https://github.com/llvm/llvm-project/commit/ddffb74afd870d284ba07f1cf6c67117a8ab8b33, which was committed by @artagnon \n\nCrash:\n\n```console\nclang: /root/llvm-project/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp:2402: void llvm::SCEVExpanderCleaner::cleanup(): Assertion `all_of(I->users(), [&InsertedSet](Value *U) { return InsertedSet.contains(cast<Instruction>(U)); }) && \"removed instruction should only be used by instructions inserted \" \"during expansion\"' failed.\n```\n\nBacktrace:\n\n```c\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 -Wall -Wextra <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 \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"e\"\n #0 0x0000000003e7dc08 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e7dc08)\n #1 0x0000000003e7b8c4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e7b8c4)\n #2 0x0000000003dc0618 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0\n #3 0x00007507d4042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #4 0x00007507d40969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #5 0x00007507d4042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #6 0x00007507d40287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #7 0x00007507d402871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #8 0x00007507d4039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #9 0x0000000003fea367 llvm::SCEVExpanderCleaner::cleanup() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fea367)\n#10 0x000000000597bc1f (anonymous namespace)::GeneratedRTChecks::~GeneratedRTChecks() LoopVectorize.cpp:0:0\n#11 0x00000000059d28c8 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x59d28c8)\n#12 0x00000000059d4e29 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x59d4e29)\n#13 0x00000000059d54a3 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x59d54a3)\n#14 0x00000000055481fe llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x55481fe)\n#15 0x000000000381c880 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x381c880)\n#16 0x00000000011a852e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x11a852e)\n#17 0x000000000381b19b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x381b19b)\n#18 0x00000000011a764e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x11a764e)\n#19 0x000000000381aba0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x381aba0)\n#20 0x000000000412e684 (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#21 0x0000000004132031 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*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4132031)\n#22 0x0000000004837120 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4837120)\n#23 0x000000000643be7c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x643be7c)\n#24 0x0000000004837528 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4837528)\n#25 0x0000000004b00005 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4b00005)\n#26 0x0000000004a8398e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4a8398e)\n#27 0x0000000004bedf9e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4bedf9e)\n#28 0x0000000000d5391f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd5391f)\n#29 0x0000000000d4b2da ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#30 0x000000000487fa49 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0\n#31 0x0000000003dc0ac4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dc0ac4)\n#32 0x000000000488003f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0\n#33 0x00000000048426fd clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x48426fd)\n#34 0x000000000484377e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x484377e)\n#35 0x000000000484b695 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x484b695)\n#36 0x0000000000d5076c clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd5076c)\n#37 0x0000000000c17ff4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc17ff4)\n#38 0x00007507d4029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#39 0x00007507d4029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#40 0x0000000000d4ad85 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd4ad85)\n```",
47
+ "author": "cardigan1008",
48
+ "labels": [
49
+ "vectorizers",
50
+ "crash-on-valid",
51
+ "generated by fuzzer"
52
+ ],
53
+ "comments": [
54
+ {
55
+ "author": "artagnon",
56
+ "body": "@fhahn Could you kindly look into this? I'm on vacation until the 24th."
57
+ },
58
+ {
59
+ "author": "dtcxzyw",
60
+ "body": "Reduced: https://godbolt.org/z/Wbvj9fExo\n```\n; bin/opt -passes=loop-vectorize test.ll -S\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 void @e(i32 %0) {\nentry:\n %sub = add i32 %0, -100\n %sub4 = add i32 %0, -99\n br label %for.cond\n\nfor.cond: ; preds = %for.body, %entry\n br label %for.body\n\nfor.body: ; preds = %for.body, %for.cond\n %inc510 = phi i32 [ %inc, %for.body ], [ 0, %for.cond ]\n %add2 = add i32 %sub4, %inc510\n %idxprom = sext i32 %add2 to i64\n %arrayidx = getelementptr i32, ptr null, i64 %idxprom\n store i32 0, ptr %arrayidx, align 4\n %inc = add i32 %inc510, 1\n %add = add i32 %sub, %inc\n %cmp.not = icmp sgt i32 %add, %0\n br i1 %cmp.not, label %for.cond, label %for.body, !llvm.loop !0\n}\n\n!0 = distinct !{!0, !1, !2}\n!1 = !{!\"llvm.loop.mustprogress\"}\n!2 = !{!\"llvm.loop.peeled.count\", i32 1}\n\n```"
61
+ },
62
+ {
63
+ "author": "fhahn",
64
+ "body": "@artagnon sure, it looks like the underlying issue existed before, but with https://github.com/llvm/llvm-project/commit/ddffb74afd870d284ba07f1cf6c67117a8ab8b33 we now crash.\n\nSCEVExpansion can prove that the AddRec never wraps via constant folding the runtime check, but really SCEV should be able to prove that: https://github.com/llvm/llvm-project/pull/131538"
65
+ }
66
+ ]
67
+ },
68
+ "verified": true
69
+ }
dataset/131360.json ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "131360",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/131360",
4
+ "bug_type": "crash",
5
+ "base_commit": "dccc0a836c20914549fa375905615db49d2f813b",
6
+ "knowledge_cutoff": "2025-03-14T17:22:16Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/SLPVectorizer"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "fbf0276b6a7a7a4508c373cf87fc349569652659",
12
+ "components": [
13
+ "SLPVectorizer"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
17
+ [
18
+ 6665,
19
+ 6670
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
25
+ "BoUpSLP::reorderBottomToTop"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit fbf0276b6a7a7a4508c373cf87fc349569652659\nAuthor: Alexey Bataev <[email protected]>\nDate: Fri Mar 14 14:07:01 2025 -0700\n\n [SLP] Reorder reuses mask, if it is not empty, for subvector operands\n \n If the subvector operands has reuses mask, need to reorder the mask, not\n the scalars, to prevent compiler crash due to mask/scalars size\n mismatch.\n \n Fixes #131360\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex 708dda9bd7f8..d450336cbc3c 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -6665,6 +6665,8 @@ void BoUpSLP::reorderBottomToTop(bool IgnoreReorder) {\n // Clear ordering of the operand.\n if (!OpTE.ReorderIndices.empty()) {\n OpTE.ReorderIndices.clear();\n+ } else if (!OpTE.ReuseShuffleIndices.empty()) {\n+ reorderReuses(OpTE.ReuseShuffleIndices, Mask);\n } else {\n assert(OpTE.isGather() && \"Expected only gather/buildvector node.\");\n reorderScalars(OpTE.Scalars, Mask);\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/SLPVectorizer/X86/reorder-reused-subvector.ll",
33
+ "commands": [
34
+ "opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-100 < %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "<module>",
39
+ "test_body": "\ndefine void @test(i32 %j.6, i32 %m.4, i8 %v.5, ptr %a, i1 %tobool14.not) {\n;\nentry:\n br label %n\n\nentry.o_crit_edge:\n br label %o\n\nn:\n %i.0 = phi i32 [ 0, %entry ], [ 1, %if.end18 ]\n %j.0 = phi i32 [ 0, %entry ], [ %j.6, %if.end18 ]\n %m.0 = phi i32 [ 0, %entry ], [ %m.4, %if.end18 ]\n %l.0 = phi i8 [ 0, %entry ], [ %l.4, %if.end18 ]\n %u.0 = phi i32 [ 0, %entry ], [ %u.5, %if.end18 ]\n store i32 %j.0, ptr %a, align 4\n %cmp.not.not = icmp eq i8 %l.0, 0\n br i1 %cmp.not.not, label %o.sink.split, label %p\n\np:\n %0 = phi i32 [ %r.3, %if.end18 ], [ 0, %n ]\n %i.1 = phi i32 [ %s.3, %if.end18 ], [ 1, %n ]\n %j.1 = phi i32 [ %j.65, %if.end18 ], [ %j.0, %n ]\n %k.1 = phi i32 [ %t.3, %if.end18 ], [ %i.0, %n ]\n %m.1 = phi i32 [ %m.46, %if.end18 ], [ %m.0, %n ]\n %l.1 = phi i8 [ 1, %if.end18 ], [ 0, %n ]\n %s.1 = phi i32 [ %s.3, %if.end18 ], [ 0, %n ]\n %t.1 = phi i32 [ %t.3, %if.end18 ], [ 0, %n ]\n %u.12 = phi i32 [ %u.5, %if.end18 ], [ 0, %n ]\n %v.1 = phi i8 [ 0, %if.end18 ], [ %v.5, %n ]\n %tobool4.not = icmp eq i32 %m.1, 0\n %spec.select = select i1 %tobool4.not, i32 %j.1, i32 0\n %tobool7.not = icmp eq i32 %0, 0\n br i1 %tobool7.not, label %o.sink.split, label %q\n\no.sink.split:\n %spec.select.sink = phi i32 [ %j.0, %n ], [ %spec.select, %p ]\n %i.3.ph = phi i32 [ 0, %n ], [ %i.1, %p ]\n %k.3.ph = phi i32 [ %i.0, %n ], [ %k.1, %p ]\n %m.3.ph = phi i32 [ %m.0, %n ], [ 0, %p ]\n %l.3.ph = phi i8 [ 0, %n ], [ %l.1, %p ]\n %u.3.ph = phi i32 [ %u.0, %n ], [ 1, %p ]\n %conv10 = zext i32 %spec.select.sink to i64\n %call11 = tail call i32 (ptr, ...) @printf(ptr null, i64 %conv10)\n br label %o\n\no:\n %j.4 = phi i32 [ 0, %entry.o_crit_edge ], [ %spec.select.sink, %o.sink.split ]\n %k.3 = phi i32 [ 0, %entry.o_crit_edge ], [ %k.3.ph, %o.sink.split ]\n %m.3 = phi i32 [ 0, %entry.o_crit_edge ], [ %m.3.ph, %o.sink.split ]\n %u.3 = phi i32 [ 0, %entry.o_crit_edge ], [ %u.3.ph, %o.sink.split ]\n %sub = sub i32 0, %j.6\n %div = sdiv i32 %sub, %i.3.ph\n %sub13 = sub i32 0, %div\n br i1 %tobool14.not, label %if.end18, label %q\n\nq:\n %s.2 = phi i32 [ %s.1, %p ], [ 0, %o ]\n %t.2 = phi i32 [ %t.1, %p ], [ %k.3, %o ]\n %u.4 = phi i32 [ %u.12, %p ], [ 0, %o ]\n %v.44 = phi i8 [ %v.1, %p ], [ 0, %o ]\n %conv17 = sext i8 %v.44 to i32\n %rem = mul i32 %u.4, %conv17\n br label %if.end18\n\nif.end18:\n %j.65 = phi i32 [ 0, %q ], [ %j.4, %o ]\n %m.46 = phi i32 [ %rem, %q ], [ %m.3, %o ]\n %l.4 = phi i8 [ 0, %q ], [ %l.3.ph, %o ]\n %r.3 = phi i32 [ 0, %q ], [ %k.3, %o ]\n %s.3 = phi i32 [ %s.2, %q ], [ %sub, %o ]\n %t.3 = phi i32 [ %t.2, %q ], [ %sub13, %o ]\n %u.5 = phi i32 [ 0, %q ], [ %u.3, %o ]\n br i1 %tobool14.not, label %n, label %p\n\n}\ndeclare i32 @printf(ptr, ...)"
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "issue": {
45
+ "title": "clang crashes at -O{s,2,3} on x86_64-linux-gnu: Assertion `idx < size()' failed",
46
+ "body": "It appears to be a recent regression as it doesn't reproduce with 20.1.0. \n\nCompiler Explorer: https://godbolt.org/z/31z58Pqnf\n\n```\n[507] % 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[508] % \n[508] % clangtk -Os small.c\nclang-21: /local/suz-local/software/clangbuild/llvm-project/llvm/include/llvm/ADT/SmallVector.h:291: T& llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::operator[](llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::size_type) [with T = llvm::Value*; <template-parameter-1-2> = void; llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::reference = llvm::Value*&; llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::size_type = long unsigned int]: Assertion `idx < size()' 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/20250314-clangtk-m64-O3-build-143933/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20250314-clangtk-m64-O3-build-143933/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-fb79f4.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 \"slp-vectorizer\" on function \"g\"\n #0 0x0000559c00edefcf llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x4577fcf)\n #1 0x0000559c00edc7a4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007f26a38b4420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\n #3 0x00007f26a32eb00b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\n #4 0x00007f26a32ca859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\n #5 0x00007f26a32ca729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\n #6 0x00007f26a32ca729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\n #7 0x00007f26a32dbfd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\n #8 0x0000559c0296f55e llvm::reorderScalars(llvm::SmallVectorImpl<llvm::Value*>&, llvm::ArrayRef<int>) SLPVectorizer.cpp:0:0\n #9 0x0000559c02a36719 llvm::slpvectorizer::BoUpSLP::reorderBottomToTop(bool) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60cf719)\n#10 0x0000559c02a41c60 llvm::SLPVectorizerPass::tryToVectorizeList(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60dac60)\n#11 0x0000559c02a4712d bool tryToVectorizeSequence<llvm::Value>(llvm::SmallVectorImpl<llvm::Value*>&, llvm::function_ref<bool (llvm::Value*, llvm::Value*)>, llvm::function_ref<bool (llvm::Value*, llvm::Value*)>, llvm::function_ref<bool (llvm::ArrayRef<llvm::Value*>, bool)>, bool, llvm::slpvectorizer::BoUpSLP&) (.constprop.0) SLPVectorizer.cpp:0:0\n#12 0x0000559c02a48b21 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60e1b21)\n#13 0x0000559c02a50b66 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\n#14 0x0000559c02a51733 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60ea733)\n#15 0x0000559c024c7cf6 llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5b60cf6)\n#16 0x0000559c0084f7c9 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#17 0x0000559bfe1397a6 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#18 0x0000559c0084e032 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x3ee7032)\n#19 0x0000559bfe1373b6 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#20 0x0000559c0084da51 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#21 0x0000559c0119ce4a (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#22 0x0000559c011a08a1 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#23 0x0000559c018e0d91 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x4f79d91)\n#24 0x0000559c0326e6dc clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x69076dc)\n#25 0x0000559c018e11b8 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x4f7a1b8)\n#26 0x0000559c01bb7bc9 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5250bc9)\n#27 0x0000559c01b38ece clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x51d1ece)\n#28 0x0000559c01cac996 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5345996)\n#29 0x0000559bfdccc9ed cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x13659ed)\n#30 0x0000559bfdcc415a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#31 0x0000559bfdcc83c7 clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x13613c7)\n#32 0x0000559bfdbad0db main (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x12460db)\n#33 0x00007f26a32cc083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\n#34 0x0000559bfdcc3bee _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-d812eb.c\nclangtk: note: diagnostic msg: /tmp/small-d812eb.sh\nclangtk: note: diagnostic msg: \n\n********************\n[509] % \n[509] % cat small.c\nint printf(const char *, ...);\nint a, b, c, d, e, f;\nvoid g() {\n int i = 1, j = 0, k = 0, m;\n char l = 1;\n if (d)\n n : {\n a = j;\n if (e >= l) {\n printf(\"%ld\", (long) j);\n goto o;\n }\n p:\n if (m)\n j = 1;\n if (b)\n goto q;\n printf(\"%ld\", (long) j);\n }\n o : ;\n int r = k, s = -f, t = -(s / i);\n if (c) {\n t = k;\n int u = a;\n char v = u;\n q:\n m = u % v;\n l = 0;\n }\n i = s;\n k = t;\n b = r;\n if (a)\n goto p;\n goto n;\n}\n```\n",
47
+ "author": "zhendongsu",
48
+ "labels": [
49
+ "llvm:SLPVectorizer",
50
+ "crash"
51
+ ],
52
+ "comments": []
53
+ },
54
+ "verified": true
55
+ }
dataset/131465.json ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "131465",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/131465",
4
+ "bug_type": "miscompilation",
5
+ "base_commit": "baab447aadd59b34bd838584b16d11475329853f",
6
+ "knowledge_cutoff": "2025-03-15T18:15:27Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Analysis/ScalarEvolution",
9
+ "llvm/test/Transforms/LoopUnroll"
10
+ ],
11
+ "hints": {
12
+ "fix_commit": "c5a491e9ea22014b65664b6e09134b4f055933e2",
13
+ "components": [
14
+ "ScalarEvolution"
15
+ ],
16
+ "bug_location_lineno": {
17
+ "llvm/lib/Analysis/ScalarEvolution.cpp": [
18
+ [
19
+ 10635,
20
+ 10644
21
+ ]
22
+ ]
23
+ },
24
+ "bug_location_funcname": {
25
+ "llvm/lib/Analysis/ScalarEvolution.cpp": [
26
+ "ScalarEvolution::howFarToZero"
27
+ ]
28
+ }
29
+ },
30
+ "patch": "commit c5a491e9ea22014b65664b6e09134b4f055933e2\nAuthor: Yingwei Zheng <[email protected]>\nDate: Mon Mar 17 13:59:16 2025 +0800\n\n [SCEV] Check whether the start is non-zero in `ScalarEvolution::howFarToZero` (#131522)\n \n https://github.com/llvm/llvm-project/pull/94525 assumes that the loop\n will be infinite when the stride is zero. However, it doesn't hold when\n the start value of addrec is also zero.\n \n Closes https://github.com/llvm/llvm-project/issues/131465.\n\ndiff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp\nindex 8f74c1c398ce..314baa7c7aee 100644\n--- a/llvm/lib/Analysis/ScalarEvolution.cpp\n+++ b/llvm/lib/Analysis/ScalarEvolution.cpp\n@@ -10635,10 +10635,11 @@ ScalarEvolution::ExitLimit ScalarEvolution::howFarToZero(const SCEV *V,\n if (ControlsOnlyExit && AddRec->hasNoSelfWrap() &&\n loopHasNoAbnormalExits(AddRec->getLoop())) {\n \n- // If the stride is zero, the loop must be infinite. In C++, most loops\n- // are finite by assumption, in which case the step being zero implies\n- // UB must execute if the loop is entered.\n- if (!loopIsFiniteByAssumption(L) && !isKnownNonZero(StepWLG))\n+ // If the stride is zero and the start is non-zero, the loop must be\n+ // infinite. In C++, most loops are finite by assumption, in which case the\n+ // step being zero implies UB must execute if the loop is entered.\n+ if (!(loopIsFiniteByAssumption(L) && isKnownNonZero(Start)) &&\n+ !isKnownNonZero(StepWLG))\n return getCouldNotCompute();\n \n const SCEV *Exact =\n",
31
+ "tests": [
32
+ {
33
+ "file": "llvm/test/Analysis/ScalarEvolution/trip-count-unknown-stride.ll",
34
+ "commands": [
35
+ "opt < %s -disable-output \"-passes=print<scalar-evolution>\" -scalar-evolution-classify-expressions=0 2>&1"
36
+ ],
37
+ "tests": [
38
+ {
39
+ "test_name": "ne_nuw_nonneg_step",
40
+ "test_body": "target datalayout = \"e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128\"\n\n; Function Attrs: mustprogress\ndefine void @ne_nuw_nonneg_step(ptr captures(none) %A, i32 %n, i32 %s) #0 {\nentry:\n %nonneg_step = icmp sge i32 %s, 0\n call void @llvm.assume(i1 %nonneg_step)\n %cmp4 = icmp sgt i32 %n, 0\n br i1 %cmp4, label %for.body, label %for.end\n\nfor.body: ; preds = %for.body, %entry\n %i.05 = phi i32 [ %add, %for.body ], [ 0, %entry ]\n %arrayidx = getelementptr inbounds i32, ptr %A, i32 %i.05\n %0 = load i32, ptr %arrayidx, align 4\n %inc = add nuw i32 %0, 1\n store i32 %inc, ptr %arrayidx, align 4\n %add = add nuw i32 %i.05, %s\n %cmp = icmp ne i32 %add, %n\n br i1 %cmp, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body, %entry\n ret void\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #1\n\nattributes #0 = { mustprogress }\nattributes #1 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n"
41
+ },
42
+ {
43
+ "test_name": "pr131465",
44
+ "test_body": "target datalayout = \"e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128\"\n\n; Function Attrs: mustprogress\ndefine i32 @pr131465(i1 %x) #0 {\nentry:\n %inc = zext i1 %x to i32\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %indvar = phi i32 [ 2, %entry ], [ %next, %for.body ]\n %next = add nsw i32 %indvar, %inc\n %exitcond = icmp eq i32 %next, 2\n br i1 %exitcond, label %for.end, label %for.body\n\nfor.end: ; preds = %for.body\n ret i32 0\n}\n\nattributes #0 = { mustprogress }\n"
45
+ },
46
+ {
47
+ "test_name": "ne_nsw_nonneg_step",
48
+ "test_body": "target datalayout = \"e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128\"\n\n; Function Attrs: mustprogress\ndefine void @ne_nsw_nonneg_step(ptr captures(none) %A, i32 %n, i32 %s) #0 {\nentry:\n %nonneg_step = icmp sge i32 %s, 0\n call void @llvm.assume(i1 %nonneg_step)\n %cmp4 = icmp sgt i32 %n, 0\n br i1 %cmp4, label %for.body, label %for.end\n\nfor.body: ; preds = %for.body, %entry\n %i.05 = phi i32 [ %add, %for.body ], [ 0, %entry ]\n %arrayidx = getelementptr inbounds i32, ptr %A, i32 %i.05\n %0 = load i32, ptr %arrayidx, align 4\n %inc = add nsw i32 %0, 1\n store i32 %inc, ptr %arrayidx, align 4\n %add = add nsw i32 %i.05, %s\n %cmp = icmp ne i32 %add, %n\n br i1 %cmp, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body, %entry\n ret void\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #1\n\nattributes #0 = { mustprogress }\nattributes #1 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n"
49
+ }
50
+ ]
51
+ },
52
+ {
53
+ "file": "llvm/test/Transforms/LoopUnroll/pr131465.ll",
54
+ "commands": [
55
+ "opt -S -passes=loop-unroll -unroll-runtime %s"
56
+ ],
57
+ "tests": [
58
+ {
59
+ "test_name": "pr131465",
60
+ "test_body": "; Function Attrs: mustprogress\ndefine i32 @pr131465(i1 %x) #0 {\nentry:\n %inc = zext i1 %x to i32\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %indvar = phi i32 [ 2, %entry ], [ %next, %for.body ]\n %next = add nsw i32 %indvar, %inc\n %exitcond = icmp eq i32 %next, 2\n br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !0\n\nfor.end: ; preds = %for.body\n ret i32 0\n}\n\nattributes #0 = { mustprogress }\n\n!0 = distinct !{!0, !1}\n!1 = !{!\"llvm.loop.unroll.count\", i32 2}\n"
61
+ }
62
+ ]
63
+ }
64
+ ],
65
+ "issue": {
66
+ "title": "[clang] Miscompilation at -O2/3",
67
+ "body": "This code prints 80 at `-O2/3` and 0 at `-O0/1`:\n\n```c\nint printf(const char *, ...);\nint a, b;\nvoid c(char d) { a = d; }\nint main() {\n int e = 82, f = 20;\n for (; 85 + 20 + e - 187 + f; f = 65535 + 20 + e - 65637)\n if (b)\n e++;\n c(e >> 24);\n printf(\"%X\\n\", a);\n}\n```\n\nCompiler Explorer: https://godbolt.org/z/6WP1aT6ba\n\nBisected to https://github.com/llvm/llvm-project/commit/04cd06906288dcb148de37d7c3e6c009c3e3b726, which was committed by @preames ",
68
+ "author": "cardigan1008",
69
+ "labels": [
70
+ "miscompilation",
71
+ "llvm:SCEV"
72
+ ],
73
+ "comments": [
74
+ {
75
+ "author": "dtcxzyw",
76
+ "body": "Reduced reproducer: https://godbolt.org/z/bvhdjdMc7 https://alive2.llvm.org/ce/z/sSLNUX\n```\n; bin/opt -passes=loop-unroll test.ll -S\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 i32 @main(i1 %tobool2.not) #0 {\nentry:\n %inc = zext i1 %tobool2.not to i32\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %e.08 = phi i32 [ 2, %entry ], [ %spec.select, %for.body ]\n %spec.select = add nsw i32 %e.08, %inc\n %tobool.not = icmp eq i32 %spec.select, 2\n br i1 %tobool.not, label %for.end, label %for.body, !llvm.loop !0\n\nfor.end: ; preds = %for.body\n ret i32 0\n}\n\nattributes #0 = { \"target-cpu\"=\"x86-64\" }\n\n!0 = distinct !{!0, !1}\n!1 = !{!\"llvm.loop.mustprogress\"}\n\n```"
77
+ },
78
+ {
79
+ "author": "antoniofrighetto",
80
+ "body": "@dtcxzyw May I ask whether llubi was used to get such a reduced reproducer? Having a hard time reducing this one, this time: am using [test.sh](https://github.com/dtcxzyw/llvm-ub-aware-interpreter?tab=readme-ov-file#automatic-ub-free-test-case-reduction-for-middle-end-miscompilation-bugs) with:\n1) Custom pipelines & O2 in order to have some proper interestingness test;\n2) `--ir-passes` with the default one, fine-tuning the pipeline by adjusting/removing passes.\n\nHowever, by the time I obtain the reduced IR, it looks already invalid (i.e., unreachable). Any suggestions / idea what I may be missing?"
81
+ },
82
+ {
83
+ "author": "dtcxzyw",
84
+ "body": "1. Manually bisect\n```\n#!/usr/bin/bash\n\nFILE=$1\nBISECT=$2\n../../LLVM/llvm-build/bin/clang -O3 -mllvm -inline-threshold=1000000 $FILE -mllvm -opt-bisect-limit=$BISECT -DNDEBUG -g0 -w -emit-llvm -S -I/home/dtcxzyw/WorkSpace/Projects/compilers/csmith/install/include -o test.ll -mllvm -print-changed -mllvm -print-module-scope 2>log\n# ../../LLVM/llvm-build/bin/lli test.ll\n./llubi --max-steps 1000000 test.ll\n# ../../LLVM/llvm-build/bin/opt -O3 $FILE -o out.ll -S -opt-bisect-limit=$BISECT -print-changed -print-module-scope 2>log\n# ./llubi out.ll\n```\n```\n# Correct one\n./bisect.sh test.c 175\n# Miscompilation\n./bisect.sh test.c 174\n```\nAfter the bisection, we got a single-pass reproducer:\n```\n; bin/opt -passes=loop-unroll test.ll -S\n; ModuleID = 'test.c'\nsource_filename = \"test.c\"\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\n@a = dso_local local_unnamed_addr global i32 0, align 4\n@b = dso_local local_unnamed_addr global i32 0, align 4\[email protected] = private unnamed_addr constant [4 x i8] c\"%X\\0A\\00\", align 1\n\n; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: none, inaccessiblemem: none) uwtable\ndefine dso_local void @c(i8 noundef signext %d) local_unnamed_addr #0 {\nentry:\n %conv = sext i8 %d to i32\n store i32 %conv, ptr @a, align 4, !tbaa !5\n ret void\n}\n\n; Function Attrs: nofree nounwind uwtable\ndefine dso_local noundef i32 @main() local_unnamed_addr #1 {\nentry:\n %0 = load i32, ptr @b, align 4, !tbaa !5\n %tobool2.not = icmp ne i32 %0, 0\n %inc = zext i1 %tobool2.not to i32\n br label %for.body\n\nfor.body: ; preds = %entry, %for.body\n %e.08 = phi i32 [ 82, %entry ], [ %spec.select, %for.body ]\n %spec.select = add nuw nsw i32 %e.08, %inc\n %sub = add nsw i32 %spec.select, -82\n %add1 = sub nsw i32 82, %spec.select\n %tobool.not = icmp eq i32 %sub, %add1\n br i1 %tobool.not, label %for.end, label %for.body, !llvm.loop !9\n\nfor.end: ; preds = %for.body\n %shr = lshr i32 %spec.select, 24\n store i32 %shr, ptr @a, align 4, !tbaa !5\n %call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %shr)\n ret i32 0\n}\n\n; Function Attrs: nofree nounwind\ndeclare noundef i32 @printf(ptr noundef readonly captures(none), ...) local_unnamed_addr #2\n\nattributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: none, inaccessiblemem: none) uwtable \"min-legal-vector-width\"=\"0\" \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"x86-64\" \"target-features\"=\"+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87\" \"tune-cpu\"=\"generic\" }\nattributes #1 = { nofree nounwind uwtable \"min-legal-vector-width\"=\"0\" \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"x86-64\" \"target-features\"=\"+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87\" \"tune-cpu\"=\"generic\" }\nattributes #2 = { nofree nounwind \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"x86-64\" \"target-features\"=\"+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87\" \"tune-cpu\"=\"generic\" }\n\n!llvm.module.flags = !{!0, !1, !2, !3}\n!llvm.ident = !{!4}\n\n!0 = !{i32 1, !\"wchar_size\", i32 4}\n!1 = !{i32 8, !\"PIC Level\", i32 2}\n!2 = !{i32 7, !\"PIE Level\", i32 2}\n!3 = !{i32 7, !\"uwtable\", i32 2}\n!4 = !{!\"clang version 21.0.0git\"}\n!5 = !{!6, !6, i64 0}\n!6 = !{!\"int\", !7, i64 0}\n!7 = !{!\"omnipotent char\", !8, i64 0}\n!8 = !{!\"Simple C/C++ TBAA\"}\n!9 = distinct !{!9, !10}\n!10 = !{!\"llvm.loop.mustprogress\"}\n```\n2. reduce\n```\n#!/usr/bin/bash\n# /home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/clang -Os -Xclang -disable-llvm-passes -emit-llvm -S test.c -o test.ll -I/home/dtcxzyw/WorkSpace/Projects/compilers/csmith/install/include -w\n# llvm-reduce --test=ubi_reduce.sh --ir-passes=\"function(sroa,instcombine<no-verify-fixpoint>,gvn,simplifycfg,infer-address-spaces),inline\" test.ll\n\na=$(/home/dtcxzyw/WorkSpace/Projects/compilers/llvm-ub-aware-interpreter/build/llubi --max-steps 1000000 --reduce-mode $1)\nif [ $? -ne 0 ]; then\n exit 1\nfi\n/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/opt -passes=loop-unroll $1 -o $1.tmp -S\nif [ $? -ne 0 ]; then\n exit 1\nfi\nb=$(/home/dtcxzyw/WorkSpace/Projects/compilers/llvm-ub-aware-interpreter/build/llubi --max-steps 1000000 --reduce-mode $1.tmp)\nif [ $? -ne 0 ]; then\n exit 0\n # exit 1\nfi\nif [[ \"$a\" == \"$b\" ]]; then\n exit 2\nfi\n# echo $a\n# echo $b\nexit 0\n```\n```\nllvm-reduce --test=ubi_reduce.sh test.ll\n```\nThen we got the final reproducer.\n\nIn general, I will run `creduce w/ sanitizers` and the bisection first to avoid falling into some long-outstanding undef bugs.\n\nBTW, an automatic reproducer reduction pipeline will be available soon :)\n"
85
+ },
86
+ {
87
+ "author": "antoniofrighetto",
88
+ "body": "@dtcxzyw Thanks a lot for clarifying that :)"
89
+ }
90
+ ]
91
+ },
92
+ "verified": true
93
+ }
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 = 130472
38
 
39
 
40
  def wait(progress):
@@ -84,6 +84,7 @@ def fetch(issue_id):
84
  "clang-tidy",
85
  "mlir:",
86
  "tools:",
 
87
  ]:
88
  if key in label_name:
89
  return False
@@ -98,6 +99,7 @@ def fetch(issue_id):
98
  "llvm:codegen",
99
  "llvm-reduce",
100
  "llvm:bitcode",
 
101
  "BOLT",
102
  ]:
103
  return False
@@ -137,6 +139,8 @@ for issue_id in progress:
137
  wait(progress)
138
  except requests.exceptions.RequestException:
139
  wait(progress)
 
 
140
  except Exception as e:
141
  print(type(e), e)
142
  exit(0)
 
34
  )
35
 
36
  issue_id_begin = 76663 # Since 2024-01-01
37
+ issue_id_end = 131718
38
 
39
 
40
  def wait(progress):
 
84
  "clang-tidy",
85
  "mlir:",
86
  "tools:",
87
+ "flang:",
88
  ]:
89
  if key in label_name:
90
  return False
 
99
  "llvm:codegen",
100
  "llvm-reduce",
101
  "llvm:bitcode",
102
+ "llvm:openmpirbuilder",
103
  "BOLT",
104
  ]:
105
  return False
 
139
  wait(progress)
140
  except requests.exceptions.RequestException:
141
  wait(progress)
142
+ except ValueError:
143
+ wait(progress)
144
  except Exception as e:
145
  print(type(e), e)
146
  exit(0)
scripts/postfix_extract.py CHANGED
@@ -126,6 +126,8 @@ fix_commit_map = {
126
  "127220": None, # Reverted
127
  "129244": None, # Cannot reproduce the miscompilation
128
  "130082": None, # Non-deterministic bug
 
 
129
  }
130
 
131
  if issue_id in fix_commit_map:
@@ -199,7 +201,7 @@ for file in patchset.modified_files:
199
  source_code = llvm_helper.git_execute(["show", f"{base_commit}:{file.path}"])
200
  modified_funcs_valid = hints.get_funcname_loc(file, source_code)
201
  if len(modified_funcs_valid) != 0:
202
- bug_location_funcname[file.path] = list(modified_funcs_valid)
203
 
204
  # Extract tests
205
  test_patchset = PatchSet(
 
126
  "127220": None, # Reverted
127
  "129244": None, # Cannot reproduce the miscompilation
128
  "130082": None, # Non-deterministic bug
129
+ "130632": None, # Reverts #108535
130
+ "131355": None, # Non-deterministic bug
131
  }
132
 
133
  if issue_id in fix_commit_map:
 
201
  source_code = llvm_helper.git_execute(["show", f"{base_commit}:{file.path}"])
202
  modified_funcs_valid = hints.get_funcname_loc(file, source_code)
203
  if len(modified_funcs_valid) != 0:
204
+ bug_location_funcname[file.path] = sorted(modified_funcs_valid)
205
 
206
  # Extract tests
207
  test_patchset = PatchSet(