Datasets:

Modalities:
Text
Formats:
json
Size:
< 1K
Tags:
code
DOI:
Libraries:
Datasets
pandas
License:
dtcxzyw commited on
Commit
8bbdd0c
·
1 Parent(s): 607dd77
dataset.jsonl CHANGED
@@ -1,6 +1,7 @@
1
  {"bug_id": "128770", "issue_url": "https://github.com/llvm/llvm-project/issues/128770", "bug_type": "crash", "base_commit": "7f482aa848c5f136d2b32431f91f88492c78c709", "knowledge_cutoff": "2025-02-25T20:34:44Z", "lit_test_dir": ["llvm/test/Transforms/SLPVectorizer"], "hints": {"fix_commit": "418a9872851ef5342b29baa36dd672129f129953", "components": ["SLPVectorizer"], "bug_location_lineno": {"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [[13353, 13358], [13453, 13459]]}, "bug_location_funcname": {"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": ["BoUpSLP::isGatherShuffledSingleRegisterEntry"]}}, "patch": "commit 418a9872851ef5342b29baa36dd672129f129953\nAuthor: Alexey Bataev <[email protected]>\nDate: Wed Feb 26 12:59:27 2025 -0800\n\n [SLP]Do not use node, if it is a subvector or buildvector node\n \n If the buildvector has some matches with another node, which is\n a subvector of another buildvector node, need to check for this and\n cancel matching to avoid incorrect ordering of the nodes.\n \n Fixes #128770\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex 02fea2eaf9d4..b25b09306aca 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -13353,6 +13353,14 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(\n return EdgeInfo(const_cast<TreeEntry *>(TE), 0);\n return TE->UserTreeIndex;\n };\n+ auto HasGatherUser = [&](const TreeEntry *TE) {\n+ while (TE->Idx != 0 && TE->UserTreeIndex) {\n+ if (TE->UserTreeIndex.EdgeIdx == UINT_MAX)\n+ return true;\n+ TE = TE->UserTreeIndex.UserTE;\n+ }\n+ return false;\n+ };\n const EdgeInfo TEUseEI = GetUserEntry(TE);\n if (!TEUseEI)\n return std::nullopt;\n@@ -13453,7 +13461,8 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(\n // If the user instruction is used for some reason in different\n // vectorized nodes - make it depend on index.\n if (TEUseEI.UserTE != UseEI.UserTE &&\n- TEUseEI.UserTE->Idx < UseEI.UserTE->Idx)\n+ (TEUseEI.UserTE->Idx < UseEI.UserTE->Idx ||\n+ HasGatherUser(TEUseEI.UserTE)))\n continue;\n }\n \n", "tests": [{"file": "llvm/test/Transforms/SLPVectorizer/X86/buildvector-reused-with-bv-subvector.ll", "commands": ["opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -mcpu=skylake < %s"], "tests": [{"test_name": "<module>", "test_body": "\ndefine void @test(ptr %0, i64 %1, i64 %2) {\n;\n %4 = ptrtoint ptr %0 to i64\n %5 = ptrtoint ptr %0 to i64\n %6 = ptrtoint ptr %0 to i64\n %7 = ptrtoint ptr %0 to i64\n %8 = ptrtoint ptr %0 to i64\n br label %.preheader.lr.ph\n\n.preheader.lr.ph:\n br label %.preheader.us.us.preheader\n\n.preheader.us.us.preheader:\n %9 = or i64 %1, %7\n %10 = or i64 %2, %7\n %11 = or i64 %1, %4\n %12 = or i64 %1, %8\n %13 = or i64 %5, %8\n %14 = or i64 %8, %4\n %15 = or i64 %5, %6\n %16 = or i64 %6, %4\n br label %.preheader.us.us\n\n.preheader.us.us:\n %diff.check1 = icmp ult i64 %9, 32\n %diff.check2 = icmp ult i64 %10, 32\n %conflict.rdx3 = or i1 %diff.check1, %diff.check2\n %diff.check4 = icmp ult i64 %11, 32\n %conflict.rdx5 = or i1 %conflict.rdx3, %diff.check4\n %diff.check6 = icmp ult i64 %12, 32\n %conflict.rdx7 = or i1 %conflict.rdx5, %diff.check6\n %diff.check8 = icmp ult i64 %13, 32\n %conflict.rdx9 = or i1 %conflict.rdx7, %diff.check8\n %diff.check10 = icmp ult i64 %14, 32\n %conflict.rdx11 = or i1 %conflict.rdx9, %diff.check10\n %diff.check12 = icmp ult i64 %15, 32\n %conflict.rdx13 = or i1 %conflict.rdx11, %diff.check12\n %diff.check14 = icmp ult i64 %16, 32\n %conflict.rdx15 = or i1 %conflict.rdx13, %diff.check14\n br i1 %conflict.rdx15, label %scalar.ph, label %.preheader.us.us\n\nscalar.ph:\n ret void\n}"}]}], "issue": {"title": "SLP: Instruction does not dominate all uses (insertelement/shufflevector)", "body": "[slp.ll.gz](https://github.com/user-attachments/files/18972113/slp.ll.gz)\n\nReproducer: `opt -passes=slp-vectorizer slp.ll -mcpu=skylake`\n\n@alexey-bataev can you please take a look?", "author": "vzakhari", "labels": ["llvm:SLPVectorizer", "crash"], "comments": []}, "verified": true}
2
  {"bug_id": "127739", "issue_url": "https://github.com/llvm/llvm-project/issues/127739", "bug_type": "crash", "base_commit": "d6301b218c6698ceb0db1753c8de480d37d11cf8", "knowledge_cutoff": "2025-02-19T03:17:57Z", "lit_test_dir": ["llvm/test/Transforms/Scalarizer"], "hints": {"fix_commit": "1440f02259abf585f0c2965bd4ececf0f3499405", "components": ["Scalarizer"], "bug_location_lineno": {"llvm/lib/Transforms/Scalar/Scalarizer.cpp": [[719, 731], [1083, 1088]]}, "bug_location_funcname": {"llvm/lib/Transforms/Scalar/Scalarizer.cpp": ["ScalarizerVisitor::splitCall", "ScalarizerVisitor::visitExtractValueInst"]}}, "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", "tests": [{"file": "llvm/test/Transforms/Scalarizer/min-bits.ll", "commands": ["opt %s -passes='function(scalarizer<load-store;min-bits=16>,dce)' -S", "opt %s -passes='function(scalarizer<load-store;min-bits=32>,dce)' -S", "opt %s -passes='function(scalarizer<load-store;min-bits=64>,dce)' -S"], "tests": [{"test_name": "load_add_store_v2i16", "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"}, {"test_name": "select_uniform_condition_v3f16", "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"}, {"test_name": "call_v4f16", "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"}, {"test_name": "unary_v4f16", "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"}, {"test_name": "gep1_v4", "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"}, {"test_name": "fptosi_v3f16", "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"}, {"test_name": "binary_v2f16", "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"}, {"test_name": "gep3_v4", "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"}, {"test_name": "fptosi_v4f16", "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"}, {"test_name": "binary_v3f16", "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"}, {"test_name": "load_add_store_v4i16", "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"}, {"test_name": "select_uniform_condition_v2f16", "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"}, {"test_name": "shufflevector_shrink", "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"}, {"test_name": "phi_v2f16", "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"}, {"test_name": "frexp_v2f16", "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"}, {"test_name": "load_insertelement_v3i16", "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"}, {"test_name": "load_add_store_v3i16", "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"}, {"test_name": "fptosi_v2f16", "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"}, {"test_name": "insertelement_v4i16", "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"}, {"test_name": "load_insertelement_v2i16", "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"}, {"test_name": "load_insertelement_v4i16", "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"}, {"test_name": "insertelement_v2i16", "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"}, {"test_name": "shufflevector_grow", "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"}, {"test_name": "uadd_with_overflow_v3i32", "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"}, {"test_name": "insertelement_v3i16", "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"}, {"test_name": "call_v2f16", "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"}, {"test_name": "phi_v3f16", "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"}, {"test_name": "phi_v4f16", "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"}, {"test_name": "call_v3f16", "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"}, {"test_name": "binary_v4f16", "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"}, {"test_name": "fpext_v4f16", "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"}, {"test_name": "load_add_store_v4i10", "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"}, {"test_name": "unary_v3f16", "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"}, {"test_name": "unary_v2f16", "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"}, {"test_name": "select_uniform_condition_v4f16", "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"}]}], "issue": {"title": "[Scalarizer] Test *_with_overflow crash with min-bits=32 and min-bits=16", "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 ", "author": "farzonl", "labels": ["crash-on-valid", "llvm:analysis"], "comments": [{"author": "farzonl", "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."}, {"author": "Icohedron", "body": "I'm on it"}, {"author": "jayfoad", "body": "As mentioned in #127996, note that you can also provoke this bug by adding `min-bits=64` to `test/Transforms/Scalarizer/frexp.ll`."}, {"author": "Icohedron", "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```"}]}, "verified": true}
3
  {"bug_id": "126181", "issue_url": "https://github.com/llvm/llvm-project/issues/126181", "bug_type": "miscompilation", "base_commit": "317a644ae6d501f1a1ec54d17ea8559bcdea35c0", "knowledge_cutoff": "2025-02-07T05:51:32Z", "lit_test_dir": ["llvm/test/Transforms/DeadStoreElimination"], "hints": {"fix_commit": "2d31a12dbe2339d20844ede70cbb54dbaf4ceea9", "components": ["DeadStoreElimination"], "bug_location_lineno": {"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": [[2283, 2289]]}, "bug_location_funcname": {"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": ["DSEState::getInitializesArgMemLoc"]}}, "patch": "commit 2d31a12dbe2339d20844ede70cbb54dbaf4ceea9\nAuthor: Nikita Popov <[email protected]>\nDate: Mon Feb 10 10:34:03 2025 +0100\n\n [DSE] Don't use initializes on byval argument (#126259)\n \n There are two ways we can fix this problem, depending on how the\n semantics of byval and initializes should interact:\n \n * Don't infer initializes on byval arguments. initializes on byval\n refers to the original caller memory (or having both attributes is made\n a verifier error).\n * Infer initializes on byval, but don't use it in DSE. initializes on\n byval refers to the callee copy. This matches the semantics of readonly\n on byval. This is slightly more powerful, for example, we could do a\n backend optimization where byval + initializes will allocate the full\n size of byval on the stack but not copy over the parts covered by\n initializes.\n \n I went with the second variant here, skipping byval + initializes in DSE\n (FunctionAttrs already doesn't propagate initializes past byval). I'm\n open to going in the other direction though.\n \n Fixes https://github.com/llvm/llvm-project/issues/126181.\n\ndiff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp\nindex 05b4f176bfc3..38454053b039 100644\n--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp\n+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp\n@@ -2283,7 +2283,9 @@ DSEState::getInitializesArgMemLoc(const Instruction *I) {\n for (unsigned Idx = 0, Count = CB->arg_size(); Idx < Count; ++Idx) {\n ConstantRangeList Inits;\n Attribute InitializesAttr = CB->getParamAttr(Idx, Attribute::Initializes);\n- if (InitializesAttr.isValid())\n+ // initializes on byval arguments refers to the callee copy, not the\n+ // original memory the caller passed in.\n+ if (InitializesAttr.isValid() && !CB->isByValArgument(Idx))\n Inits = InitializesAttr.getValueAsConstantRangeList();\n \n Value *CurArg = CB->getArgOperand(Idx);\n", "tests": [{"file": "llvm/test/Transforms/DeadStoreElimination/inter-procedural.ll", "commands": ["opt < %s -passes=dse -enable-dse-initializes-attr-improvement -S"], "tests": [{"test_name": "test_byval", "test_body": "%struct.a = type { i32, i64, i32, i32 }\n\n@e = dso_local global { i32, [4 x i8], i64, i32, i32 } { i32 5, [4 x i8] zeroinitializer, i64 0, i32 1, i32 90986701 }, align 8\n\ndefine i8 @ad(ptr byval(%struct.a) %ah) {\nentry:\n store i32 0, ptr %ah, align 8\n %call = call i64 @af(ptr %ah)\n %0 = load i8, ptr %ah, align 1\n ret i8 %0\n}\n\ndefine i64 @af(ptr byval(%struct.a) initializes((0, 24)) %am) {\nentry:\n call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %am, ptr noundef nonnull align 8 dereferenceable(24) @e, i64 24, i1 false)\n ret i64 0\n}\n\ndefine i32 @main() {\n %res = call i8 @ad(ptr @e)\n %val = sext i8 %res to i32\n ret i32 %val\n}\n", "lli_expected_out": ""}]}], "issue": {"title": "[FuncAttrs] `initializes` is incorrectly set on parameters with `byval`", "body": "Reproducer: https://godbolt.org/z/Mcx1nY4E7\n```\n; bin/opt -passes=function-attrs reduced.ll -S\n%struct.a = type { i32, i64, i32, i32 }\n\n@e = dso_local global { i32, [4 x i8], i64, i32, i32 } { i32 5, [4 x i8] zeroinitializer, i64 0, i32 1, i32 90986701 }, align 8\n\ndefine i8 @ad(ptr byval(%struct.a) %ah) {\nentry:\n store i32 0, ptr %ah, align 8\n %call = call i64 @af(ptr %ah)\n %0 = load i8, ptr %ah, align 1\n ret i8 %0\n}\n\ndefine i64 @af(ptr byval(%struct.a) %am) {\nentry:\n call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %am, ptr noundef nonnull align 8 dereferenceable(24) @e, i64 24, i1 false)\n ret i64 0\n}\n\n```\n```\ndefine i8 @ad(ptr byval(%struct.a) captures(none) initializes((0, 4)) %ah) #0 {\n store i32 0, ptr %ah, align 8\n %call = call i64 @af(ptr %ah)\n %0 = load i8, ptr %ah, align 1\n ret i8 %0\n}\n\ndefine noundef i64 @af(ptr writeonly byval(%struct.a) captures(none) initializes((0, 24)) %am) #0 {\n call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %am, ptr noundef nonnull align 8 dereferenceable(24) @e, i64 24, i1 false)\n ret i64 0\n}\n```\nAfter DSE:\n```\ndefine i8 @ad(ptr byval(%struct.a) captures(none) initializes((0, 4)) %ah) #0 {\n %call = call i64 @af(ptr %ah)\n %0 = load i8, ptr %ah, align 1\n ret i8 %0\n}\n\ndefine noundef i64 @af(ptr writeonly byval(%struct.a) captures(none) initializes((0, 24)) %am) #0 {\n ret i64 0\n}\n```\n\nllvm version: d21fc58aeeaa7f0369a24dbe70a0360e0edbf76f\n", "author": "dtcxzyw", "labels": ["miscompilation", "llvm:transforms"], "comments": [{"author": "nikic", "body": "> We should also emit the padding for %struct.a.\n\nWithout commenting on whether we should or shouldn't, why is not having the padding a miscompile? As this is not a packed struct, for a i64:64 target, LLVM will implicitly insert the padding and it should have the correct size."}, {"author": "dtcxzyw", "body": "> As this is not a packed struct, for a i64:64 target, LLVM will implicitly insert the padding and it should have the correct size.\n\nSorry. It is a DSE bug.\n"}, {"author": "dtcxzyw", "body": "cc @haopliu "}, {"author": "nikic", "body": "@dtcxzyw I think your new IR is over-reduced. You have `initializes((0, 24)` on `@af`, so I think eliminating the store is correct."}, {"author": "dtcxzyw", "body": "> [@dtcxzyw](https://github.com/dtcxzyw) I think your new IR is over-reduced. You have `initializes((0, 24)` on `@af`, so I think eliminating the store is correct.\n\nFixed."}, {"author": "nikic", "body": "There are two ways we can fix this, depending on what we want the semantics to do:\n\n 1. Don't infer initializes on byval arguments. initializes on byval refers to the original caller memory (or having both attributes is made a verifier error).\n 2. Infer initializes on byval, but don't use it in DSE. initializes on byval refers to the callee copy. This matches the semantics of readonly on byval.\n\nI think variant 2 is marginally more powerful. For example, we could do a backend optimization where byval + initializes will allocate the full size of byval on the stack but not copy over the parts covered by initializes."}]}, "verified": true}
 
4
  {"bug_id": "113143", "issue_url": "https://github.com/llvm/llvm-project/issues/113143", "bug_type": "crash", "base_commit": "42ba452aa94e4da277842d8990ad958a6256e558", "knowledge_cutoff": "2024-10-21T10:11:54Z", "lit_test_dir": ["llvm/test/Transforms/SLPVectorizer"], "hints": {"fix_commit": "9e03920cbf946e7ba282e99213707643a23ae5fb", "components": ["SLPVectorizer"], "bug_location_lineno": {"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [[12466, 12472]]}, "bug_location_funcname": {"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": ["BoUpSLP::isGatherShuffledSingleRegisterEntry"]}}, "patch": "commit 9e03920cbf946e7ba282e99213707643a23ae5fb\nAuthor: Alexey Bataev <[email protected]>\nDate: Mon Oct 21 08:57:36 2024 -0700\n\n [SLP]Ignore root gather node, when searching for reuses\n \n Root gather/buildvector node should be ignored when SLP vectorizer tries\n to find matching gather nodes, vectorized earlier. This node is\n definitely the last one in the pipeline and it does not have users. It\n may cause the compiler crash\n \n Fixes #113143\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex 1098bf578d2d..a11e3f3815cb 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -12466,7 +12466,7 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(\n // Build a list of tree entries where V is used.\n SmallPtrSet<const TreeEntry *, 4> VToTEs;\n for (const TreeEntry *TEPtr : ValueToGatherNodes.find(V)->second) {\n- if (TEPtr == TE)\n+ if (TEPtr == TE || TEPtr->Idx == 0)\n continue;\n assert(any_of(TEPtr->Scalars,\n [&](Value *V) { return GatheredScalars.contains(V); }) &&\n", "tests": [{"file": "llvm/test/Transforms/SLPVectorizer/X86/root-gather-reused-scalar.ll", "commands": ["opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"], "tests": [{"test_name": "test", "test_body": "define void @test(ptr %a, i32 %0, i32 %1, i1 %cmp1) {\nentry:\n %2 = load i32, ptr %a, align 4\n %tobool10.not = icmp eq i32 %0, 0\n %cmp4.3 = icmp ne i32 %1, 0\n %3 = and i1 %cmp4.3, %tobool10.not\n %cmp2.2 = xor i1 %tobool10.not, true\n %conv3.2 = zext i1 %cmp2.2 to i32\n %cmp4.2 = icmp ne i32 %2, %conv3.2\n %cmp2.1 = xor i1 %cmp1, true\n %conv3.1 = zext i1 %cmp2.1 to i32\n %cmp4.1 = icmp ne i32 %2, %conv3.1\n %4 = select i1 %3, i1 %cmp4.2, i1 false\n %5 = select i1 %4, i1 %cmp4.1, i1 false\n %and.3 = zext i1 %5 to i32\n store i32 %and.3, ptr %a, align 4\n ret void\n}\n"}]}], "issue": {"title": "clang crashes on valid code at -O2 on x86_64-linux-gnu: Assertion `TEPtr->UserTreeIndices.size() == 1 && \"Expected only single user of a gather node.\"' failed ", "body": "It appears to be a recent regression as it doesn't reproduce with 19.1.0 and earlier. \r\n\r\nCompiler Explorer: https://godbolt.org/z/a1W3c5ard\r\n\r\n```\r\n[523] % clangtk -v\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git df8b785838a2db01b4d056e603f7317209accefb)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\r\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nCandidate multilib: .;@m64\r\nSelected multilib: .;@m64\r\n[524] % \r\n[524] % clangtk -O2 small.c\r\nclang-20: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:12559: std::optional<llvm::TargetTransformInfo::ShuffleKind> llvm::slpvectorizer::BoUpSLP::isGatherShuffledSingleRegisterEntry(const llvm::slpvectorizer::BoUpSLP::TreeEntry*, llvm::ArrayRef<llvm::Value*>, llvm::MutableArrayRef<int>, llvm::SmallVectorImpl<const llvm::slpvectorizer::BoUpSLP::TreeEntry*>&, unsigned int, bool): Assertion `TEPtr->UserTreeIndices.size() == 1 && \"Expected only single user of a gather node.\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-20 -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/20241020-clangtk-m64-O2-build-231331/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20241020-clangtk-m64-O2-build-231331/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/20 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/20/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 -O2 -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-572b89.o -x c small.c\r\n1.\t<eof> parser at end of file\r\n2.\tOptimizer\r\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\"\r\n4.\tRunning pass \"slp-vectorizer\" on function \"main\"\r\n #0 0x0000560576c8b9af llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x43f29af)\r\n #1 0x0000560576c89184 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007f4623c27420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\r\n #3 0x00007f462365e00b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #4 0x00007f462363d859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\r\n #5 0x00007f462363d729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #6 0x00007f462363d729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #7 0x00007f462364efd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #8 0x0000560578707edc llvm::slpvectorizer::BoUpSLP::isGatherShuffledSingleRegisterEntry(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::MutableArrayRef<int>, llvm::SmallVectorImpl<llvm::slpvectorizer::BoUpSLP::TreeEntry const*>&, unsigned int, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5e6eedc)\r\n #9 0x0000560578708cd8 llvm::slpvectorizer::BoUpSLP::isGatherShuffledEntry(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallVectorImpl<int>&, llvm::SmallVectorImpl<llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, 6u>>&, unsigned int, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5e6fcd8)\r\n#10 0x000056057870a6f3 llvm::InstructionCost llvm::slpvectorizer::BoUpSLP::processBuildVector<llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator, llvm::InstructionCost, llvm::TargetTransformInfo, llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP, llvm::SmallPtrSetImpl<llvm::Value*>>(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::Type*, llvm::TargetTransformInfo&, llvm::ArrayRef<llvm::Value*>&, llvm::slpvectorizer::BoUpSLP&, llvm::SmallPtrSetImpl<llvm::Value*>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5e716f3)\r\n#11 0x000056057870cde7 llvm::slpvectorizer::BoUpSLP::getEntryCost(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallPtrSetImpl<llvm::Value*>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5e73de7)\r\n#12 0x0000560578745f69 llvm::slpvectorizer::BoUpSLP::getTreeCost(llvm::ArrayRef<llvm::Value*>) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5eacf69)\r\n#13 0x000056057874b57b (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&) SLPVectorizer.cpp:0:0\r\n#14 0x000056057874eb79 llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5eb5b79)\r\n#15 0x000056057875349b llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (.constprop.0) SLPVectorizer.cpp:0:0\r\n#16 0x0000560578757d50 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5ebed50)\r\n#17 0x000056057875e590 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\r\n#18 0x000056057875f263 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5ec6263)\r\n#19 0x00005605781e0e66 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-20+0x5947e66)\r\n#20 0x0000560576614891 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3d7b891)\r\n#21 0x000056057410e656 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-20+0x1875656)\r\n#22 0x00005605766131fd llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3d7a1fd)\r\n#23 0x000056057410d196 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-20+0x1874196)\r\n#24 0x0000560576612c31 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3d79c31)\r\n#25 0x0000560576f44dd3 (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\r\n#26 0x0000560576f483a8 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, 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-20+0x46af3a8)\r\n#27 0x000056057764462c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4dab62c)\r\n#28 0x000056057951629c clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x6c7d29c)\r\n#29 0x0000560577644a48 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4daba48)\r\n#30 0x000056057790d3d9 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x50743d9)\r\n#31 0x00005605778895ce clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4ff05ce)\r\n#32 0x00005605779f9f26 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5160f26)\r\n#33 0x0000560573cd1fe5 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x1438fe5)\r\n#34 0x0000560573cc9afa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#35 0x0000560573cce52e clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x143552e)\r\n#36 0x0000560573bba67b main (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x132167b)\r\n#37 0x00007f462363f083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#38 0x0000560573cc958e _start (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x143058e)\r\nclangtk: error: unable to execute command: Aborted\r\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git df8b785838a2db01b4d056e603f7317209accefb)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nclangtk: note: diagnostic msg: \r\n********************\r\n\r\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\r\nPreprocessed source(s) and associated run script(s) are located at:\r\nclangtk: note: diagnostic msg: /tmp/small-d99d4e.c\r\nclangtk: note: diagnostic msg: /tmp/small-d99d4e.sh\r\nclangtk: note: diagnostic msg: \r\n\r\n********************\r\n[525] % \r\n[525] % cat small.c\r\nint a, b, c, d, e, f;\r\nint main() {\r\n for (f = 0; f < 4; f++) {\r\n d &= (((a > 0) != b) != c) && b;\r\n for (b = 0; b < 1; b++)\r\n if (e)\r\n break;\r\n }\r\n return 0;\r\n}\r\n```\r\n\r\n", "author": "zhendongsu", "labels": ["llvm:SLPVectorizer", "crash-on-valid"], "comments": []}, "verified": true}
5
  {"bug_id": "114082", "issue_url": "https://github.com/llvm/llvm-project/issues/114082", "bug_type": "crash", "base_commit": "0f040433d325aa68ec6840aa179f3f314c26153a", "knowledge_cutoff": "2024-10-29T16:26:31Z", "lit_test_dir": ["llvm/test/Transforms/SLPVectorizer"], "hints": {"fix_commit": "77bec78878762e34150fe23734fa43df796c873c", "components": ["SLPVectorizer"], "bug_location_lineno": {"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [[13398, 13404]]}, "bug_location_funcname": {"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": ["BoUpSLP::getLastInstructionInBundle"]}}, "patch": "commit 77bec78878762e34150fe23734fa43df796c873c\nAuthor: Alexey Bataev <[email protected]>\nDate: Fri Nov 8 04:16:01 2024 -0800\n\n [SLP]Do not look for last instruction in schedule block for buildvectors\n \n If looking for the insertion point for the node and the node is\n a buildvector node, the compiler should not use scheduling info for such\n nodes, they may contain only partial info, which is not fully correct\n and may cause compiler crash.\n \n Fixes #114082\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex b2f677fb84f9..c5b3537bc57b 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -13398,7 +13398,7 @@ Instruction &BoUpSLP::getLastInstructionInBundle(const TreeEntry *E) {\n // scheduled, and the last instruction is VL.back(). So we start with\n // VL.back() and iterate over schedule data until we reach the end of the\n // bundle. The end of the bundle is marked by null ScheduleData.\n- if (BlocksSchedules.count(BB)) {\n+ if (BlocksSchedules.count(BB) && !E->isGather()) {\n Value *V = E->isOneOf(E->Scalars.back());\n if (doesNotNeedToBeScheduled(V))\n V = *find_if_not(E->Scalars, doesNotNeedToBeScheduled);\n", "tests": [{"file": "llvm/test/Transforms/SLPVectorizer/X86/buildvector-schedule-for-subvector.ll", "commands": ["opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-99999 < %s"], "tests": [{"test_name": "test", "test_body": "define void @test() {\nbb:\n %icmp = icmp samesign ult i32 0, 0\n %select = select i1 %icmp, i32 0, i32 0\n %zext = zext i32 %select to i64\n %getelementptr = getelementptr ptr addrspace(1), ptr addrspace(1) null, i64 %zext\n store ptr addrspace(1) null, ptr addrspace(1) %getelementptr, align 8\n %icmp1 = icmp eq i32 0, 0\n %icmp2 = icmp eq i32 0, 0\n %icmp3 = icmp samesign ult i32 0, 0\n %icmp4 = icmp eq i32 0, 0\n %add = add i32 1, 0\n %icmp5 = icmp samesign ult i32 %add, 0\n store volatile i32 0, ptr addrspace(1) null, align 4\n %call = call i32 null(<2 x double> zeroinitializer)\n %icmp6 = icmp eq i32 %call, 0\n %icmp7 = icmp samesign ult i32 0, 0\n ret void\n}\n"}]}], "issue": {"title": "[SLPVectorizer] Instruction does not dominate all uses! LLVM ERROR: Broken module found, compilation aborted!", "body": "To reproduce run opt with the test below with -passes=slp-vectorizer -slp-threshold=-99999\r\n```; ModuleID = './reduced.ll'\r\nsource_filename = \"./reduced.ll\"\r\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\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine void @wombat() #0 gc \"statepoint-example\" {\r\nbb:\r\n %icmp = icmp samesign ult i32 0, 0\r\n %select = select i1 %icmp, i32 0, i32 0\r\n %zext = zext i32 %select to i64\r\n %getelementptr = getelementptr ptr addrspace(1), ptr addrspace(1) null, i64 %zext\r\n store ptr addrspace(1) null, ptr addrspace(1) %getelementptr, align 8\r\n %icmp1 = icmp eq i32 0, 0\r\n %icmp2 = icmp eq i32 0, 0\r\n %icmp3 = icmp samesign ult i32 0, 0\r\n %icmp4 = icmp eq i32 0, 0\r\n %add = add i32 1, 0\r\n %icmp5 = icmp samesign ult i32 %add, 0\r\n store volatile i32 0, ptr addrspace(1) null, align 4\r\n %call = call i32 @llvm.x86.sse2.cvttsd2si(<2 x double> zeroinitializer)\r\n %icmp6 = icmp eq i32 %call, 0\r\n %icmp7 = icmp samesign ult i32 0, 0\r\n ret void\r\n}\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)\r\ndeclare i32 @llvm.x86.sse2.cvttsd2si(<2 x double>) #1\r\n\r\nattributes #0 = { \"target-features\"=\"+prfchw,-cldemote,+avx,+aes,+sahf,+pclmul,-xop,+crc32,+xsaves,-avx512fp16,-usermsr,-sm4,-egpr,+sse4.1,-avx512ifma,+xsave,+sse4.2,-tsxldtrk,-sm3,-ptwrite,-widekl,+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,+fsgsbase,-clzero,-mwaitx,-lwp,+lzcnt,-sha,-movdir64b,-ppx,-wbnoinvd,-enqcmd,-avx10.2-512,-avxneconvert,-tbm,-pconfig,-amx-complex,+ssse3,+cx16,+bmi2,+fma,+popcnt,-avxifma,+f16c,-avx512bitalg,-rdpru,+clwb,+mmx,+sse2,+rdseed,-avx512vbmi2,-prefetchi,-rdpid,-fma4,-avx512vbmi,-shstk,-vaes,-waitpkg,-sgx,+fxsr,+avx512dq,-sse4a,-avx512f\" }\r\nattributes #1 = { nocallback nofree nosync nounwind willreturn memory(none) \"target-features\"=\"+prfchw,-cldemote,+avx,+aes,+sahf,+pclmul,-xop,+crc32,+xsaves,-avx512fp16,-usermsr,-sm4,-egpr,+sse4.1,-avx512ifma,+xsave,+sse4.2,-tsxldtrk,-sm3,-ptwrite,-widekl,+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,+fsgsbase,-clzero,-mwaitx,-lwp,+lzcnt,-sha,-movdir64b,-ppx,-wbnoinvd,-enqcmd,-avx10.2-512,-avxneconvert,-tbm,-pconfig,-amx-complex,+ssse3,+cx16,+bmi2,+fma,+popcnt,-avxifma,+f16c,-avx512bitalg,-rdpru,+clwb,+mmx,+sse2,+rdseed,-avx512vbmi2,-prefetchi,-rdpid,-fma4,-avx512vbmi,-shstk,-vaes,-waitpkg,-sgx,+fxsr,+avx512dq,-sse4a,-avx512f\" }\r\n```\r\nReproducer: https://godbolt.org/z/nTE84xq7n\r\n\r\nStack dump\r\n```\r\nInstruction does not dominate all uses!\r\n %5 = icmp eq <4 x i32> %4, zeroinitializer\r\n %2 = call <8 x i1> @llvm.vector.insert.v8i1.v4i1(<8 x i1> poison, <4 x i1> %5, i64 0)\r\nLLVM ERROR: Broken module found, compilation aborted!\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer -slp-threshold=-99999 <source>\r\n1.\tRunning pass \"verify\" on module \"<source>\"\r\n #0 0x00000000050e7a98 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x50e7a98)\r\n #1 0x00000000050e548c SignalHandler(int) Signals.cpp:0:0\r\n #2 0x000078c8a0042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x000078c8a00969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x000078c8a0042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x000078c8a00287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00000000007d7d7b llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0\r\n #7 0x00000000050265b8 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x50265b8)\r\n #8 0x0000000004f24790 llvm::VerifierPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f24790)\r\n #9 0x00000000009015ce 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+0x9015ce)\r\n#10 0x0000000004ee5440 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4ee5440)\r\n#11 0x000000000090c1ea 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+0x90c1ea)\r\n#12 0x00000000008ff258 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8ff258)\r\n#13 0x000078c8a0029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#14 0x000078c8a0029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#15 0x00000000008f6d2e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8f6d2e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```", "author": "TatyanaDoubts", "labels": ["llvm:SLPVectorizer", "crash-on-valid"], "comments": []}, "verified": true}
6
  {"bug_id": "126974", "issue_url": "https://github.com/llvm/llvm-project/issues/126974", "bug_type": "miscompilation", "base_commit": "dab9156923133b4ce3c40efcae4f80b0d720e72f", "knowledge_cutoff": "2025-02-12T21:21:07Z", "lit_test_dir": ["llvm/test/Transforms/InstCombine"], "hints": {"fix_commit": "29f3a352068ce562bcb65e18a676c82a9991583c", "components": ["InstCombine"], "bug_location_lineno": {"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": [[5637, 5642]]}, "bug_location_funcname": {"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": ["InstCombinerImpl::foldICmpWithMinMax"]}}, "patch": "commit 29f3a352068ce562bcb65e18a676c82a9991583c\nAuthor: Yingwei Zheng <[email protected]>\nDate: Sun Feb 16 20:18:29 2025 +0800\n\n [InstCombine] Do not keep samesign when speculatively executing icmps (#127007)\n \n Closes https://github.com/llvm/llvm-project/issues/126974.\n\ndiff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp\nindex 96d6db2ba5bf..76020d2b1dbf 100644\n--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp\n+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp\n@@ -5637,6 +5637,11 @@ Instruction *InstCombinerImpl::foldICmpWithMinMax(Instruction &I,\n return false;\n return std::nullopt;\n };\n+ // Remove samesign here since it is illegal to keep it when we speculatively\n+ // execute comparisons. For example, `icmp samesign ult umax(X, -46), -32`\n+ // cannot be decomposed into `(icmp samesign ult X, -46) or (icmp samesign ult\n+ // -46, -32)`. `X` is allowed to be non-negative here.\n+ Pred = static_cast<CmpInst::Predicate>(Pred);\n auto CmpXZ = IsCondKnownTrue(simplifyICmpInst(Pred, X, Z, Q));\n auto CmpYZ = IsCondKnownTrue(simplifyICmpInst(Pred, Y, Z, Q));\n if (!CmpXZ.has_value() && !CmpYZ.has_value())\n", "tests": [{"file": "llvm/test/Transforms/InstCombine/umax-icmp.ll", "commands": ["opt -S -passes=instcombine < %s"], "tests": [{"test_name": "pr126974", "test_body": "define i1 @pr126974(i8 %x) {\nentry:\n %cond = icmp sgt i8 %x, -2\n br i1 %cond, label %if.then, label %if.else\n\nif.then: ; preds = %entry\n %umax = call i8 @llvm.umax.i8(i8 %x, i8 -46)\n %cmp = icmp samesign ult i8 %umax, -32\n ret i1 %cmp\n\nif.else: ; preds = %entry\n ret i1 false\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i8 @llvm.umax.i8(i8, i8) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}]}], "issue": {"title": "[RISC-V] Miscompile using rv64gcv", "body": "Testcase:\n```c\nint a[][21][21];\nvoid b(int c, int d, int e, short f, _Bool g, char h, char i, int j, int k,\n int l, unsigned char m, int n, char o, int p, long long q[],\n unsigned short r[][10], unsigned s[][10],\n unsigned long long t[][10][10][10], unsigned long long u[][10][10][10],\n int w[][10][10][10][10], _Bool x) {\n for (signed z = 0; z < (char)m + 3; z = 4)\n for (short aa = ({\n __typeof__(0) ab = 173;\n __typeof__(0) ac = ({\n __typeof__(0) ab = m;\n ab;\n });\n ab > ac ? ab : ac;\n }) -\n 171;\n aa < 9; aa = k)\n a[z][aa][aa] = ~0;\n}\ntypedef int ad;\nint printf(const char *, ...);\nlong long ae;\nvoid af(long long *ae, int v) { *ae ^= v; }\nint c;\nint d;\nint e;\nshort f;\n_Bool g;\nchar h;\nchar i;\nint j;\nint k = 2805750831;\nint l;\nchar m;\nint n;\nchar o;\nint p;\nlong long q[0];\nunsigned short r[0][10];\nunsigned s[0][10];\nunsigned long long t[0][10][10][10];\nunsigned long long u[0][10][10][10];\nint w[0][10][10][10][10];\n_Bool x;\nint a[21][21][21];\nvoid ag() {\n for (ad y = 0; y < 10; ++y)\n for (ad ah = 0; ah < 10; ++ah)\n for (ad ai = 0; ai < 10; ++ai)\n af(&ae, a[y][ah][ai]);\n}\nint main() {\n b(c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, w, x);\n ag();\n printf(\"%llu\\n\", ae);\n}\n```\n\nCommands:\n```\n# riscv \n$ QEMU_CPU=rv64,vlen=128,rvv_ta_all_1s=true,rvv_ma_all_1s=true,v=true,vext_spec=v1.0,zve32f=true,zve64f=true timeout --verbose -k 0.1 4 /scratch/ewlu/daily-upstream-build/build-gcv/bin/qemu-riscv64 user-config.out 1\n0\n\n# x86\n$ ./native.out 1\n18446744073709551615\n```\n\nGodbolt: https://godbolt.org/z/85rz18rxY\n\nBisected to cfee344dda7394631f2177a15e56cfeee1d61fc4 as the first bad commit\n\nI tried reducing the testcase down farther but was unsuccessful\n\nFound via fuzzer. First detected 01/24/2025", "author": "ewlu", "labels": ["miscompilation", "llvm:instcombine"], "comments": [{"author": "dzaima", "body": "Some manual simplification, reproduces on x86-64 `-O3` too:\n\n```c\n#include<stdio.h>\n\nvoid f(int more_than_20, unsigned char zero) {\n int i = 0;\n while (i < (signed char)zero + 2) {\n int max = zero < 210 ? 210 : zero; // 210; has to be >127\n int j = max - 200; // 10\n while (j < 20) {\n printf(\"I should be printed once\\n\");\n j = more_than_20;\n }\n i = 2; // can be anything >2\n }\n}\n\nint main() {\n f(50, 0);\n}\n```\n\nhttps://godbolt.org/z/qfn9PT6r5"}, {"author": "dtcxzyw", "body": "Reproducer: https://alive2.llvm.org/ce/z/adparc"}, {"author": "dtcxzyw", "body": "Further reduced: https://alive2.llvm.org/ce/z/5da83j"}]}, "verified": true}
 
1
  {"bug_id": "128770", "issue_url": "https://github.com/llvm/llvm-project/issues/128770", "bug_type": "crash", "base_commit": "7f482aa848c5f136d2b32431f91f88492c78c709", "knowledge_cutoff": "2025-02-25T20:34:44Z", "lit_test_dir": ["llvm/test/Transforms/SLPVectorizer"], "hints": {"fix_commit": "418a9872851ef5342b29baa36dd672129f129953", "components": ["SLPVectorizer"], "bug_location_lineno": {"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [[13353, 13358], [13453, 13459]]}, "bug_location_funcname": {"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": ["BoUpSLP::isGatherShuffledSingleRegisterEntry"]}}, "patch": "commit 418a9872851ef5342b29baa36dd672129f129953\nAuthor: Alexey Bataev <[email protected]>\nDate: Wed Feb 26 12:59:27 2025 -0800\n\n [SLP]Do not use node, if it is a subvector or buildvector node\n \n If the buildvector has some matches with another node, which is\n a subvector of another buildvector node, need to check for this and\n cancel matching to avoid incorrect ordering of the nodes.\n \n Fixes #128770\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex 02fea2eaf9d4..b25b09306aca 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -13353,6 +13353,14 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(\n return EdgeInfo(const_cast<TreeEntry *>(TE), 0);\n return TE->UserTreeIndex;\n };\n+ auto HasGatherUser = [&](const TreeEntry *TE) {\n+ while (TE->Idx != 0 && TE->UserTreeIndex) {\n+ if (TE->UserTreeIndex.EdgeIdx == UINT_MAX)\n+ return true;\n+ TE = TE->UserTreeIndex.UserTE;\n+ }\n+ return false;\n+ };\n const EdgeInfo TEUseEI = GetUserEntry(TE);\n if (!TEUseEI)\n return std::nullopt;\n@@ -13453,7 +13461,8 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(\n // If the user instruction is used for some reason in different\n // vectorized nodes - make it depend on index.\n if (TEUseEI.UserTE != UseEI.UserTE &&\n- TEUseEI.UserTE->Idx < UseEI.UserTE->Idx)\n+ (TEUseEI.UserTE->Idx < UseEI.UserTE->Idx ||\n+ HasGatherUser(TEUseEI.UserTE)))\n continue;\n }\n \n", "tests": [{"file": "llvm/test/Transforms/SLPVectorizer/X86/buildvector-reused-with-bv-subvector.ll", "commands": ["opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -mcpu=skylake < %s"], "tests": [{"test_name": "<module>", "test_body": "\ndefine void @test(ptr %0, i64 %1, i64 %2) {\n;\n %4 = ptrtoint ptr %0 to i64\n %5 = ptrtoint ptr %0 to i64\n %6 = ptrtoint ptr %0 to i64\n %7 = ptrtoint ptr %0 to i64\n %8 = ptrtoint ptr %0 to i64\n br label %.preheader.lr.ph\n\n.preheader.lr.ph:\n br label %.preheader.us.us.preheader\n\n.preheader.us.us.preheader:\n %9 = or i64 %1, %7\n %10 = or i64 %2, %7\n %11 = or i64 %1, %4\n %12 = or i64 %1, %8\n %13 = or i64 %5, %8\n %14 = or i64 %8, %4\n %15 = or i64 %5, %6\n %16 = or i64 %6, %4\n br label %.preheader.us.us\n\n.preheader.us.us:\n %diff.check1 = icmp ult i64 %9, 32\n %diff.check2 = icmp ult i64 %10, 32\n %conflict.rdx3 = or i1 %diff.check1, %diff.check2\n %diff.check4 = icmp ult i64 %11, 32\n %conflict.rdx5 = or i1 %conflict.rdx3, %diff.check4\n %diff.check6 = icmp ult i64 %12, 32\n %conflict.rdx7 = or i1 %conflict.rdx5, %diff.check6\n %diff.check8 = icmp ult i64 %13, 32\n %conflict.rdx9 = or i1 %conflict.rdx7, %diff.check8\n %diff.check10 = icmp ult i64 %14, 32\n %conflict.rdx11 = or i1 %conflict.rdx9, %diff.check10\n %diff.check12 = icmp ult i64 %15, 32\n %conflict.rdx13 = or i1 %conflict.rdx11, %diff.check12\n %diff.check14 = icmp ult i64 %16, 32\n %conflict.rdx15 = or i1 %conflict.rdx13, %diff.check14\n br i1 %conflict.rdx15, label %scalar.ph, label %.preheader.us.us\n\nscalar.ph:\n ret void\n}"}]}], "issue": {"title": "SLP: Instruction does not dominate all uses (insertelement/shufflevector)", "body": "[slp.ll.gz](https://github.com/user-attachments/files/18972113/slp.ll.gz)\n\nReproducer: `opt -passes=slp-vectorizer slp.ll -mcpu=skylake`\n\n@alexey-bataev can you please take a look?", "author": "vzakhari", "labels": ["llvm:SLPVectorizer", "crash"], "comments": []}, "verified": true}
2
  {"bug_id": "127739", "issue_url": "https://github.com/llvm/llvm-project/issues/127739", "bug_type": "crash", "base_commit": "d6301b218c6698ceb0db1753c8de480d37d11cf8", "knowledge_cutoff": "2025-02-19T03:17:57Z", "lit_test_dir": ["llvm/test/Transforms/Scalarizer"], "hints": {"fix_commit": "1440f02259abf585f0c2965bd4ececf0f3499405", "components": ["Scalarizer"], "bug_location_lineno": {"llvm/lib/Transforms/Scalar/Scalarizer.cpp": [[719, 731], [1083, 1088]]}, "bug_location_funcname": {"llvm/lib/Transforms/Scalar/Scalarizer.cpp": ["ScalarizerVisitor::splitCall", "ScalarizerVisitor::visitExtractValueInst"]}}, "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", "tests": [{"file": "llvm/test/Transforms/Scalarizer/min-bits.ll", "commands": ["opt %s -passes='function(scalarizer<load-store;min-bits=16>,dce)' -S", "opt %s -passes='function(scalarizer<load-store;min-bits=32>,dce)' -S", "opt %s -passes='function(scalarizer<load-store;min-bits=64>,dce)' -S"], "tests": [{"test_name": "load_add_store_v2i16", "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"}, {"test_name": "select_uniform_condition_v3f16", "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"}, {"test_name": "call_v4f16", "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"}, {"test_name": "unary_v4f16", "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"}, {"test_name": "gep1_v4", "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"}, {"test_name": "fptosi_v3f16", "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"}, {"test_name": "binary_v2f16", "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"}, {"test_name": "gep3_v4", "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"}, {"test_name": "fptosi_v4f16", "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"}, {"test_name": "binary_v3f16", "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"}, {"test_name": "load_add_store_v4i16", "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"}, {"test_name": "select_uniform_condition_v2f16", "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"}, {"test_name": "shufflevector_shrink", "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"}, {"test_name": "phi_v2f16", "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"}, {"test_name": "frexp_v2f16", "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"}, {"test_name": "load_insertelement_v3i16", "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"}, {"test_name": "load_add_store_v3i16", "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"}, {"test_name": "fptosi_v2f16", "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"}, {"test_name": "insertelement_v4i16", "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"}, {"test_name": "load_insertelement_v2i16", "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"}, {"test_name": "load_insertelement_v4i16", "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"}, {"test_name": "insertelement_v2i16", "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"}, {"test_name": "shufflevector_grow", "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"}, {"test_name": "uadd_with_overflow_v3i32", "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"}, {"test_name": "insertelement_v3i16", "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"}, {"test_name": "call_v2f16", "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"}, {"test_name": "phi_v3f16", "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"}, {"test_name": "phi_v4f16", "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"}, {"test_name": "call_v3f16", "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"}, {"test_name": "binary_v4f16", "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"}, {"test_name": "fpext_v4f16", "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"}, {"test_name": "load_add_store_v4i10", "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"}, {"test_name": "unary_v3f16", "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"}, {"test_name": "unary_v2f16", "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"}, {"test_name": "select_uniform_condition_v4f16", "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"}]}], "issue": {"title": "[Scalarizer] Test *_with_overflow crash with min-bits=32 and min-bits=16", "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 ", "author": "farzonl", "labels": ["crash-on-valid", "llvm:analysis"], "comments": [{"author": "farzonl", "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."}, {"author": "Icohedron", "body": "I'm on it"}, {"author": "jayfoad", "body": "As mentioned in #127996, note that you can also provoke this bug by adding `min-bits=64` to `test/Transforms/Scalarizer/frexp.ll`."}, {"author": "Icohedron", "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```"}]}, "verified": true}
3
  {"bug_id": "126181", "issue_url": "https://github.com/llvm/llvm-project/issues/126181", "bug_type": "miscompilation", "base_commit": "317a644ae6d501f1a1ec54d17ea8559bcdea35c0", "knowledge_cutoff": "2025-02-07T05:51:32Z", "lit_test_dir": ["llvm/test/Transforms/DeadStoreElimination"], "hints": {"fix_commit": "2d31a12dbe2339d20844ede70cbb54dbaf4ceea9", "components": ["DeadStoreElimination"], "bug_location_lineno": {"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": [[2283, 2289]]}, "bug_location_funcname": {"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": ["DSEState::getInitializesArgMemLoc"]}}, "patch": "commit 2d31a12dbe2339d20844ede70cbb54dbaf4ceea9\nAuthor: Nikita Popov <[email protected]>\nDate: Mon Feb 10 10:34:03 2025 +0100\n\n [DSE] Don't use initializes on byval argument (#126259)\n \n There are two ways we can fix this problem, depending on how the\n semantics of byval and initializes should interact:\n \n * Don't infer initializes on byval arguments. initializes on byval\n refers to the original caller memory (or having both attributes is made\n a verifier error).\n * Infer initializes on byval, but don't use it in DSE. initializes on\n byval refers to the callee copy. This matches the semantics of readonly\n on byval. This is slightly more powerful, for example, we could do a\n backend optimization where byval + initializes will allocate the full\n size of byval on the stack but not copy over the parts covered by\n initializes.\n \n I went with the second variant here, skipping byval + initializes in DSE\n (FunctionAttrs already doesn't propagate initializes past byval). I'm\n open to going in the other direction though.\n \n Fixes https://github.com/llvm/llvm-project/issues/126181.\n\ndiff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp\nindex 05b4f176bfc3..38454053b039 100644\n--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp\n+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp\n@@ -2283,7 +2283,9 @@ DSEState::getInitializesArgMemLoc(const Instruction *I) {\n for (unsigned Idx = 0, Count = CB->arg_size(); Idx < Count; ++Idx) {\n ConstantRangeList Inits;\n Attribute InitializesAttr = CB->getParamAttr(Idx, Attribute::Initializes);\n- if (InitializesAttr.isValid())\n+ // initializes on byval arguments refers to the callee copy, not the\n+ // original memory the caller passed in.\n+ if (InitializesAttr.isValid() && !CB->isByValArgument(Idx))\n Inits = InitializesAttr.getValueAsConstantRangeList();\n \n Value *CurArg = CB->getArgOperand(Idx);\n", "tests": [{"file": "llvm/test/Transforms/DeadStoreElimination/inter-procedural.ll", "commands": ["opt < %s -passes=dse -enable-dse-initializes-attr-improvement -S"], "tests": [{"test_name": "test_byval", "test_body": "%struct.a = type { i32, i64, i32, i32 }\n\n@e = dso_local global { i32, [4 x i8], i64, i32, i32 } { i32 5, [4 x i8] zeroinitializer, i64 0, i32 1, i32 90986701 }, align 8\n\ndefine i8 @ad(ptr byval(%struct.a) %ah) {\nentry:\n store i32 0, ptr %ah, align 8\n %call = call i64 @af(ptr %ah)\n %0 = load i8, ptr %ah, align 1\n ret i8 %0\n}\n\ndefine i64 @af(ptr byval(%struct.a) initializes((0, 24)) %am) {\nentry:\n call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %am, ptr noundef nonnull align 8 dereferenceable(24) @e, i64 24, i1 false)\n ret i64 0\n}\n\ndefine i32 @main() {\n %res = call i8 @ad(ptr @e)\n %val = sext i8 %res to i32\n ret i32 %val\n}\n", "lli_expected_out": ""}]}], "issue": {"title": "[FuncAttrs] `initializes` is incorrectly set on parameters with `byval`", "body": "Reproducer: https://godbolt.org/z/Mcx1nY4E7\n```\n; bin/opt -passes=function-attrs reduced.ll -S\n%struct.a = type { i32, i64, i32, i32 }\n\n@e = dso_local global { i32, [4 x i8], i64, i32, i32 } { i32 5, [4 x i8] zeroinitializer, i64 0, i32 1, i32 90986701 }, align 8\n\ndefine i8 @ad(ptr byval(%struct.a) %ah) {\nentry:\n store i32 0, ptr %ah, align 8\n %call = call i64 @af(ptr %ah)\n %0 = load i8, ptr %ah, align 1\n ret i8 %0\n}\n\ndefine i64 @af(ptr byval(%struct.a) %am) {\nentry:\n call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %am, ptr noundef nonnull align 8 dereferenceable(24) @e, i64 24, i1 false)\n ret i64 0\n}\n\n```\n```\ndefine i8 @ad(ptr byval(%struct.a) captures(none) initializes((0, 4)) %ah) #0 {\n store i32 0, ptr %ah, align 8\n %call = call i64 @af(ptr %ah)\n %0 = load i8, ptr %ah, align 1\n ret i8 %0\n}\n\ndefine noundef i64 @af(ptr writeonly byval(%struct.a) captures(none) initializes((0, 24)) %am) #0 {\n call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %am, ptr noundef nonnull align 8 dereferenceable(24) @e, i64 24, i1 false)\n ret i64 0\n}\n```\nAfter DSE:\n```\ndefine i8 @ad(ptr byval(%struct.a) captures(none) initializes((0, 4)) %ah) #0 {\n %call = call i64 @af(ptr %ah)\n %0 = load i8, ptr %ah, align 1\n ret i8 %0\n}\n\ndefine noundef i64 @af(ptr writeonly byval(%struct.a) captures(none) initializes((0, 24)) %am) #0 {\n ret i64 0\n}\n```\n\nllvm version: d21fc58aeeaa7f0369a24dbe70a0360e0edbf76f\n", "author": "dtcxzyw", "labels": ["miscompilation", "llvm:transforms"], "comments": [{"author": "nikic", "body": "> We should also emit the padding for %struct.a.\n\nWithout commenting on whether we should or shouldn't, why is not having the padding a miscompile? As this is not a packed struct, for a i64:64 target, LLVM will implicitly insert the padding and it should have the correct size."}, {"author": "dtcxzyw", "body": "> As this is not a packed struct, for a i64:64 target, LLVM will implicitly insert the padding and it should have the correct size.\n\nSorry. It is a DSE bug.\n"}, {"author": "dtcxzyw", "body": "cc @haopliu "}, {"author": "nikic", "body": "@dtcxzyw I think your new IR is over-reduced. You have `initializes((0, 24)` on `@af`, so I think eliminating the store is correct."}, {"author": "dtcxzyw", "body": "> [@dtcxzyw](https://github.com/dtcxzyw) I think your new IR is over-reduced. You have `initializes((0, 24)` on `@af`, so I think eliminating the store is correct.\n\nFixed."}, {"author": "nikic", "body": "There are two ways we can fix this, depending on what we want the semantics to do:\n\n 1. Don't infer initializes on byval arguments. initializes on byval refers to the original caller memory (or having both attributes is made a verifier error).\n 2. Infer initializes on byval, but don't use it in DSE. initializes on byval refers to the callee copy. This matches the semantics of readonly on byval.\n\nI think variant 2 is marginally more powerful. For example, we could do a backend optimization where byval + initializes will allocate the full size of byval on the stack but not copy over the parts covered by initializes."}]}, "verified": true}
4
+ {"bug_id": "131818", "issue_url": "https://github.com/llvm/llvm-project/issues/131818", "bug_type": "crash", "base_commit": "84909d797782a0dcf240f79a8e5e863d8165c03f", "knowledge_cutoff": "2025-03-18T15:06:59Z", "lit_test_dir": ["llvm/test/Transforms/SLPVectorizer"], "hints": {"fix_commit": "45090b3059562b32723cd25679db75d1574ab04e", "components": ["SLPVectorizer"], "bug_location_lineno": {"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [[14086, 14096]]}, "bug_location_funcname": {"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": ["BoUpSLP::isGatherShuffledSingleRegisterEntry"]}}, "patch": "commit 45090b3059562b32723cd25679db75d1574ab04e\nAuthor: Alexey Bataev <[email protected]>\nDate: Tue Mar 18 09:32:23 2025 -0700\n\n [SLP]Check the whole def-use chain in the tree to find proper dominance, if the last instruction is the same\n \n If the insertion point (last instruction) of the user nodes is the same,\n need to check the whole def-use chain in the tree to find proper\n dominance to prevent a compiler crash.\n \n Fixes #131818\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex 24171f1d9a06..4a835bc797ab 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -14086,11 +14086,18 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(\n auto CheckParentNodes = [&](const TreeEntry *User1, const TreeEntry *User2,\n unsigned EdgeIdx) {\n const TreeEntry *Ptr1 = User1;\n+ const TreeEntry *Ptr2 = User2;\n+ SmallDenseMap<const TreeEntry *, unsigned> PtrToIdx;\n+ while (Ptr2) {\n+ PtrToIdx.try_emplace(Ptr2, EdgeIdx);\n+ EdgeIdx = Ptr2->UserTreeIndex.EdgeIdx;\n+ Ptr2 = Ptr2->UserTreeIndex.UserTE;\n+ }\n while (Ptr1) {\n unsigned Idx = Ptr1->UserTreeIndex.EdgeIdx;\n Ptr1 = Ptr1->UserTreeIndex.UserTE;\n- if (Ptr1 == User2)\n- return Idx < EdgeIdx;\n+ if (auto It = PtrToIdx.find(Ptr1); It != PtrToIdx.end())\n+ return Idx < It->second;\n }\n return false;\n };\n", "tests": [{"file": "llvm/test/Transforms/SLPVectorizer/X86/same-last-instruction-different-parents.ll", "commands": ["opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"], "tests": [{"test_name": "<module>", "test_body": "\ndefine i32 @test(i32 %0, i1 %1) {\n;\n %3 = sitofp i32 %0 to double\n %4 = sitofp i32 %0 to double\n %5 = sitofp i32 %0 to double\n br i1 %1, label %6, label %9\n\n6:\n %7 = tail call double @llvm.fmuladd.f64(double %4, double 0.000000e+00, double 0.000000e+00)\n %8 = tail call double @llvm.fmuladd.f64(double %5, double 0.000000e+00, double 0.000000e+00)\n br label %18\n\n9:\n br i1 false, label %15, label %10\n\n10:\n %11 = call double @llvm.copysign.f64(double 0.000000e+00, double %3)\n %12 = tail call double @llvm.fmuladd.f64(double %11, double %4, double 0.000000e+00)\n %13 = call double @llvm.copysign.f64(double 0.000000e+00, double %5)\n %14 = tail call double @llvm.fmuladd.f64(double %13, double 0.000000e+00, double 0.000000e+00)\n br label %15\n\n15:\n %16 = phi double [ %12, %10 ], [ 0.000000e+00, %9 ]\n %17 = phi double [ %14, %10 ], [ 0.000000e+00, %9 ]\n br label %18\n\n18:\n %19 = phi double [ %17, %15 ], [ %8, %6 ]\n %20 = phi double [ %16, %15 ], [ %7, %6 ]\n %21 = fmul double %20, %19\n %22 = fptosi double %21 to i32\n ret i32 %22\n}"}]}], "issue": {"title": "[clang] Crash at -O3: Instruction does not dominate all uses!", "body": "This code crashes at `-O3`:\n\n```c\nint a;\ndouble b;\nlong c;\nint d(long f, long g) {\n if (f + g)\n return 1;\n for (long e = 0; e < g; e++)\n *(char *)e = 5;\n return 0;\n}\nint h(int f) {\n double i = 0.270112271089232341485679099e4;\n b = 0.1e1;\n for (; c; c--) {\n i = i * (80 + f) * (9 + f) + a;\n a = 0;\n b = b * f * (d(-42, f) + f) + 0.11623987080032122878585294e22;\n }\n return i / b;\n}\nvoid main() {}\n```\n\nCompiler Explorer: https://godbolt.org/z/b4YEsPMrq\n\nBisected to https://github.com/llvm/llvm-project/commit/d57884011e8c57b118b831614b692ba4bc8b5aca, which was committed by @alexey-bataev \n\nCrash:\n\n```console\nInstruction does not dominate all uses!\n %3 = insertelement <2 x i32> %2, i32 %f, i64 1\n %0 = insertelement <2 x i32> %3, i32 %add1, i64 0\nin function h\nfatal error: error in backend: Broken function found, compilation aborted!\n```\n\nBacktrace:\n\n```console\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 -O3 -Wall -Wextra <source>\n1.\t<eof> parser at end of file\n2.\tCode generation\n3.\tRunning pass 'Function Pass Manager' on module '<source>'.\n4.\tRunning pass 'Module Verifier' on function '@h'\n #0 0x0000000003e87c38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e87c38)\n #1 0x0000000003e858c4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e858c4)\n #2 0x0000000003dcacb6 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dcacb6)\n #3 0x0000000003e7cfee llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e7cfee)\n #4 0x0000000000d4e5a0 LLVMErrorHandler(void*, char const*, bool) cc1_main.cpp:0:0\n #5 0x0000000003dd5443 llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dd5443)\n #6 0x0000000003dd55a8 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dd55a8)\n #7 0x0000000003887952 (anonymous namespace)::VerifierLegacyPass::runOnFunction(llvm::Function&) Verifier.cpp:0:0\n #8 0x00000000037d28df llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x37d28df)\n #9 0x00000000037d2c91 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x37d2c91)\n#10 0x00000000037d3531 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x37d3531)\n#11 0x000000000413d67e 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+0x413d67e)\n#12 0x00000000048429a0 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x48429a0)\n#13 0x00000000064aecac clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x64aecac)\n#14 0x0000000004842da8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4842da8)\n#15 0x0000000004b127f5 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4b127f5)\n#16 0x0000000004a94a2e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4a94a2e)\n#17 0x0000000004c024fe clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4c024fe)\n#18 0x0000000000d50baf cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd50baf)\n#19 0x0000000000d4836a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#20 0x000000000488b309 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#21 0x0000000003dcabf4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dcabf4)\n#22 0x000000000488b91f 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#23 0x000000000484e38d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x484e38d)\n#24 0x000000000484f41e 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+0x484f41e)\n#25 0x0000000004856af5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4856af5)\n#26 0x0000000000d4d9a8 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd4d9a8)\n#27 0x0000000000c146c4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc146c4)\n#28 0x00007acc03029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#29 0x00007acc03029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#30 0x0000000000d47e15 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd47e15)\n```", "author": "cardigan1008", "labels": ["llvm:SLPVectorizer", "crash-on-valid"], "comments": []}, "verified": true}
5
  {"bug_id": "113143", "issue_url": "https://github.com/llvm/llvm-project/issues/113143", "bug_type": "crash", "base_commit": "42ba452aa94e4da277842d8990ad958a6256e558", "knowledge_cutoff": "2024-10-21T10:11:54Z", "lit_test_dir": ["llvm/test/Transforms/SLPVectorizer"], "hints": {"fix_commit": "9e03920cbf946e7ba282e99213707643a23ae5fb", "components": ["SLPVectorizer"], "bug_location_lineno": {"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [[12466, 12472]]}, "bug_location_funcname": {"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": ["BoUpSLP::isGatherShuffledSingleRegisterEntry"]}}, "patch": "commit 9e03920cbf946e7ba282e99213707643a23ae5fb\nAuthor: Alexey Bataev <[email protected]>\nDate: Mon Oct 21 08:57:36 2024 -0700\n\n [SLP]Ignore root gather node, when searching for reuses\n \n Root gather/buildvector node should be ignored when SLP vectorizer tries\n to find matching gather nodes, vectorized earlier. This node is\n definitely the last one in the pipeline and it does not have users. It\n may cause the compiler crash\n \n Fixes #113143\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex 1098bf578d2d..a11e3f3815cb 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -12466,7 +12466,7 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(\n // Build a list of tree entries where V is used.\n SmallPtrSet<const TreeEntry *, 4> VToTEs;\n for (const TreeEntry *TEPtr : ValueToGatherNodes.find(V)->second) {\n- if (TEPtr == TE)\n+ if (TEPtr == TE || TEPtr->Idx == 0)\n continue;\n assert(any_of(TEPtr->Scalars,\n [&](Value *V) { return GatheredScalars.contains(V); }) &&\n", "tests": [{"file": "llvm/test/Transforms/SLPVectorizer/X86/root-gather-reused-scalar.ll", "commands": ["opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"], "tests": [{"test_name": "test", "test_body": "define void @test(ptr %a, i32 %0, i32 %1, i1 %cmp1) {\nentry:\n %2 = load i32, ptr %a, align 4\n %tobool10.not = icmp eq i32 %0, 0\n %cmp4.3 = icmp ne i32 %1, 0\n %3 = and i1 %cmp4.3, %tobool10.not\n %cmp2.2 = xor i1 %tobool10.not, true\n %conv3.2 = zext i1 %cmp2.2 to i32\n %cmp4.2 = icmp ne i32 %2, %conv3.2\n %cmp2.1 = xor i1 %cmp1, true\n %conv3.1 = zext i1 %cmp2.1 to i32\n %cmp4.1 = icmp ne i32 %2, %conv3.1\n %4 = select i1 %3, i1 %cmp4.2, i1 false\n %5 = select i1 %4, i1 %cmp4.1, i1 false\n %and.3 = zext i1 %5 to i32\n store i32 %and.3, ptr %a, align 4\n ret void\n}\n"}]}], "issue": {"title": "clang crashes on valid code at -O2 on x86_64-linux-gnu: Assertion `TEPtr->UserTreeIndices.size() == 1 && \"Expected only single user of a gather node.\"' failed ", "body": "It appears to be a recent regression as it doesn't reproduce with 19.1.0 and earlier. \r\n\r\nCompiler Explorer: https://godbolt.org/z/a1W3c5ard\r\n\r\n```\r\n[523] % clangtk -v\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git df8b785838a2db01b4d056e603f7317209accefb)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\r\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nCandidate multilib: .;@m64\r\nSelected multilib: .;@m64\r\n[524] % \r\n[524] % clangtk -O2 small.c\r\nclang-20: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:12559: std::optional<llvm::TargetTransformInfo::ShuffleKind> llvm::slpvectorizer::BoUpSLP::isGatherShuffledSingleRegisterEntry(const llvm::slpvectorizer::BoUpSLP::TreeEntry*, llvm::ArrayRef<llvm::Value*>, llvm::MutableArrayRef<int>, llvm::SmallVectorImpl<const llvm::slpvectorizer::BoUpSLP::TreeEntry*>&, unsigned int, bool): Assertion `TEPtr->UserTreeIndices.size() == 1 && \"Expected only single user of a gather node.\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-20 -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/20241020-clangtk-m64-O2-build-231331/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20241020-clangtk-m64-O2-build-231331/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/20 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/20/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 -O2 -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-572b89.o -x c small.c\r\n1.\t<eof> parser at end of file\r\n2.\tOptimizer\r\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\"\r\n4.\tRunning pass \"slp-vectorizer\" on function \"main\"\r\n #0 0x0000560576c8b9af llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x43f29af)\r\n #1 0x0000560576c89184 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007f4623c27420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\r\n #3 0x00007f462365e00b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #4 0x00007f462363d859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\r\n #5 0x00007f462363d729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #6 0x00007f462363d729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #7 0x00007f462364efd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #8 0x0000560578707edc llvm::slpvectorizer::BoUpSLP::isGatherShuffledSingleRegisterEntry(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::MutableArrayRef<int>, llvm::SmallVectorImpl<llvm::slpvectorizer::BoUpSLP::TreeEntry const*>&, unsigned int, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5e6eedc)\r\n #9 0x0000560578708cd8 llvm::slpvectorizer::BoUpSLP::isGatherShuffledEntry(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallVectorImpl<int>&, llvm::SmallVectorImpl<llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, 6u>>&, unsigned int, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5e6fcd8)\r\n#10 0x000056057870a6f3 llvm::InstructionCost llvm::slpvectorizer::BoUpSLP::processBuildVector<llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator, llvm::InstructionCost, llvm::TargetTransformInfo, llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP, llvm::SmallPtrSetImpl<llvm::Value*>>(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::Type*, llvm::TargetTransformInfo&, llvm::ArrayRef<llvm::Value*>&, llvm::slpvectorizer::BoUpSLP&, llvm::SmallPtrSetImpl<llvm::Value*>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5e716f3)\r\n#11 0x000056057870cde7 llvm::slpvectorizer::BoUpSLP::getEntryCost(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallPtrSetImpl<llvm::Value*>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5e73de7)\r\n#12 0x0000560578745f69 llvm::slpvectorizer::BoUpSLP::getTreeCost(llvm::ArrayRef<llvm::Value*>) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5eacf69)\r\n#13 0x000056057874b57b (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&) SLPVectorizer.cpp:0:0\r\n#14 0x000056057874eb79 llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5eb5b79)\r\n#15 0x000056057875349b llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (.constprop.0) SLPVectorizer.cpp:0:0\r\n#16 0x0000560578757d50 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5ebed50)\r\n#17 0x000056057875e590 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\r\n#18 0x000056057875f263 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5ec6263)\r\n#19 0x00005605781e0e66 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-20+0x5947e66)\r\n#20 0x0000560576614891 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3d7b891)\r\n#21 0x000056057410e656 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-20+0x1875656)\r\n#22 0x00005605766131fd llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3d7a1fd)\r\n#23 0x000056057410d196 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-20+0x1874196)\r\n#24 0x0000560576612c31 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3d79c31)\r\n#25 0x0000560576f44dd3 (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\r\n#26 0x0000560576f483a8 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, 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-20+0x46af3a8)\r\n#27 0x000056057764462c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4dab62c)\r\n#28 0x000056057951629c clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x6c7d29c)\r\n#29 0x0000560577644a48 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4daba48)\r\n#30 0x000056057790d3d9 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x50743d9)\r\n#31 0x00005605778895ce clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4ff05ce)\r\n#32 0x00005605779f9f26 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5160f26)\r\n#33 0x0000560573cd1fe5 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x1438fe5)\r\n#34 0x0000560573cc9afa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#35 0x0000560573cce52e clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x143552e)\r\n#36 0x0000560573bba67b main (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x132167b)\r\n#37 0x00007f462363f083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#38 0x0000560573cc958e _start (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x143058e)\r\nclangtk: error: unable to execute command: Aborted\r\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git df8b785838a2db01b4d056e603f7317209accefb)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nclangtk: note: diagnostic msg: \r\n********************\r\n\r\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\r\nPreprocessed source(s) and associated run script(s) are located at:\r\nclangtk: note: diagnostic msg: /tmp/small-d99d4e.c\r\nclangtk: note: diagnostic msg: /tmp/small-d99d4e.sh\r\nclangtk: note: diagnostic msg: \r\n\r\n********************\r\n[525] % \r\n[525] % cat small.c\r\nint a, b, c, d, e, f;\r\nint main() {\r\n for (f = 0; f < 4; f++) {\r\n d &= (((a > 0) != b) != c) && b;\r\n for (b = 0; b < 1; b++)\r\n if (e)\r\n break;\r\n }\r\n return 0;\r\n}\r\n```\r\n\r\n", "author": "zhendongsu", "labels": ["llvm:SLPVectorizer", "crash-on-valid"], "comments": []}, "verified": true}
6
  {"bug_id": "114082", "issue_url": "https://github.com/llvm/llvm-project/issues/114082", "bug_type": "crash", "base_commit": "0f040433d325aa68ec6840aa179f3f314c26153a", "knowledge_cutoff": "2024-10-29T16:26:31Z", "lit_test_dir": ["llvm/test/Transforms/SLPVectorizer"], "hints": {"fix_commit": "77bec78878762e34150fe23734fa43df796c873c", "components": ["SLPVectorizer"], "bug_location_lineno": {"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [[13398, 13404]]}, "bug_location_funcname": {"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": ["BoUpSLP::getLastInstructionInBundle"]}}, "patch": "commit 77bec78878762e34150fe23734fa43df796c873c\nAuthor: Alexey Bataev <[email protected]>\nDate: Fri Nov 8 04:16:01 2024 -0800\n\n [SLP]Do not look for last instruction in schedule block for buildvectors\n \n If looking for the insertion point for the node and the node is\n a buildvector node, the compiler should not use scheduling info for such\n nodes, they may contain only partial info, which is not fully correct\n and may cause compiler crash.\n \n Fixes #114082\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex b2f677fb84f9..c5b3537bc57b 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -13398,7 +13398,7 @@ Instruction &BoUpSLP::getLastInstructionInBundle(const TreeEntry *E) {\n // scheduled, and the last instruction is VL.back(). So we start with\n // VL.back() and iterate over schedule data until we reach the end of the\n // bundle. The end of the bundle is marked by null ScheduleData.\n- if (BlocksSchedules.count(BB)) {\n+ if (BlocksSchedules.count(BB) && !E->isGather()) {\n Value *V = E->isOneOf(E->Scalars.back());\n if (doesNotNeedToBeScheduled(V))\n V = *find_if_not(E->Scalars, doesNotNeedToBeScheduled);\n", "tests": [{"file": "llvm/test/Transforms/SLPVectorizer/X86/buildvector-schedule-for-subvector.ll", "commands": ["opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-99999 < %s"], "tests": [{"test_name": "test", "test_body": "define void @test() {\nbb:\n %icmp = icmp samesign ult i32 0, 0\n %select = select i1 %icmp, i32 0, i32 0\n %zext = zext i32 %select to i64\n %getelementptr = getelementptr ptr addrspace(1), ptr addrspace(1) null, i64 %zext\n store ptr addrspace(1) null, ptr addrspace(1) %getelementptr, align 8\n %icmp1 = icmp eq i32 0, 0\n %icmp2 = icmp eq i32 0, 0\n %icmp3 = icmp samesign ult i32 0, 0\n %icmp4 = icmp eq i32 0, 0\n %add = add i32 1, 0\n %icmp5 = icmp samesign ult i32 %add, 0\n store volatile i32 0, ptr addrspace(1) null, align 4\n %call = call i32 null(<2 x double> zeroinitializer)\n %icmp6 = icmp eq i32 %call, 0\n %icmp7 = icmp samesign ult i32 0, 0\n ret void\n}\n"}]}], "issue": {"title": "[SLPVectorizer] Instruction does not dominate all uses! LLVM ERROR: Broken module found, compilation aborted!", "body": "To reproduce run opt with the test below with -passes=slp-vectorizer -slp-threshold=-99999\r\n```; ModuleID = './reduced.ll'\r\nsource_filename = \"./reduced.ll\"\r\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\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine void @wombat() #0 gc \"statepoint-example\" {\r\nbb:\r\n %icmp = icmp samesign ult i32 0, 0\r\n %select = select i1 %icmp, i32 0, i32 0\r\n %zext = zext i32 %select to i64\r\n %getelementptr = getelementptr ptr addrspace(1), ptr addrspace(1) null, i64 %zext\r\n store ptr addrspace(1) null, ptr addrspace(1) %getelementptr, align 8\r\n %icmp1 = icmp eq i32 0, 0\r\n %icmp2 = icmp eq i32 0, 0\r\n %icmp3 = icmp samesign ult i32 0, 0\r\n %icmp4 = icmp eq i32 0, 0\r\n %add = add i32 1, 0\r\n %icmp5 = icmp samesign ult i32 %add, 0\r\n store volatile i32 0, ptr addrspace(1) null, align 4\r\n %call = call i32 @llvm.x86.sse2.cvttsd2si(<2 x double> zeroinitializer)\r\n %icmp6 = icmp eq i32 %call, 0\r\n %icmp7 = icmp samesign ult i32 0, 0\r\n ret void\r\n}\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)\r\ndeclare i32 @llvm.x86.sse2.cvttsd2si(<2 x double>) #1\r\n\r\nattributes #0 = { \"target-features\"=\"+prfchw,-cldemote,+avx,+aes,+sahf,+pclmul,-xop,+crc32,+xsaves,-avx512fp16,-usermsr,-sm4,-egpr,+sse4.1,-avx512ifma,+xsave,+sse4.2,-tsxldtrk,-sm3,-ptwrite,-widekl,+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,+fsgsbase,-clzero,-mwaitx,-lwp,+lzcnt,-sha,-movdir64b,-ppx,-wbnoinvd,-enqcmd,-avx10.2-512,-avxneconvert,-tbm,-pconfig,-amx-complex,+ssse3,+cx16,+bmi2,+fma,+popcnt,-avxifma,+f16c,-avx512bitalg,-rdpru,+clwb,+mmx,+sse2,+rdseed,-avx512vbmi2,-prefetchi,-rdpid,-fma4,-avx512vbmi,-shstk,-vaes,-waitpkg,-sgx,+fxsr,+avx512dq,-sse4a,-avx512f\" }\r\nattributes #1 = { nocallback nofree nosync nounwind willreturn memory(none) \"target-features\"=\"+prfchw,-cldemote,+avx,+aes,+sahf,+pclmul,-xop,+crc32,+xsaves,-avx512fp16,-usermsr,-sm4,-egpr,+sse4.1,-avx512ifma,+xsave,+sse4.2,-tsxldtrk,-sm3,-ptwrite,-widekl,+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,+fsgsbase,-clzero,-mwaitx,-lwp,+lzcnt,-sha,-movdir64b,-ppx,-wbnoinvd,-enqcmd,-avx10.2-512,-avxneconvert,-tbm,-pconfig,-amx-complex,+ssse3,+cx16,+bmi2,+fma,+popcnt,-avxifma,+f16c,-avx512bitalg,-rdpru,+clwb,+mmx,+sse2,+rdseed,-avx512vbmi2,-prefetchi,-rdpid,-fma4,-avx512vbmi,-shstk,-vaes,-waitpkg,-sgx,+fxsr,+avx512dq,-sse4a,-avx512f\" }\r\n```\r\nReproducer: https://godbolt.org/z/nTE84xq7n\r\n\r\nStack dump\r\n```\r\nInstruction does not dominate all uses!\r\n %5 = icmp eq <4 x i32> %4, zeroinitializer\r\n %2 = call <8 x i1> @llvm.vector.insert.v8i1.v4i1(<8 x i1> poison, <4 x i1> %5, i64 0)\r\nLLVM ERROR: Broken module found, compilation aborted!\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer -slp-threshold=-99999 <source>\r\n1.\tRunning pass \"verify\" on module \"<source>\"\r\n #0 0x00000000050e7a98 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x50e7a98)\r\n #1 0x00000000050e548c SignalHandler(int) Signals.cpp:0:0\r\n #2 0x000078c8a0042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x000078c8a00969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x000078c8a0042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x000078c8a00287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00000000007d7d7b llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0\r\n #7 0x00000000050265b8 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x50265b8)\r\n #8 0x0000000004f24790 llvm::VerifierPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f24790)\r\n #9 0x00000000009015ce 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+0x9015ce)\r\n#10 0x0000000004ee5440 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4ee5440)\r\n#11 0x000000000090c1ea 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+0x90c1ea)\r\n#12 0x00000000008ff258 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8ff258)\r\n#13 0x000078c8a0029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#14 0x000078c8a0029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#15 0x00000000008f6d2e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8f6d2e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```", "author": "TatyanaDoubts", "labels": ["llvm:SLPVectorizer", "crash-on-valid"], "comments": []}, "verified": true}
7
  {"bug_id": "126974", "issue_url": "https://github.com/llvm/llvm-project/issues/126974", "bug_type": "miscompilation", "base_commit": "dab9156923133b4ce3c40efcae4f80b0d720e72f", "knowledge_cutoff": "2025-02-12T21:21:07Z", "lit_test_dir": ["llvm/test/Transforms/InstCombine"], "hints": {"fix_commit": "29f3a352068ce562bcb65e18a676c82a9991583c", "components": ["InstCombine"], "bug_location_lineno": {"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": [[5637, 5642]]}, "bug_location_funcname": {"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": ["InstCombinerImpl::foldICmpWithMinMax"]}}, "patch": "commit 29f3a352068ce562bcb65e18a676c82a9991583c\nAuthor: Yingwei Zheng <[email protected]>\nDate: Sun Feb 16 20:18:29 2025 +0800\n\n [InstCombine] Do not keep samesign when speculatively executing icmps (#127007)\n \n Closes https://github.com/llvm/llvm-project/issues/126974.\n\ndiff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp\nindex 96d6db2ba5bf..76020d2b1dbf 100644\n--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp\n+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp\n@@ -5637,6 +5637,11 @@ Instruction *InstCombinerImpl::foldICmpWithMinMax(Instruction &I,\n return false;\n return std::nullopt;\n };\n+ // Remove samesign here since it is illegal to keep it when we speculatively\n+ // execute comparisons. For example, `icmp samesign ult umax(X, -46), -32`\n+ // cannot be decomposed into `(icmp samesign ult X, -46) or (icmp samesign ult\n+ // -46, -32)`. `X` is allowed to be non-negative here.\n+ Pred = static_cast<CmpInst::Predicate>(Pred);\n auto CmpXZ = IsCondKnownTrue(simplifyICmpInst(Pred, X, Z, Q));\n auto CmpYZ = IsCondKnownTrue(simplifyICmpInst(Pred, Y, Z, Q));\n if (!CmpXZ.has_value() && !CmpYZ.has_value())\n", "tests": [{"file": "llvm/test/Transforms/InstCombine/umax-icmp.ll", "commands": ["opt -S -passes=instcombine < %s"], "tests": [{"test_name": "pr126974", "test_body": "define i1 @pr126974(i8 %x) {\nentry:\n %cond = icmp sgt i8 %x, -2\n br i1 %cond, label %if.then, label %if.else\n\nif.then: ; preds = %entry\n %umax = call i8 @llvm.umax.i8(i8 %x, i8 -46)\n %cmp = icmp samesign ult i8 %umax, -32\n ret i1 %cmp\n\nif.else: ; preds = %entry\n ret i1 false\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i8 @llvm.umax.i8(i8, i8) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}]}], "issue": {"title": "[RISC-V] Miscompile using rv64gcv", "body": "Testcase:\n```c\nint a[][21][21];\nvoid b(int c, int d, int e, short f, _Bool g, char h, char i, int j, int k,\n int l, unsigned char m, int n, char o, int p, long long q[],\n unsigned short r[][10], unsigned s[][10],\n unsigned long long t[][10][10][10], unsigned long long u[][10][10][10],\n int w[][10][10][10][10], _Bool x) {\n for (signed z = 0; z < (char)m + 3; z = 4)\n for (short aa = ({\n __typeof__(0) ab = 173;\n __typeof__(0) ac = ({\n __typeof__(0) ab = m;\n ab;\n });\n ab > ac ? ab : ac;\n }) -\n 171;\n aa < 9; aa = k)\n a[z][aa][aa] = ~0;\n}\ntypedef int ad;\nint printf(const char *, ...);\nlong long ae;\nvoid af(long long *ae, int v) { *ae ^= v; }\nint c;\nint d;\nint e;\nshort f;\n_Bool g;\nchar h;\nchar i;\nint j;\nint k = 2805750831;\nint l;\nchar m;\nint n;\nchar o;\nint p;\nlong long q[0];\nunsigned short r[0][10];\nunsigned s[0][10];\nunsigned long long t[0][10][10][10];\nunsigned long long u[0][10][10][10];\nint w[0][10][10][10][10];\n_Bool x;\nint a[21][21][21];\nvoid ag() {\n for (ad y = 0; y < 10; ++y)\n for (ad ah = 0; ah < 10; ++ah)\n for (ad ai = 0; ai < 10; ++ai)\n af(&ae, a[y][ah][ai]);\n}\nint main() {\n b(c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, w, x);\n ag();\n printf(\"%llu\\n\", ae);\n}\n```\n\nCommands:\n```\n# riscv \n$ QEMU_CPU=rv64,vlen=128,rvv_ta_all_1s=true,rvv_ma_all_1s=true,v=true,vext_spec=v1.0,zve32f=true,zve64f=true timeout --verbose -k 0.1 4 /scratch/ewlu/daily-upstream-build/build-gcv/bin/qemu-riscv64 user-config.out 1\n0\n\n# x86\n$ ./native.out 1\n18446744073709551615\n```\n\nGodbolt: https://godbolt.org/z/85rz18rxY\n\nBisected to cfee344dda7394631f2177a15e56cfeee1d61fc4 as the first bad commit\n\nI tried reducing the testcase down farther but was unsuccessful\n\nFound via fuzzer. First detected 01/24/2025", "author": "ewlu", "labels": ["miscompilation", "llvm:instcombine"], "comments": [{"author": "dzaima", "body": "Some manual simplification, reproduces on x86-64 `-O3` too:\n\n```c\n#include<stdio.h>\n\nvoid f(int more_than_20, unsigned char zero) {\n int i = 0;\n while (i < (signed char)zero + 2) {\n int max = zero < 210 ? 210 : zero; // 210; has to be >127\n int j = max - 200; // 10\n while (j < 20) {\n printf(\"I should be printed once\\n\");\n j = more_than_20;\n }\n i = 2; // can be anything >2\n }\n}\n\nint main() {\n f(50, 0);\n}\n```\n\nhttps://godbolt.org/z/qfn9PT6r5"}, {"author": "dtcxzyw", "body": "Reproducer: https://alive2.llvm.org/ce/z/adparc"}, {"author": "dtcxzyw", "body": "Further reduced: https://alive2.llvm.org/ce/z/5da83j"}]}, "verified": true}
dataset/131818.json ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "131818",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/131818",
4
+ "bug_type": "crash",
5
+ "base_commit": "84909d797782a0dcf240f79a8e5e863d8165c03f",
6
+ "knowledge_cutoff": "2025-03-18T15:06:59Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/SLPVectorizer"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "45090b3059562b32723cd25679db75d1574ab04e",
12
+ "components": [
13
+ "SLPVectorizer"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
17
+ [
18
+ 14086,
19
+ 14096
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
25
+ "BoUpSLP::isGatherShuffledSingleRegisterEntry"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit 45090b3059562b32723cd25679db75d1574ab04e\nAuthor: Alexey Bataev <[email protected]>\nDate: Tue Mar 18 09:32:23 2025 -0700\n\n [SLP]Check the whole def-use chain in the tree to find proper dominance, if the last instruction is the same\n \n If the insertion point (last instruction) of the user nodes is the same,\n need to check the whole def-use chain in the tree to find proper\n dominance to prevent a compiler crash.\n \n Fixes #131818\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex 24171f1d9a06..4a835bc797ab 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -14086,11 +14086,18 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(\n auto CheckParentNodes = [&](const TreeEntry *User1, const TreeEntry *User2,\n unsigned EdgeIdx) {\n const TreeEntry *Ptr1 = User1;\n+ const TreeEntry *Ptr2 = User2;\n+ SmallDenseMap<const TreeEntry *, unsigned> PtrToIdx;\n+ while (Ptr2) {\n+ PtrToIdx.try_emplace(Ptr2, EdgeIdx);\n+ EdgeIdx = Ptr2->UserTreeIndex.EdgeIdx;\n+ Ptr2 = Ptr2->UserTreeIndex.UserTE;\n+ }\n while (Ptr1) {\n unsigned Idx = Ptr1->UserTreeIndex.EdgeIdx;\n Ptr1 = Ptr1->UserTreeIndex.UserTE;\n- if (Ptr1 == User2)\n- return Idx < EdgeIdx;\n+ if (auto It = PtrToIdx.find(Ptr1); It != PtrToIdx.end())\n+ return Idx < It->second;\n }\n return false;\n };\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/SLPVectorizer/X86/same-last-instruction-different-parents.ll",
33
+ "commands": [
34
+ "opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "<module>",
39
+ "test_body": "\ndefine i32 @test(i32 %0, i1 %1) {\n;\n %3 = sitofp i32 %0 to double\n %4 = sitofp i32 %0 to double\n %5 = sitofp i32 %0 to double\n br i1 %1, label %6, label %9\n\n6:\n %7 = tail call double @llvm.fmuladd.f64(double %4, double 0.000000e+00, double 0.000000e+00)\n %8 = tail call double @llvm.fmuladd.f64(double %5, double 0.000000e+00, double 0.000000e+00)\n br label %18\n\n9:\n br i1 false, label %15, label %10\n\n10:\n %11 = call double @llvm.copysign.f64(double 0.000000e+00, double %3)\n %12 = tail call double @llvm.fmuladd.f64(double %11, double %4, double 0.000000e+00)\n %13 = call double @llvm.copysign.f64(double 0.000000e+00, double %5)\n %14 = tail call double @llvm.fmuladd.f64(double %13, double 0.000000e+00, double 0.000000e+00)\n br label %15\n\n15:\n %16 = phi double [ %12, %10 ], [ 0.000000e+00, %9 ]\n %17 = phi double [ %14, %10 ], [ 0.000000e+00, %9 ]\n br label %18\n\n18:\n %19 = phi double [ %17, %15 ], [ %8, %6 ]\n %20 = phi double [ %16, %15 ], [ %7, %6 ]\n %21 = fmul double %20, %19\n %22 = fptosi double %21 to i32\n ret i32 %22\n}"
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "issue": {
45
+ "title": "[clang] Crash at -O3: Instruction does not dominate all uses!",
46
+ "body": "This code crashes at `-O3`:\n\n```c\nint a;\ndouble b;\nlong c;\nint d(long f, long g) {\n if (f + g)\n return 1;\n for (long e = 0; e < g; e++)\n *(char *)e = 5;\n return 0;\n}\nint h(int f) {\n double i = 0.270112271089232341485679099e4;\n b = 0.1e1;\n for (; c; c--) {\n i = i * (80 + f) * (9 + f) + a;\n a = 0;\n b = b * f * (d(-42, f) + f) + 0.11623987080032122878585294e22;\n }\n return i / b;\n}\nvoid main() {}\n```\n\nCompiler Explorer: https://godbolt.org/z/b4YEsPMrq\n\nBisected to https://github.com/llvm/llvm-project/commit/d57884011e8c57b118b831614b692ba4bc8b5aca, which was committed by @alexey-bataev \n\nCrash:\n\n```console\nInstruction does not dominate all uses!\n %3 = insertelement <2 x i32> %2, i32 %f, i64 1\n %0 = insertelement <2 x i32> %3, i32 %add1, i64 0\nin function h\nfatal error: error in backend: Broken function found, compilation aborted!\n```\n\nBacktrace:\n\n```console\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 -O3 -Wall -Wextra <source>\n1.\t<eof> parser at end of file\n2.\tCode generation\n3.\tRunning pass 'Function Pass Manager' on module '<source>'.\n4.\tRunning pass 'Module Verifier' on function '@h'\n #0 0x0000000003e87c38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e87c38)\n #1 0x0000000003e858c4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e858c4)\n #2 0x0000000003dcacb6 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dcacb6)\n #3 0x0000000003e7cfee llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e7cfee)\n #4 0x0000000000d4e5a0 LLVMErrorHandler(void*, char const*, bool) cc1_main.cpp:0:0\n #5 0x0000000003dd5443 llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dd5443)\n #6 0x0000000003dd55a8 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dd55a8)\n #7 0x0000000003887952 (anonymous namespace)::VerifierLegacyPass::runOnFunction(llvm::Function&) Verifier.cpp:0:0\n #8 0x00000000037d28df llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x37d28df)\n #9 0x00000000037d2c91 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x37d2c91)\n#10 0x00000000037d3531 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x37d3531)\n#11 0x000000000413d67e 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+0x413d67e)\n#12 0x00000000048429a0 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x48429a0)\n#13 0x00000000064aecac clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x64aecac)\n#14 0x0000000004842da8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4842da8)\n#15 0x0000000004b127f5 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4b127f5)\n#16 0x0000000004a94a2e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4a94a2e)\n#17 0x0000000004c024fe clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4c024fe)\n#18 0x0000000000d50baf cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd50baf)\n#19 0x0000000000d4836a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#20 0x000000000488b309 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#21 0x0000000003dcabf4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dcabf4)\n#22 0x000000000488b91f 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#23 0x000000000484e38d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x484e38d)\n#24 0x000000000484f41e 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+0x484f41e)\n#25 0x0000000004856af5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4856af5)\n#26 0x0000000000d4d9a8 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd4d9a8)\n#27 0x0000000000c146c4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc146c4)\n#28 0x00007acc03029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#29 0x00007acc03029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#30 0x0000000000d47e15 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd47e15)\n```",
47
+ "author": "cardigan1008",
48
+ "labels": [
49
+ "llvm:SLPVectorizer",
50
+ "crash-on-valid"
51
+ ],
52
+ "comments": []
53
+ },
54
+ "verified": true
55
+ }
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 = 131718
38
 
39
 
40
  def wait(progress):
 
34
  )
35
 
36
  issue_id_begin = 76663 # Since 2024-01-01
37
+ issue_id_end = 132850
38
 
39
 
40
  def wait(progress):
scripts/unpack.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ # Copyright 2025 Yingwei Zheng
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ import sys
17
+ import json
18
+ import os
19
+
20
+ dataset_dir = sys.argv[1]
21
+ input_file = sys.argv[2]
22
+
23
+ os.makedirs(dataset_dir, exist_ok=True)
24
+
25
+ with open(input_file) as f:
26
+ data = json.load(f)
27
+ for item in data["fixes"]:
28
+ issue_id = item['bug_id']
29
+ with open(os.path.join(dataset_dir, f"{issue_id}.json"), "w") as out:
30
+ json.dump(item, out, indent=2)