diff --git "a/dataset.jsonl" "b/dataset.jsonl" --- "a/dataset.jsonl" +++ "b/dataset.jsonl" @@ -37,6 +37,7 @@ {"bug_id": "117537", "issue_url": "https://github.com/llvm/llvm-project/issues/117537", "bug_type": "crash", "base_commit": "c979ec05642f292737d250c6682d85ed49bc7b6e", "knowledge_cutoff": "2024-11-25T10:47:02Z", "lit_test_dir": ["llvm/test/Transforms/SimpleLoopUnswitch"], "hints": {"fix_commit": "fc5c89900f2a4b50e0f3a88ef7c89115d93684f4", "components": ["SimpleLoopUnswitch"], "bug_location_lineno": {"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": [[1248, 1255]]}, "bug_location_funcname": {"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": ["buildClonedLoopBlocks"]}}, "patch": "commit fc5c89900f2a4b50e0f3a88ef7c89115d93684f4\nAuthor: Nikita Popov \nDate: Wed Nov 27 11:47:22 2024 +0100\n\n [SimpleLoopUnswitch] Fix LCSSA phi node invalidation\n \n Fixes https://github.com/llvm/llvm-project/issues/117537.\n\ndiff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp\nindex aa3cbc5e4bdd..d8ef450eeb9a 100644\n--- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp\n+++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp\n@@ -1248,8 +1248,9 @@ static BasicBlock *buildClonedLoopBlocks(\n assert(VMap.lookup(&I) == &ClonedI && \"Mismatch in the value map!\");\n \n // Forget SCEVs based on exit phis in case SCEV looked through the phi.\n- if (SE && isa(I))\n- SE->forgetValue(&I);\n+ if (SE)\n+ if (auto *PN = dyn_cast(&I))\n+ SE->forgetLcssaPhiWithNewPredecessor(&L, PN);\n \n BasicBlock::iterator InsertPt = MergeBB->getFirstInsertionPt();\n \n", "tests": [{"file": "llvm/test/Transforms/SimpleLoopUnswitch/pr117537.ll", "commands": ["opt -S -passes='print,simple-loop-unswitch,print' -verify-scev < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "define void @test(ptr %p) {\nentry:\n %check = icmp eq ptr %p, null\n br label %bb0\n\nbb0: ; preds = %loop0, %entry\n br i1 %check, label %loop0, label %latch\n\nlatch: ; preds = %bb0\n br i1 %check, label %exit0, label %loop0\n\nexit0: ; preds = %latch\n ret void\n\nloop0: ; preds = %latch, %bb0\n %v = load atomic i32, ptr %p unordered, align 8\n %add = add i32 %v, 3\n br i1 true, label %preheader, label %bb0\n\npreheader: ; preds = %loop0\n br label %loop1\n\nloop1: ; preds = %backedge, %preheader\n %iv1 = phi i32 [ %add, %preheader ], [ %iv1.next, %backedge ]\n %iv1.next = add i32 %iv1, -33\n br label %loop2\n\nbackedge: ; preds = %loop2\n br i1 true, label %exit1, label %loop1\n\nloop2: ; preds = %loop2, %loop1\n %iv0 = phi i32 [ %iv1, %loop1 ], [ %iv0.next, %loop2 ]\n %iv0.next = add nsw i32 %iv0, 1\n %cmp = icmp sgt i32 %iv0.next, 0\n br i1 %cmp, label %backedge, label %loop2\n\nexit1: ; preds = %backedge\n ret void\n}\n"}]}], "issue": {"title": "[SCEV] Assertion `isAvailableAtLoopEntry(Op, L) && \"SCEVAddRecExpr operand is not available at loop entry!\"' failed.", "body": "Faulty IR:\n```\n; ModuleID = 'test.ll'\nsource_filename = \"/nfs/build-cache/zvm-dev-4598/jdk11/x86_64/fastdebug/lib/server/boilerplate.ll\"\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @test(ptr addrspace(1) %p) {\nentry:\n %check = icmp eq ptr addrspace(1) %p, null\n br label %bb0\n\nbb0: ; preds = %loop0, %entry\n br i1 %check, label %loop0, label %latch\n\nlatch: ; preds = %bb0\n br i1 %check, label %exit0, label %loop0\n\nexit0: ; preds = %latch\n ret void\n\nloop0: ; preds = %latch, %bb0\n %0 = load atomic i32, ptr addrspace(1) %p unordered, align 8\n %add = add i32 %0, 3\n br i1 true, label %preheader, label %bb0\n\npreheader: ; preds = %loop0\n br label %loop1\n\nloop1: ; preds = %backedge, %preheader\n %iv1 = phi i32 [ %add, %preheader ], [ %1, %backedge ]\n %1 = add i32 %iv1, -33\n br label %loop2\n\nbackedge: ; preds = %loop2\n br i1 true, label %exit1, label %loop1\n\nloop2: ; preds = %loop2, %loop1\n %iv0 = phi i32 [ %iv1, %loop1 ], [ %2, %loop2 ]\n %2 = add nsw i32 %iv0, 1\n %3 = icmp sgt i32 %2, 0\n br i1 %3, label %backedge, label %loop2\n\nexit1: ; preds = %backedge\n ret void\n}\n```\nfails when run with `opt -passes='print,simple-loop-unswitch,print' `\nDemo of failure: https://godbolt.org/z/qhboK5r3j\n", "author": "Nirhar", "labels": ["crash", "llvm:transforms"], "comments": [{"author": "Nirhar", "body": "Here is the IR after simple-loop-unswitch pass:\n![res](https://github.com/user-attachments/assets/8a35df98-54f4-45f6-9e96-626fd6814e7f)\n\n\nAt the point of crash, the SCEV for Exit Value of `%iv0`(which I assume, as we crashed while printing it) is `(-4 + (-1 * %1) + %.us-phi)`, which is incorrect. The crash happens because `%1` is in a block that does not properly dominate `%iv0`. Looks like, simple-loop-unswitch is either incorrectly updating the SCEV in the pass, or is incorrectly reporting SCEV to be preserved. As of now, I'm not sure which is the case. "}, {"author": "Nirhar", "body": "@nikic @dtcxzyw @EugeneZelenko any thoughts? I'm inclined to having a patch that removes SCEV from simple-loop-unswitch 's list of preserved analyses."}, {"author": "dtcxzyw", "body": "> I'm inclined to having a patch that removes SCEV from simple-loop-unswitch 's list of preserved analyses.\n\nSome SCEVs should be invalidated in `unswitchNontrivialInvariants`. Removing SCEV from the list of preserved analyses doesn't fix the issue.\n"}]}, "verified": true} {"bug_id": "110193", "issue_url": "https://github.com/llvm/llvm-project/issues/110193", "bug_type": "crash", "base_commit": "7dfdca1961aadc75ca397818bfb9bd32f1879248", "knowledge_cutoff": "2024-09-27T00:54:58Z", "lit_test_dir": ["llvm/test/Transforms/SLPVectorizer"], "hints": {"fix_commit": "af6354634d2cec14570108ee038ca4b18cf6856a", "components": ["SLPVectorizer"], "bug_location_lineno": {"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [[10340, 10352]]}, "bug_location_funcname": {"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": ["BoUpSLP::getEntryCost"]}}, "patch": "commit af6354634d2cec14570108ee038ca4b18cf6856a\nAuthor: Alexey Bataev \nDate: Fri Sep 27 03:55:17 2024 -0700\n\n [SLP]Look for vector user when estimating the cost\n \n Need to find the first vector node user, not the very first user node at\n all. The very first user might be a gather, vectorized as clustered,\n which may cause compiler crash.\n \n Fixes https://github.com/llvm/llvm-project/issues/110193\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex 48a8627ab63e..dee0b7e1f437 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -10340,13 +10340,16 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef VectorizedVals,\n InstructionCost VecCost = VectorCost(CommonCost);\n // Check if the current node must be resized, if the parent node is not\n // resized.\n- if (!UnaryInstruction::isCast(E->getOpcode()) && E->Idx != 0 &&\n+ if (It != MinBWs.end() && !UnaryInstruction::isCast(E->getOpcode()) &&\n+ E->Idx != 0 &&\n (E->getOpcode() != Instruction::Load ||\n !E->UserTreeIndices.empty())) {\n- const EdgeInfo &EI = E->UserTreeIndices.front();\n- if ((EI.UserTE->getOpcode() != Instruction::Select ||\n- EI.EdgeIdx != 0) &&\n- It != MinBWs.end()) {\n+ const EdgeInfo &EI =\n+ *find_if(E->UserTreeIndices, [](const EdgeInfo &EI) {\n+ return !EI.UserTE->isGather() || EI.EdgeIdx != UINT_MAX;\n+ });\n+ if (EI.UserTE->getOpcode() != Instruction::Select ||\n+ EI.EdgeIdx != 0) {\n auto UserBWIt = MinBWs.find(EI.UserTE);\n Type *UserScalarTy =\n EI.UserTE->getOperand(EI.EdgeIdx).front()->getType();\n", "tests": [{"file": "llvm/test/Transforms/SLPVectorizer/X86/minbw-multiused-from-gather.ll", "commands": ["opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"], "tests": [{"test_name": "test", "test_body": "define i1 @test() {\nentry:\n %c18.i308.i.i = shl i32 0, 0\n %c19.i315.i.i = shl i32 0, 0\n %and.19.i316.i.i = and i32 %c18.i308.i.i, %c19.i315.i.i\n %c20.i322.i.i = shl i32 0, 0\n %and.20.i323.i.i = and i32 %and.19.i316.i.i, %c20.i322.i.i\n %c21.i329.i.i = shl i32 0, 0\n %and.21.i330.i.i = and i32 %and.20.i323.i.i, %c21.i329.i.i\n %0 = trunc i64 0 to i32\n %conv85.22.i333.i.i = or i32 0, %0\n %cmp3.i.22.i334.i.i = icmp ugt i32 %conv85.22.i333.i.i, 0\n %shl.i111.22.i335.i.i = select i1 %cmp3.i.22.i334.i.i, i32 0, i32 0\n %c22.i336.i.i = shl i32 %conv85.22.i333.i.i, %shl.i111.22.i335.i.i\n %and.22.i337.i.i = and i32 %and.21.i330.i.i, %c22.i336.i.i\n %1 = trunc i64 0 to i32\n %conv85.23.i340.i.i = or i32 0, %1\n %cmp3.i.23.i341.i.i = icmp ugt i32 %conv85.23.i340.i.i, 0\n %shl.i111.23.i342.i.i = select i1 %cmp3.i.23.i341.i.i, i32 0, i32 0\n %c23.i343.i.i = shl i32 %conv85.23.i340.i.i, %shl.i111.23.i342.i.i\n %and.23.i344.i.i = and i32 %and.22.i337.i.i, %c23.i343.i.i\n %2 = trunc i64 0 to i32\n %conv85.24.i347.i.i = or i32 0, %2\n %cmp3.i.24.i348.i.i = icmp ugt i32 %conv85.24.i347.i.i, 0\n %shl.i111.24.i349.i.i = select i1 %cmp3.i.24.i348.i.i, i32 0, i32 0\n %c24.i350.i.i = shl i32 %conv85.24.i347.i.i, %shl.i111.24.i349.i.i\n %and.24.i351.i.i = and i32 %and.23.i344.i.i, %c24.i350.i.i\n %3 = trunc i64 0 to i32\n %conv85.25.i354.i.i = or i32 0, %3\n %cmp3.i.25.i355.i.i = icmp ugt i32 %conv85.25.i354.i.i, 0\n %shl.i111.25.i356.i.i = select i1 %cmp3.i.25.i355.i.i, i32 0, i32 0\n %c25.i357.i.i = shl i32 %conv85.25.i354.i.i, %shl.i111.25.i356.i.i\n %and.25.i358.i.i = and i32 %and.24.i351.i.i, %c25.i357.i.i\n %conv109.i.i = trunc i32 %and.25.i358.i.i to i8\n %cmp.i.i54.i = icmp eq i8 %conv109.i.i, 0\n ret i1 %cmp.i.i54.i\n}\n"}]}], "issue": {"title": "[SLPVectorizer] Assertion `OpIdx < Operands.size() && \"Off bounds\"' failed.", "body": "Reproducer: https://godbolt.org/z/6GbP5f7qa\r\n```\r\n; bin/opt -passes=slp-vectorizer reduced.ll -S\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\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine i1 @main() {\r\nentry:\r\n %cond.i112.18.i308.i.i = shl i32 0, 0\r\n %cond.i112.19.i315.i.i = shl i32 0, 0\r\n %and.19.i316.i.i = and i32 %cond.i112.18.i308.i.i, %cond.i112.19.i315.i.i\r\n %cond.i112.20.i322.i.i = shl i32 0, 0\r\n %and.20.i323.i.i = and i32 %and.19.i316.i.i, %cond.i112.20.i322.i.i\r\n %cond.i112.21.i329.i.i = shl i32 0, 0\r\n %and.21.i330.i.i = and i32 %and.20.i323.i.i, %cond.i112.21.i329.i.i\r\n %0 = trunc i64 0 to i32\r\n %conv85.22.i333.i.i = or i32 0, %0\r\n %cmp3.i.22.i334.i.i = icmp ugt i32 %conv85.22.i333.i.i, 0\r\n %shl.i111.22.i335.i.i = select i1 %cmp3.i.22.i334.i.i, i32 0, i32 0\r\n %cond.i112.22.i336.i.i = shl i32 %conv85.22.i333.i.i, %shl.i111.22.i335.i.i\r\n %and.22.i337.i.i = and i32 %and.21.i330.i.i, %cond.i112.22.i336.i.i\r\n %1 = trunc i64 0 to i32\r\n %conv85.23.i340.i.i = or i32 0, %1\r\n %cmp3.i.23.i341.i.i = icmp ugt i32 %conv85.23.i340.i.i, 0\r\n %shl.i111.23.i342.i.i = select i1 %cmp3.i.23.i341.i.i, i32 0, i32 0\r\n %cond.i112.23.i343.i.i = shl i32 %conv85.23.i340.i.i, %shl.i111.23.i342.i.i\r\n %and.23.i344.i.i = and i32 %and.22.i337.i.i, %cond.i112.23.i343.i.i\r\n %2 = trunc i64 0 to i32\r\n %conv85.24.i347.i.i = or i32 0, %2\r\n %cmp3.i.24.i348.i.i = icmp ugt i32 %conv85.24.i347.i.i, 0\r\n %shl.i111.24.i349.i.i = select i1 %cmp3.i.24.i348.i.i, i32 0, i32 0\r\n %cond.i112.24.i350.i.i = shl i32 %conv85.24.i347.i.i, %shl.i111.24.i349.i.i\r\n %and.24.i351.i.i = and i32 %and.23.i344.i.i, %cond.i112.24.i350.i.i\r\n %3 = trunc i64 0 to i32\r\n %conv85.25.i354.i.i = or i32 0, %3\r\n %cmp3.i.25.i355.i.i = icmp ugt i32 %conv85.25.i354.i.i, 0\r\n %shl.i111.25.i356.i.i = select i1 %cmp3.i.25.i355.i.i, i32 0, i32 0\r\n %cond.i112.25.i357.i.i = shl i32 %conv85.25.i354.i.i, %shl.i111.25.i356.i.i\r\n %and.25.i358.i.i = and i32 %and.24.i351.i.i, %cond.i112.25.i357.i.i\r\n %conv109.i.i = trunc i32 %and.25.i358.i.i to i8\r\n %cmp.i.i54.i = icmp eq i8 %conv109.i.i, 0\r\n ret i1 %cmp.i.i54.i\r\n}\r\n```\r\n```\r\nopt: /home/dtcxzyw/WorkSpace/Projects/compilers/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:3247: llvm::slpvectorizer::BoUpSLP::ValueList& llvm::slpvectorizer::BoUpSLP::TreeEntry::getOperand(unsigned int): Assertion `OpIdx < Operands.size() && \"Off bounds\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: bin/opt -passes=slp-vectorizer reduced.ll\r\n1. Running pass \"function(slp-vectorizer)\" on module \"reduced.ll\"\r\n2. Running pass \"slp-vectorizer\" on function \"main\"\r\n #0 0x000075e591a13b52 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.20.0git+0x213b52)\r\n #1 0x000075e591a10a1f llvm::sys::RunSignalHandlers() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.20.0git+0x210a1f)\r\n #2 0x000075e591a10b65 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x000075e591442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x000075e5914969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x000075e5914969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x000075e5914969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x000075e591442476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x000075e5914287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x000075e59142871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x000075e591439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x000075e58c574c14 (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x174c14)\r\n#12 0x000075e58c5bcafe llvm::slpvectorizer::BoUpSLP::getEntryCost(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef, llvm::SmallPtrSetImpl&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1bcafe)\r\n#13 0x000075e58c5d0eed llvm::slpvectorizer::BoUpSLP::getTreeCost(llvm::ArrayRef) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1d0eed)\r\n#14 0x000075e58c5d68cc (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&) SLPVectorizer.cpp:0:0\r\n#15 0x000075e58c5d997a llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*, llvm::SmallVectorImpl&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1d997a)\r\n#16 0x000075e58c5ddf28 llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1ddf28)\r\n#17 0x000075e58c5de0cb bool llvm::SLPVectorizerPass::vectorizeCmpInsts>(llvm::iterator_range>, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1de0cb)\r\n#18 0x000075e58c5e2299 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1e2299)\r\n#19 0x000075e58c5e8c0f llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1e8c0f)\r\n#20 0x000075e58c5e9876 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1e9876)\r\n#21 0x000075e58ced5195 llvm::detail::PassModel>::run(llvm::Function&, llvm::AnalysisManager&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMPasses.so.20.0git+0xd5195)\r\n#22 0x000075e58a15de5d llvm::PassManager>::run(llvm::Function&, llvm::AnalysisManager&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.20.0git+0x35de5d)\r\n#23 0x000075e5904d9d05 llvm::detail::PassModel>, llvm::AnalysisManager>::run(llvm::Function&, llvm::AnalysisManager&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.20.0git+0xd9d05)\r\n#24 0x000075e58a15bf96 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.20.0git+0x35bf96)\r\n#25 0x000075e5904da6c5 llvm::detail::PassModel>::run(llvm::Module&, llvm::AnalysisManager&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.20.0git+0xda6c5)\r\n#26 0x000075e58a15cb1a llvm::PassManager>::run(llvm::Module&, llvm::AnalysisManager&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.20.0git+0x35cb1a)\r\n#27 0x000075e591c041c1 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef, llvm::ArrayRef>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.20.0git+0x2d1c1)\r\n#28 0x000075e591c0f944 optMain (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.20.0git+0x38944)\r\n#29 0x000075e591429d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#30 0x000075e591429e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#31 0x000075e591429e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#32 0x00005b421cc0e095 _start (bin/opt+0x1095)\r\nAborted (core dumped)\r\n```\r\n\r\nllvm version: 2b84ef06ac55ac8de3c210d059ec3a3c96666a90", "author": "dtcxzyw", "labels": ["llvm:SLPVectorizer", "crash-on-valid"], "comments": []}, "verified": true} {"bug_id": "127128", "issue_url": "https://github.com/llvm/llvm-project/issues/127128", "bug_type": "crash", "base_commit": "1ff5f328d9824694cc356ebf78adad8816a6de86", "knowledge_cutoff": "2025-02-13T20:59:01Z", "lit_test_dir": ["llvm/test/Transforms/SLPVectorizer"], "hints": {"fix_commit": "ac217ee389d63124432e5e6890851a678f7a676b", "components": ["SLPVectorizer"], "bug_location_lineno": {"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [[13206, 13213]]}, "bug_location_funcname": {"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": ["BoUpSLP::isGatherShuffledSingleRegisterEntry"]}}, "patch": "commit ac217ee389d63124432e5e6890851a678f7a676b\nAuthor: Alexey Bataev \nDate: Thu Feb 13 14:19:51 2025 -0800\n\n [SLP] Check for PHI nodes (potentially cycles!) when checking dependencies\n \n When checking for dependecies for gather nodes with users with the same\n last instruction, cannot rely on the index order, if there is (even\n potential!) cycle in the graph, which may cause order not work correctly\n and cause compiler crash.\n \n Fixes #127128\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex fb72a112b9ac..780cafe91d6b 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -13206,8 +13206,16 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(\n continue;\n // If the user instruction is used for some reason in different\n // vectorized nodes - make it depend on index.\n+ // If any vector node is PHI node, this dependency might not work\n+ // because of cycle dependencies, so disable it.\n if (TEUseEI.UserTE != UseEI.UserTE &&\n- TEUseEI.UserTE->Idx < UseEI.UserTE->Idx)\n+ (TEUseEI.UserTE->Idx < UseEI.UserTE->Idx ||\n+ any_of(\n+ VectorizableTree,\n+ [](const std::unique_ptr &TE) {\n+ return TE->State == TreeEntry::Vectorize &&\n+ TE->getOpcode() == Instruction::PHI;\n+ })))\n continue;\n }\n \n", "tests": [{"file": "llvm/test/Transforms/SLPVectorizer/X86/delayed-gather-emission.ll", "commands": ["opt -passes=slp-vectorizer -mtriple=x86_64 -mattr=+avx2 -S < %s"], "tests": [{"test_name": "test", "test_body": "define void @test() {\nentry:\n %.pre.pre = load float, ptr poison, align 4\n br label %bb1\n\nbb1: ; preds = %bb2, %entry\n %.pre = phi float [ %.pre.pre, %entry ], [ %i2, %bb2 ]\n %foxtrot.0 = phi float [ undef, %entry ], [ %gulf.0, %bb2 ]\n br label %bb2\n\nbb2: ; preds = %bb2, %bb1\n %i = phi float [ %.pre, %bb1 ], [ %i2, %bb2 ]\n %gulf.0 = phi float [ %foxtrot.0, %bb1 ], [ %div, %bb2 ]\n %div = fdiv float %i, %gulf.0\n %i1 = load float, ptr poison, align 4\n %div1 = fdiv float %gulf.0, %i1\n %mul = fmul float %div, %div1\n tail call void @foo(float %mul)\n %i2 = load float, ptr poison, align 4\n %tobool = fcmp une float %i2, 0.000000e+00\n br i1 %tobool, label %bb1, label %bb2\n}\n\ndeclare void @foo(float)\n"}]}, {"file": "llvm/test/Transforms/SLPVectorizer/X86/phi-node-with-cycle.ll", "commands": ["opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -mcpu=haswell < %s"], "tests": [{"test_name": "", "test_body": "\ndefine void @test(float %0) {\n;\n %2 = fdiv float 0.000000e+00, 0.000000e+00\n %3 = fdiv float 0.000000e+00, 0.000000e+00\n %4 = fdiv float %0, 0.000000e+00\n br label %5\n\n5:\n %6 = fmul float %4, 0.000000e+00\n %7 = fsub float 0.000000e+00, %6\n %8 = fmul float %3, 0.000000e+00\n %9 = fsub float 0.000000e+00, %8\n br label %11\n\n10:\n br label %11\n\n11:\n %12 = phi float [ %7, %5 ], [ 0.000000e+00, %10 ]\n %13 = phi float [ %9, %5 ], [ 0.000000e+00, %10 ]\n br label %14\n\n14:\n %15 = fmul float %2, 0.000000e+00\n %16 = fsub float %12, %15\n %17 = fmul float %4, 0.000000e+00\n %18 = fsub float %13, %17\n %19 = fadd float %16, %18\n %20 = call float @llvm.fabs.f32(float %19)\n ret void\n}\n"}]}], "issue": {"title": "SLPVectorizer miscompilation", "body": "```llvm\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:10:11:12:13\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine swiftcc { ptr addrspace(10), i8 } @julia__dir2ori_404(float %0) {\n %2 = fdiv float 0.000000e+00, 0.000000e+00\n %3 = fdiv float 0.000000e+00, 0.000000e+00\n %4 = fdiv float %0, 0.000000e+00\n br label %5\n\n5: ; preds = %1\n %6 = fmul float %4, 0.000000e+00\n %7 = fsub float 0.000000e+00, %6\n %8 = fmul float %3, 0.000000e+00\n %9 = fsub float 0.000000e+00, %8\n br label %11\n\n10: ; No predecessors!\n br label %11\n\n11: ; preds = %10, %5\n %12 = phi float [ %7, %5 ], [ 0.000000e+00, %10 ]\n %13 = phi float [ %9, %5 ], [ 0.000000e+00, %10 ]\n br label %14\n\n14: ; preds = %11\n %15 = fmul float %2, 0.000000e+00\n %16 = fsub float %12, %15\n %17 = fmul float %4, 0.000000e+00\n %18 = fsub float %13, %17\n %19 = fadd float %16, %18\n %20 = call float @llvm.fabs.f32(float %19)\n ret { ptr addrspace(10), i8 } zeroinitializer\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.fabs.f32(float) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n```\nproduces \n```\nInstruction does not dominate all uses!\n %4 = insertelement <2 x float> , float %0, i32 0\n %2 = shufflevector <2 x float> %4, <2 x float> , <2 x i32> \nLLVM ERROR: Broken module found, compilation aborted!\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer -mcpu=haswell \n1.\tRunning pass \"verify\" on module \"\"\n #0 0x00000000054edec8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x54edec8)\n #1 0x00000000054eb884 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007faaea842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007faaea8969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x00007faaea842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007faaea8287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x000000000082790d llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0\n #7 0x000000000542b6e8 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x542b6e8)\n #8 0x0000000005329278 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5329278)\n #9 0x000000000095605e llvm::detail::PassModel>::run(llvm::Module&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x95605e)\n#10 0x00000000052e7b50 llvm::PassManager>::run(llvm::Module&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x52e7b50)\n#11 0x000000000096174a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef, llvm::ArrayRef>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x96174a)\n#12 0x0000000000953c7c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x953c7c)\n#13 0x00007faaea829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#14 0x00007faaea829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#15 0x000000000094b555 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x94b555)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```\non 19 and trunk.\nGodbolt: https://godbolt.org/z/qxKP6198T", "author": "Zentrik", "labels": ["llvm:SLPVectorizer", "crash-on-valid"], "comments": [{"author": "Zentrik", "body": "Bisected thanks to manyclangs to 66775f8ccdcc8264ef349518e1c59d96d4227823 (8e2b2c4181506efc5b9321c203dd107bbd63392b seemed to be good) @alexey-bataev"}]}, "verified": true} +{"bug_id": "129242", "issue_url": "https://github.com/llvm/llvm-project/issues/129242", "bug_type": "crash", "base_commit": "5faa5f848a35de13196f2f516f51aa970da942b4", "knowledge_cutoff": "2025-02-28T13:35:26Z", "lit_test_dir": ["llvm/test/Transforms/SLPVectorizer"], "hints": {"fix_commit": "a36a67c79afaa1fdd0dbe0440ec852fd4eb3a532", "components": ["SLPVectorizer"], "bug_location_lineno": {"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [[11425, 11435]]}, "bug_location_funcname": {"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": ["BoUpSLP::getEntryCost"]}}, "patch": "commit a36a67c79afaa1fdd0dbe0440ec852fd4eb3a532\nAuthor: Alexey Bataev \nDate: Fri Feb 28 13:15:46 2025 -0800\n\n [SLP]Fix the analysis of the user buildvector nodes for minbitwidth\n \n If the user node is a buildvector/gather node and it has no internal\n instructions state, need to check properly for this state and check the\n type of the node itself, not its operands.\n \n Fixes #129242\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex 4a68e0ee5989..4f3fd6d53909 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -11425,11 +11425,14 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef VectorizedVals,\n E->Idx != 0 &&\n (E->getOpcode() != Instruction::Load || E->UserTreeIndex)) {\n const EdgeInfo &EI = E->UserTreeIndex;\n- if (EI.UserTE->getOpcode() != Instruction::Select ||\n+ if (!EI.UserTE->hasState() ||\n+ EI.UserTE->getOpcode() != Instruction::Select ||\n EI.EdgeIdx != 0) {\n auto UserBWIt = MinBWs.find(EI.UserTE);\n Type *UserScalarTy =\n- EI.UserTE->getOperand(EI.EdgeIdx).front()->getType();\n+ EI.UserTE->isGather()\n+ ? EI.UserTE->Scalars.front()->getType()\n+ : EI.UserTE->getOperand(EI.EdgeIdx).front()->getType();\n if (UserBWIt != MinBWs.end())\n UserScalarTy = IntegerType::get(ScalarTy->getContext(),\n UserBWIt->second.first);\n", "tests": [{"file": "llvm/test/Transforms/SLPVectorizer/X86/user-buildvector-with-minbiwidth.ll", "commands": ["opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"], "tests": [{"test_name": "", "test_body": "\ndefine i32 @test(i8 %0, i32 %conv2, i1 %cmp.i, i64 %shl.i) {\n;\nentry:\n %conv21 = sext i8 %0 to i32\n %conv7 = zext i32 %conv2 to i64\n %cond.i = shl i64 %conv7, %shl.i\n %1 = and i64 %cond.i, 4294967295\n %.not = icmp eq i64 %1, 1\n %conv7.1 = zext i32 %conv2 to i64\n %cond.i.1 = shl i64 %conv7.1, %shl.i\n %2 = and i64 %cond.i.1, 4294967295\n %.not.1 = icmp eq i64 %2, 1\n %sub.2 = or i32 %conv21, 1\n %cond.2 = select i1 %cmp.i, i32 %sub.2, i32 0\n %conv7.2 = zext i32 %cond.2 to i64\n %cmp.i.2 = icmp slt i32 %cond.2, 1\n %shl.i.2 = zext i1 %cmp.i.2 to i64\n %cond.i.2 = shl i64 %conv7.2, %shl.i.2\n %3 = and i64 %cond.i.2, 4294967295\n %.not.2 = icmp eq i64 %3, 1\n %sub.3 = or i32 %conv21, 1\n %cond.3 = select i1 %cmp.i, i32 %sub.3, i32 0\n %conv7.3 = zext i32 %cond.3 to i64\n %cmp.i.3 = icmp slt i32 %cond.3, 1\n %shl.i.3 = zext i1 %cmp.i.3 to i64\n %cond.i.3 = shl i64 %conv7.3, %shl.i.3\n %4 = and i64 %cond.i.3, 4294967295\n %.not.3 = icmp eq i64 %4, 1\n %sub.4 = or i32 %conv21, 1\n %cond.4 = select i1 %cmp.i, i32 %sub.4, i32 0\n %conv7.4 = zext i32 %cond.4 to i64\n %cmp.i.4 = icmp slt i32 %cond.4, 1\n %shl.i.4 = zext i1 %cmp.i.4 to i64\n %cond.i.4 = shl i64 %conv7.4, %shl.i.4\n %5 = and i64 %cond.i.4, 4294967295\n %.not.4 = icmp eq i64 %5, 1\n %sub.5 = or i32 %conv21, 1\n %cond.5 = select i1 %cmp.i, i32 %sub.5, i32 0\n %conv7.5 = zext i32 %cond.5 to i64\n %cmp.i.5 = icmp slt i32 %cond.5, 1\n %shl.i.5 = zext i1 %cmp.i.5 to i64\n %cond.i.5 = shl i64 %conv7.5, %shl.i.5\n %6 = and i64 %cond.i.5, 4294967295\n %.not.5 = icmp eq i64 %6, 1\n %sub.6 = or i32 %conv21, 1\n %cond.6 = select i1 %cmp.i, i32 %sub.6, i32 0\n %conv7.6 = zext i32 %cond.6 to i64\n %cmp.i.6 = icmp slt i32 %cond.6, 1\n %shl.i.6 = zext i1 %cmp.i.6 to i64\n %cond.i.6 = shl i64 %conv7.6, %shl.i.6\n %7 = and i64 %cond.i.6, 4294967295\n %.not.6 = icmp eq i64 %7, 1\n %sub.7 = or i32 %conv21, 1\n %cond.7 = select i1 %cmp.i, i32 %sub.7, i32 0\n %conv7.7 = zext i32 %cond.7 to i64\n %cmp.i.7 = icmp slt i32 %cond.7, 1\n %shl.i.7 = zext i1 %cmp.i.7 to i64\n %cond.i.7 = shl i64 %conv7.7, %shl.i.7\n %8 = and i64 %cond.i.7, 4294967295\n %.not.7 = icmp eq i64 %8, 1\n %sub.8 = or i32 %conv21, 1\n %cond.8 = select i1 %cmp.i, i32 %sub.8, i32 0\n %conv7.8 = zext i32 %cond.8 to i64\n %cmp.i.8 = icmp slt i32 %cond.8, 1\n %shl.i.8 = zext i1 %cmp.i.8 to i64\n %cond.i.8 = shl i64 %conv7.8, %shl.i.8\n %9 = and i64 %cond.i.8, 4294967295\n %.not.8 = icmp eq i64 %9, 1\n %sub.9 = or i32 %conv21, 1\n %cond.9 = select i1 %cmp.i, i32 %sub.9, i32 0\n %conv7.9 = zext i32 %cond.9 to i64\n %cmp.i.9 = icmp slt i32 %cond.9, 1\n %shl.i.9 = zext i1 %cmp.i.9 to i64\n %cond.i.9 = shl i64 %conv7.9, %shl.i.9\n %10 = and i64 %cond.i.9, 4294967295\n %.not.9 = icmp eq i64 %10, 1\n br label %while.body\n\nwhile.body:\n br i1 %.not, label %for.inc, label %if.then10\n\nif.then10:\n br label %for.inc\n\nfor.inc:\n br i1 %.not.1, label %for.inc.1, label %if.then10.1\n\nif.then10.1:\n br label %for.inc.1\n\nfor.inc.1:\n br i1 %.not.2, label %for.inc.2, label %if.then10.2\n\nif.then10.2:\n br label %for.inc.2\n\nfor.inc.2:\n br i1 %.not.3, label %for.inc.3, label %if.then10.3\n\nif.then10.3:\n br label %for.inc.3\n\nfor.inc.3:\n br i1 %.not.4, label %for.inc.4, label %if.then10.4\n\nif.then10.4:\n br label %for.inc.4\n\nfor.inc.4:\n br i1 %.not.5, label %for.inc.5, label %if.then10.5\n\nif.then10.5:\n br label %for.inc.5\n\nfor.inc.5:\n br i1 %.not.6, label %for.inc.6, label %if.then10.6\n\nif.then10.6:\n br label %for.inc.6\n\nfor.inc.6:\n br i1 %.not.7, label %for.inc.7, label %if.then10.7\n\nif.then10.7:\n br label %for.inc.7\n\nfor.inc.7:\n br i1 %.not.8, label %for.inc.8, label %if.then10.8\n\nif.then10.8:\n br label %for.inc.8\n\nfor.inc.8:\n br i1 %.not.9, label %while.body, label %if.then10.9\n\nif.then10.9:\n br label %while.body\n}"}]}], "issue": {"title": "clang crashes on valid code at -O{2,3} on x86_64-linux-gnu: Assertion `valid() && \"InstructionsState is invalid.\"' failed", "body": "It appears to be a recent regression as it doesn't reproduce with 19.1.0 and earlier.\n\nCompiler Explorer: https://godbolt.org/z/8KTq9hGv9\n\n```\n[516] % clangtk -v\nclang version 21.0.0git (https://github.com/llvm/llvm-project.git d0edd931bcc328b9502289d346f2b2219341f853)\nTarget: x86_64-unknown-linux-gnu\nThread model: posix\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\nBuild config: +assertions\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\nCandidate multilib: .;@m64\nSelected multilib: .;@m64\n[517] % \n[517] % clangtk -O2 -w small.c\nclang-21: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:821: llvm::Instruction* {anonymous}::InstructionsState::getMainOp() const: Assertion `valid() && \"InstructionsState is invalid.\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\nStack dump:\n0.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-21 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/20250227-clangtk-m64-O3-build-235136/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20250227-clangtk-m64-O3-build-235136/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/21 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -w -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-933a0f.o -x c small.c\n1.\t parser at end of file\n2.\tOptimizer\n3.\tRunning pass \"function(float2int,lower-constant-intrinsics,loop(loop-rotate,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize,infer-alignment,loop-load-elim,instcombine,simplifycfg,slp-vectorizer,vector-combine,instcombine,loop-unroll,transform-warning,sroa,infer-alignment,instcombine,loop-mssa(licm),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg)\" on module \"small.c\"\n4.\tRunning pass \"slp-vectorizer\" on function \"main\"\n #0 0x00005597e9b142df llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x455e2df)\n #1 0x00005597e9b11ab4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007fa06c8aa420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\n #3 0x00007fa06c2e100b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\n #4 0x00007fa06c2c0859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\n #5 0x00007fa06c2c0729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\n #6 0x00007fa06c2c0729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\n #7 0x00007fa06c2d1fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\n #8 0x00005597eb591745 (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5fdb745)\n #9 0x00005597eb62a4e5 llvm::slpvectorizer::BoUpSLP::getEntryCost(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef, llvm::SmallPtrSetImpl&)::'lambda0'(llvm::function_ref, llvm::function_ref)::operator()(llvm::function_ref, llvm::function_ref) const SLPVectorizer.cpp:0:0\n#10 0x00005597eb633034 llvm::slpvectorizer::BoUpSLP::getEntryCost(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef, llvm::SmallPtrSetImpl&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x607d034)\n#11 0x00005597eb668741 llvm::slpvectorizer::BoUpSLP::getTreeCost(llvm::ArrayRef) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60b2741)\n#12 0x00005597eb672691 llvm::SLPVectorizerPass::tryToVectorizeList(llvm::ArrayRef, llvm::slpvectorizer::BoUpSLP&, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60bc691)\n#13 0x00005597eb676e5e bool llvm::SLPVectorizerPass::vectorizeCmpInsts>(llvm::iterator_range>, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60c0e5e)\n#14 0x00005597eb6773db llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&)::'lambda3'(bool)::operator()(bool) const SLPVectorizer.cpp:0:0\n#15 0x00005597eb67ac20 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60c4c20)\n#16 0x00005597eb681396 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\n#17 0x00005597eb681ef3 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60cbef3)\n#18 0x00005597eb104166 llvm::detail::PassModel>::run(llvm::Function&, llvm::AnalysisManager&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5b4e166)\n#19 0x00005597e948caf9 llvm::PassManager>::run(llvm::Function&, llvm::AnalysisManager&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x3ed6af9)\n#20 0x00005597e6d6c406 llvm::detail::PassModel>, llvm::AnalysisManager>::run(llvm::Function&, llvm::AnalysisManager&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x17b6406)\n#21 0x00005597e948b362 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x3ed5362)\n#22 0x00005597e6d6a4b6 llvm::detail::PassModel>::run(llvm::Module&, llvm::AnalysisManager&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x17b44b6)\n#23 0x00005597e948ad81 llvm::PassManager>::run(llvm::Module&, llvm::AnalysisManager&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x3ed4d81)\n#24 0x00005597e9ddb283 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr>&, std::unique_ptr>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\n#25 0x00005597e9ddf573 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr, std::unique_ptr>, clang::BackendConsumer*) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x4829573)\n#26 0x00005597ea51bba0 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x4f65ba0)\n#27 0x00005597ebe39acc clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x6883acc)\n#28 0x00005597ea51bfc8 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x4f65fc8)\n#29 0x00005597ea7f2779 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x523c779)\n#30 0x00005597ea77325e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x51bd25e)\n#31 0x00005597ea8e7626 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5331626)\n#32 0x00005597e68fefb7 cc1_main(llvm::ArrayRef, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x1348fb7)\n#33 0x00005597e68f66ea ExecuteCC1Tool(llvm::SmallVectorImpl&, llvm::ToolContext const&) driver.cpp:0:0\n#34 0x00005597e68fa97a clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x134497a)\n#35 0x00005597e67edccb main (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x1237ccb)\n#36 0x00007fa06c2c2083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\n#37 0x00005597e68f617e _start (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x134017e)\nclangtk: error: unable to execute command: Aborted\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\nclang version 21.0.0git (https://github.com/llvm/llvm-project.git d0edd931bcc328b9502289d346f2b2219341f853)\nTarget: x86_64-unknown-linux-gnu\nThread model: posix\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\nBuild config: +assertions\nclangtk: note: diagnostic msg: \n********************\n\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\nPreprocessed source(s) and associated run script(s) are located at:\nclangtk: note: diagnostic msg: /tmp/small-fd80bc.c\nclangtk: note: diagnostic msg: /tmp/small-fd80bc.sh\nclangtk: note: diagnostic msg: \n\n********************\n[518] % \n[518] % cat small.c\nint a[1], g;\nchar b, c;\nvolatile int d;\nlong e, f;\nlong h(long i) { return i > 1 ? i : i << 1; }\nint main() {\n if (g)\n while (1) {\n b = 0;\n for (; b < 10; b++) {\n e = c & b ? 0 : c - b;\n f = h(e);\n g = (a != 0) % (unsigned)f;\n if (g)\n d;\n }\n }\n return 0;\n}\n```\n\n", "author": "zhendongsu", "labels": ["llvm:SLPVectorizer", "crash"], "comments": []}, "verified": true} {"bug_id": "82230", "issue_url": "https://github.com/llvm/llvm-project/issues/82230", "bug_type": "crash", "base_commit": "769c22f25b81b74e4da7871d4e552584605caef1", "knowledge_cutoff": "2024-02-19T09:37:19Z", "lit_test_dir": ["llvm/test/DebugInfo"], "hints": {"fix_commit": "5b342e6041f8567a39354ae3c5346cf74b3bb84f", "components": ["IR"], "bug_location_lineno": {"llvm/lib/IR/AsmWriter.cpp": [[293, 299], [4886, 4893]]}, "bug_location_funcname": {"llvm/lib/IR/AsmWriter.cpp": ["DPValue::print", "PrintCallingConv", "getModuleFromDPI"]}}, "patch": "commit 5b342e6041f8567a39354ae3c5346cf74b3bb84f\nAuthor: Stephen Tozer \nDate: Mon Feb 19 11:38:04 2024 +0000\n\n [RemoveDIs][DebugInfo] Check for null marker when printing DPValues (#82238)\n \n The function to print DPValues currently tries to incorporate the\n function it is part of, which is found through its marker; this means\n when we try to print a DPValue with no marker, we dereference a nullptr.\n We can print instructions without parents, and so the same should be\n true for DPValues; this patch changes DPValue::print to check for a null\n marker and avoid dereferencing it.\n \n Fixes issue: https://github.com/llvm/llvm-project/issues/82230\n\ndiff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp\nindex 0ae720e8b7ce..d3c64a57f7fd 100644\n--- a/llvm/lib/IR/AsmWriter.cpp\n+++ b/llvm/lib/IR/AsmWriter.cpp\n@@ -293,7 +293,7 @@ static const Module *getModuleFromDPI(const DPMarker *Marker) {\n }\n \n static const Module *getModuleFromDPI(const DPValue *DPV) {\n- return getModuleFromDPI(DPV->getMarker());\n+ return DPV->getMarker() ? getModuleFromDPI(DPV->getMarker()) : nullptr;\n }\n \n static void PrintCallingConv(unsigned cc, raw_ostream &Out) {\n@@ -4886,8 +4886,9 @@ void DPValue::print(raw_ostream &ROS, ModuleSlotTracker &MST,\n if (F)\n MST.incorporateFunction(*F);\n };\n- incorporateFunction(Marker->getParent() ? Marker->getParent()->getParent()\n- : nullptr);\n+ incorporateFunction(Marker && Marker->getParent()\n+ ? Marker->getParent()->getParent()\n+ : nullptr);\n AssemblyWriter W(OS, SlotTable, getModuleFromDPI(this), nullptr, IsForDebug);\n W.printDPValue(*this);\n }\n", "tests": [{"file": "llvm/test/DebugInfo/dpvalue-print-nocrash.ll", "commands": ["opt -passes=\"instcombine\" -debug %s -o /dev/null 2>&1"], "tests": [{"test_name": "", "test_body": ";; Tests that we can debug-print DPValues that have no markers attached.\n; REQUIRES: asserts\n\n\ndefine ptr @func_10(i32 %p_11) {\nentry:\n %conv108 = zext i32 %p_11 to i64\n tail call void @llvm.dbg.value(metadata i64 %conv108, metadata !4, metadata !DIExpression()), !dbg !12\n br label %func_29.exit\n\nfunc_29.exit: ; preds = %entry\n store i64 %conv108, ptr null, align 1\n ret ptr null\n}\n\ndeclare void @llvm.dbg.value(metadata, metadata, metadata)\n\n!llvm.dbg.cu = !{!0}\n!llvm.module.flags = !{!3}\n\n!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: \"clang\", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, retainedTypes: !2, globals: !2, splitDebugInlining: false, nameTableKind: None)\n!1 = !DIFile(filename: \"csmith5961503756960.c\", directory: \"/llvm\")\n!2 = !{}\n!3 = !{i32 2, !\"Debug Info Version\", i32 3}\n!4 = !DILocalVariable(name: \"p_31\", arg: 2, scope: !5, file: !1, line: 148, type: !7)\n!5 = distinct !DISubprogram(name: \"func_29\", scope: !1, file: !1, line: 148, type: !6, scopeLine: 149, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)\n!6 = !DISubroutineType(types: !2)\n!7 = !DIDerivedType(tag: DW_TAG_typedef, name: \"uint64_t\", file: !8, line: 60, baseType: !9)\n!8 = !DIFile(filename: \"/foo/_stdint.h\", directory: \"\")\n!9 = !DIDerivedType(tag: DW_TAG_typedef, name: \"__uint64_t\", file: !10, line: 108, baseType: !11)\n!10 = !DIFile(filename: \"/foo/_default_types.h\", directory: \"\")\n!11 = !DIBasicType(name: \"unsigned long long\", size: 64, encoding: DW_ATE_unsigned)\n!12 = !DILocation(line: 0, scope: !5)"}]}], "issue": {"title": "opt -passes=\"instcombine\" -debug crashes with non-instrinsic debug-info", "body": "llvm commit: d61864f813e3\r\nReproduce with:\r\n```\r\nopt -passes=\"instcombine\" -debug bbi-92509.ll -o /dev/null\r\n```\r\n[bbi-92509.ll.gz](https://github.com/llvm/llvm-project/files/14329283/bbi-92509.ll.gz)\r\n\r\nResult:\r\n```\r\nINSTCOMBINE ITERATION #1 on func_10\r\nADD: ret ptr null\r\nADD: store i64 %conv108, ptr null, align 1\r\nADD: br label %func_29.exit\r\nADD: %conv108 = zext i32 %p_11 to i64\r\nCLONE: PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: ../../main-github/llvm/build-all/bin/opt -passes=instcombine -debug bbi-92509.ll -o /dev/null\r\n #0 0x000055e12968f4a7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (../../main-github/llvm/build-all/bin/opt+0x3db14a7)\r\n #1 0x000055e12968cf7e llvm::sys::RunSignalHandlers() (../../main-github/llvm/build-all/bin/opt+0x3daef7e)\r\n #2 0x000055e12968fe6f SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007fdf33999630 __restore_rt sigaction.c:0:0\r\n #4 0x000055e12971f8e0 llvm::DPMarker::getParent() const (../../main-github/llvm/build-all/bin/opt+0x3e418e0)\r\n #5 0x000055e129761abf llvm::DPValue::print(llvm::raw_ostream&, bool) const (../../main-github/llvm/build-all/bin/opt+0x3e83abf)\r\n #6 0x000055e12a244957 llvm::InstCombinerImpl::tryToSinkInstructionDPValues(llvm::Instruction*, llvm::ilist_iterator_w_bits, false, false>, llvm::BasicBlock*, llvm::BasicBlock*, llvm::SmallVectorImpl&) InstructionCombining.cpp:0:0\r\n #7 0x000055e12a242b0c llvm::InstCombinerImpl::tryToSinkInstruction(llvm::Instruction*, llvm::BasicBlock*) InstructionCombining.cpp:0:0\r\n #8 0x000055e12a2453fc llvm::InstCombinerImpl::run() InstructionCombining.cpp:0:0\r\n #9 0x000055e12a248c79 combineInstructionsOverFunction(llvm::Function&, llvm::InstructionWorklist&, llvm::AAResults*, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::ProfileSummaryInfo*, llvm::LoopInfo*, llvm::InstCombineOptions const&) InstructionCombining.cpp:0:0\r\n#10 0x000055e12a2482ea llvm::InstCombinePass::run(llvm::Function&, llvm::AnalysisManager&) (../../main-github/llvm/build-all/bin/opt+0x496a2ea)\r\n#11 0x000055e12a95e5bd llvm::detail::PassModel>::run(llvm::Function&, llvm::AnalysisManager&) PassBuilderPipelines.cpp:0:0\r\n#12 0x000055e12989a8e4 llvm::PassManager>::run(llvm::Function&, llvm::AnalysisManager&) (../../main-github/llvm/build-all/bin/opt+0x3fbc8e4)\r\n#13 0x000055e12a9644dd llvm::detail::PassModel>, llvm::AnalysisManager>::run(llvm::Function&, llvm::AnalysisManager&) PassBuilderPipelines.cpp:0:0\r\n#14 0x000055e12989f9ae llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager&) (../../main-github/llvm/build-all/bin/opt+0x3fc19ae)\r\n#15 0x000055e12a95dd9d llvm::detail::PassModel>::run(llvm::Module&, llvm::AnalysisManager&) PassBuilderPipelines.cpp:0:0\r\n#16 0x000055e129899456 llvm::PassManager>::run(llvm::Module&, llvm::AnalysisManager&) (../../main-github/llvm/build-all/bin/opt+0x3fbb456)\r\n#17 0x000055e12a90a42b llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef, llvm::ArrayRef>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (../../main-github/llvm/build-all/bin/opt+0x502c42b)\r\n#18 0x000055e129657a28 optMain (../../main-github/llvm/build-all/bin/opt+0x3d79a28)\r\n#19 0x00007fdf310cc555 __libc_start_main (/lib64/libc.so.6+0x22555)\r\n#20 0x000055e129651369 _start (../../main-github/llvm/build-all/bin/opt+0x3d73369)\r\nSegmentation fault (core dumped)\r\n```\r\n\r\nThis starts happening with a93a4ec7dd205\r\n```\r\nReapply \"[DebugInfo][RemoveDIs] Turn on non-instrinsic debug-info by default\"\r\n```\r\n", "author": "mikaelholmen", "labels": ["debuginfo", "llvm:crash", "llvm:ir"], "comments": [{"author": "SLTozer", "body": "Should be fixed by: [5b342e6](https://github.com/llvm/llvm-project/commit/5b342e6041f8567a39354ae3c5346cf74b3bb84f)"}, {"author": "mikaelholmen", "body": "> Should be fixed by: [5b342e6](https://github.com/llvm/llvm-project/commit/5b342e6041f8567a39354ae3c5346cf74b3bb84f)\r\n\r\nYep, thanks!"}]}, "verified": true} {"bug_id": "115732", "issue_url": "https://github.com/llvm/llvm-project/issues/115732", "bug_type": "crash", "base_commit": "da78ac5d331953d3386fd56cd7979022be7400cf", "knowledge_cutoff": "2024-11-11T16:03:33Z", "lit_test_dir": ["llvm/test/Transforms/SLPVectorizer"], "hints": {"fix_commit": "058ac837bc35419bbbb34f3206f5aa229c669811", "components": ["SLPVectorizer"], "bug_location_lineno": {"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [[3045, 3051], [9167, 9174], [13454, 13460], [13560, 13566], [14022, 14028]]}, "bug_location_funcname": {"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": ["BoUpSLP::gather", "BoUpSLP::setInsertPointAfterBundle", "createFreeze", "createShuffle"]}}, "patch": "commit 058ac837bc35419bbbb34f3206f5aa229c669811\nAuthor: Alexey Bataev \nDate: Mon Nov 11 10:48:15 2024 -0800\n\n [SLP]Use generic createShuffle for buildvector\n \n Use generic createShuffle function, which know how to adjust the vectors\n correctly, to avoid compiler crash when trying to build a buildvector as\n a shuffle\n \n Fixes #115732\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex da8e0d8cc09a..1bf082d57b8b 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -3045,7 +3045,9 @@ private:\n \n /// \\returns a vector from a collection of scalars in \\p VL. if \\p Root is not\n /// specified, the starting vector value is poison.\n- Value *gather(ArrayRef VL, Value *Root, Type *ScalarTy);\n+ Value *\n+ gather(ArrayRef VL, Value *Root, Type *ScalarTy,\n+ function_ref)> CreateShuffle);\n \n /// \\returns whether the VectorizableTree is fully vectorizable and will\n /// be beneficial even the tree height is tiny.\n@@ -9167,8 +9169,9 @@ protected:\n int VF = Mask.size();\n if (auto *FTy = dyn_cast(V1->getType()))\n VF = FTy->getNumElements();\n- if (V2 &&\n- !isUndefVector(V2, buildUseMask(VF, Mask, UseMask::SecondArg)).all()) {\n+ if (V2 && !isUndefVector(\n+ V2, buildUseMask(VF, Mask, UseMask::SecondArg))\n+ .all()) {\n // Peek through shuffles.\n Value *Op1 = V1;\n Value *Op2 = V2;\n@@ -13454,7 +13457,9 @@ void BoUpSLP::setInsertPointAfterBundle(const TreeEntry *E) {\n Builder.SetCurrentDebugLocation(Front->getDebugLoc());\n }\n \n-Value *BoUpSLP::gather(ArrayRef VL, Value *Root, Type *ScalarTy) {\n+Value *BoUpSLP::gather(\n+ ArrayRef VL, Value *Root, Type *ScalarTy,\n+ function_ref)> CreateShuffle) {\n // List of instructions/lanes from current block and/or the blocks which are\n // part of the current loop. These instructions will be inserted at the end to\n // make it possible to optimize loops and hoist invariant instructions out of\n@@ -13560,7 +13565,7 @@ Value *BoUpSLP::gather(ArrayRef VL, Value *Root, Type *ScalarTy) {\n if (isa(Vec)) {\n Vec = OriginalRoot;\n } else {\n- Vec = Builder.CreateShuffleVector(Root, Vec, Mask);\n+ Vec = CreateShuffle(Root, Vec, Mask);\n if (auto *OI = dyn_cast(OriginalRoot);\n OI && OI->hasNUses(0))\n eraseInstruction(OI);\n@@ -14022,7 +14027,10 @@ public:\n }\n Value *gather(ArrayRef VL, unsigned MaskVF = 0,\n Value *Root = nullptr) {\n- return R.gather(VL, Root, ScalarTy);\n+ return R.gather(VL, Root, ScalarTy,\n+ [&](Value *V1, Value *V2, ArrayRef Mask) {\n+ return createShuffle(V1, V2, Mask);\n+ });\n }\n Value *createFreeze(Value *V) { return Builder.CreateFreeze(V); }\n /// Finalize emission of the shuffles.\n", "tests": [{"file": "llvm/test/Transforms/SLPVectorizer/X86/buildvector-shuffle-with-root.ll", "commands": ["opt -S --passes=slp-vectorizer -slp-threshold=-99999 -mtriple=x86_64-unknown-linux-gnu < %s"], "tests": [{"test_name": "", "test_body": "\ndefine void @test(i16 %arg) {\n;\nbb:\n %sitofp = sitofp i16 %arg to float\n %fadd = fadd float 0.000000e+00, 0.000000e+00\n %fsub = fsub float 0.000000e+00, %sitofp\n %fsub1 = fsub float 0.000000e+00, %sitofp\n %fsub2 = fsub float 0.000000e+00, %sitofp\n %sitofp3 = sitofp i16 0 to float\n %fsub4 = fsub float %fadd, %sitofp3\n store float %fsub4, ptr addrspace(1) getelementptr inbounds (i8, ptr addrspace(1) null, i64 20), align 4\n %fsub5 = fsub float %fsub, %sitofp\n store float %fsub5, ptr addrspace(1) getelementptr inbounds (i8, ptr addrspace(1) null, i64 24), align 4\n %fsub6 = fsub float %fsub1, %sitofp\n store float %fsub6, ptr addrspace(1) getelementptr inbounds (i8, ptr addrspace(1) null, i64 28), align 4\n %fsub7 = fsub float %fsub2, %sitofp\n store float %fsub7, ptr addrspace(1) getelementptr inbounds (i8, ptr addrspace(1) null, i64 32), align 4\n ret void\n}"}]}], "issue": {"title": "Assertion `isValidOperands(V1, V2, Mask) && \"Invalid shuffle vector instruction operands!\"' failed.", "body": "To reproduce run the test below with -passes=slp-vectorizer.\r\n```\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(i16 %arg) gc \"statepoint-example\" {\r\nbb:\r\n %sitofp = sitofp i16 %arg to float\r\n %fadd = fadd float 0.000000e+00, 0.000000e+00\r\n %fsub = fsub float 0.000000e+00, %sitofp\r\n %fsub1 = fsub float 0.000000e+00, %sitofp\r\n %fsub2 = fsub float 0.000000e+00, %sitofp\r\n %sitofp3 = sitofp i16 0 to float\r\n %fsub4 = fsub float %fadd, %sitofp3\r\n store float %fsub4, ptr addrspace(1) getelementptr inbounds (i8, ptr addrspace(1) null, i64 20), align 4\r\n %fsub5 = fsub float %fsub, %sitofp\r\n store float %fsub5, ptr addrspace(1) getelementptr inbounds (i8, ptr addrspace(1) null, i64 24), align 4\r\n %fsub6 = fsub float %fsub1, %sitofp\r\n store float %fsub6, ptr addrspace(1) getelementptr inbounds (i8, ptr addrspace(1) null, i64 28), align 4\r\n %fsub7 = fsub float %fsub2, %sitofp\r\n store float %fsub7, ptr addrspace(1) getelementptr inbounds (i8, ptr addrspace(1) null, i64 32), align 4\r\n ret void\r\n}\r\n```\r\nReproducer: https://godbolt.org/z/6h4xzhGa1\r\nStack dump:\r\n```\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer \r\n1.\tRunning pass \"function(slp-vectorizer)\" on module \"\"\r\n2.\tRunning pass \"slp-vectorizer\" on function \"wombat\"\r\n #0 0x00000000051494c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x51494c8)\r\n #1 0x0000000005146ebc SignalHandler(int) Signals.cpp:0:0\r\n #2 0x000072f583642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x000072f5836969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x000072f583642476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x000072f5836287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x000072f58362871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x000072f583639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x0000000004eb74ce llvm::ShuffleVectorInst::ShuffleVectorInst(llvm::Value*, llvm::Value*, llvm::ArrayRef, llvm::Twine const&, llvm::InsertPosition) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4eb74ce)\r\n #9 0x0000000000d09e93 llvm::IRBuilderBase::CreateShuffleVector(llvm::Value*, llvm::Value*, llvm::ArrayRef, llvm::Twine const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xd09e93)\r\n#10 0x00000000041a0bdd llvm::slpvectorizer::BoUpSLP::gather(llvm::ArrayRef, llvm::Value*, llvm::Type*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x41a0bdd)\r\n#11 0x00000000041a13fc void llvm::function_ref&)>::callback_fn, llvm::slpvectorizer::BoUpSLP>(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::Type*, llvm::IRBuilder&, llvm::slpvectorizer::BoUpSLP&)::'lambda15'(llvm::Value*&, llvm::SmallVectorImpl&)>(long, llvm::Value*&, llvm::SmallVectorImpl&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x41a13fc)\r\n#12 0x00000000041a26b9 llvm::slpvectorizer::BoUpSLP::ShuffleInstructionBuilder::finalize(llvm::ArrayRef, llvm::ArrayRef>, llvm::ArrayRef, unsigned int, llvm::function_ref&)>) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x41a26b9)\r\n#13 0x00000000041d5335 llvm::Value* llvm::slpvectorizer::BoUpSLP::processBuildVector, llvm::slpvectorizer::BoUpSLP>(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::Type*, llvm::IRBuilder&, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x41d5335)\r\n#14 0x00000000041e168e llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x41e168e)\r\n#15 0x000000000420234a llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::SmallDenseSet> const&, llvm::Instruction*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x420234a)\r\n#16 0x0000000004205c7d llvm::slpvectorizer::BoUpSLP::vectorizeTree() (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4205c7d)\r\n#17 0x0000000004224402 llvm::SLPVectorizerPass::vectorizeStoreChain(llvm::ArrayRef, llvm::slpvectorizer::BoUpSLP&, unsigned int, unsigned int, unsigned int&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4224402)\r\n#18 0x0000000004225e6b llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet, llvm::DenseMapInfo, void>>&)::'lambda'(std::set, llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet, llvm::DenseMapInfo, void>>&)::StoreDistCompare, std::allocator>> const&)::operator()(std::set, llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet, llvm::DenseMapInfo, void>>&)::StoreDistCompare, std::allocator>> const&) const SLPVectorizer.cpp:0:0\r\n#19 0x0000000004227d98 llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet, llvm::DenseMapInfo, void>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4227d98)\r\n#20 0x00000000042285e9 llvm::SLPVectorizerPass::vectorizeStoreChains(llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x42285e9)\r\n#21 0x0000000004229b35 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#22 0x000000000422a63b llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x422a63b)\r\n#23 0x0000000002f9948e llvm::detail::PassModel>::run(llvm::Function&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2f9948e)\r\n#24 0x0000000004f47488 llvm::PassManager>::run(llvm::Function&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f47488)\r\n#25 0x0000000000e3bf3e llvm::detail::PassModel>, llvm::AnalysisManager>::run(llvm::Function&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe3bf3e)\r\n#26 0x0000000004f45eae llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f45eae)\r\n#27 0x0000000000e3b64e llvm::detail::PassModel>::run(llvm::Module&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe3b64e)\r\n#28 0x0000000004f458e0 llvm::PassManager>::run(llvm::Module&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f458e0)\r\n#29 0x000000000091103a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef, llvm::ArrayRef>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x91103a)\r\n#30 0x000000000090399a optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x90399a)\r\n#31 0x000072f583629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#32 0x000072f583629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#33 0x00000000008fb41e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8fb41e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```", "author": "TatyanaDoubts", "labels": ["llvm:SLPVectorizer", "crash"], "comments": [{"author": "RKSimon", "body": "CC @alexey-bataev "}]}, "verified": true} {"bug_id": "116775", "issue_url": "https://github.com/llvm/llvm-project/issues/116775", "bug_type": "crash", "base_commit": "bdf00e2216280edef1ec91ccc07987db92197b59", "knowledge_cutoff": "2024-11-19T09:53:12Z", "lit_test_dir": ["llvm/test/Transforms/InstCombine"], "hints": {"fix_commit": "03d8831fa8ef5b7e32172c718b550a454645faea", "components": ["InstCombine"], "bug_location_lineno": {"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": [[997, 1003]]}, "bug_location_funcname": {"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": ["InstCombinerImpl::SimplifyDemandedUseBits"]}}, "patch": "commit 03d8831fa8ef5b7e32172c718b550a454645faea\nAuthor: Yingwei Zheng \nDate: Tue Nov 19 22:17:24 2024 +0800\n\n [InstCombine] Handle constant GEP expr in `SimplifyDemandedUseBits` (#116794)\n \n Closes https://github.com/llvm/llvm-project/issues/116775.\n\ndiff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp\nindex 5eb807dcb76c..392c5c78345c 100644\n--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp\n+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp\n@@ -997,7 +997,7 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Instruction *I,\n uint64_t MaskedGEPIndex = HighBitsGEPIndex | MaskedLowBitsGEPIndex;\n \n if (MaskedGEPIndex != GEPIndex) {\n- auto *GEP = cast(II->getArgOperand(0));\n+ auto *GEP = cast(II->getArgOperand(0));\n Builder.SetInsertPoint(I);\n Type *GEPIndexType =\n DL.getIndexType(GEP->getPointerOperand()->getType());\n", "tests": [{"file": "llvm/test/Transforms/InstCombine/ptrmask.ll", "commands": ["opt < %s -passes=instcombine -S"], "tests": [{"test_name": "ptrmask_demandedbits_constantexpr", "test_body": "target datalayout = \"p1:64:64:64:32\"\n\n@GC_arrays = external global { i8, i8, i64 }\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare ptr @llvm.ptrmask.p0.i64(ptr, i64) #0\n\ndefine ptr @ptrmask_demandedbits_constantexpr() {\nentry:\n %aligned_result = call ptr @llvm.ptrmask.p0.i64(ptr getelementptr inbounds (i8, ptr @GC_arrays, i64 1), i64 -8)\n ret ptr %aligned_result\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "ptrmask_is_useless_fail1", "test_body": "target datalayout = \"p1:64:64:64:32\"\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare ptr @llvm.ptrmask.p0.i64(ptr, i64) #0\n\ndefine ptr @ptrmask_is_useless_fail1(i64 %i, i64 %m) {\n %m0 = and i64 %m, 127\n %i0 = and i64 %i, 511\n %p0 = inttoptr i64 %i0 to ptr\n %r = call ptr @llvm.ptrmask.p0.i64(ptr %p0, i64 %m0)\n ret ptr %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}]}], "issue": {"title": "Segfault when building https://github.com/ivmai/bdwgc@4fe4238", "body": "Attempting to build [https://github.com/ivmai/bdwgc@4fe4238](https://github.com/ivmai/bdwgc/tree/4fe42389509ff059bad8d4c955a570b34a6bda4b) using\r\n```shell\r\n$ ./autogen.sh\r\n$ ./configure --with-libatomic-ops --enable-cplusplus --enable-large-config\r\n$ make\r\n```\r\nresults in\r\n```text\r\nlibtool: compile: clang -std=gnu23 -DHAVE_CONFIG_H -I./include -I./include -DNDEBUG -fexceptions -DGC_VISIBILITY_HIDDEN_SET -fvisibility=hidden -Wall -Wextra -Wpedantic -Wno-long-long -O2 -march=native -Wno-frame-address -MT extra/gc.lo -MD -MP -MF extra/.deps/gc.Tpo -c extra/gc.c -fno-common -DPIC -o extra/.libs/gc.o\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: clang -std=gnu23 -DHAVE_CONFIG_H -I./include -I./include -DNDEBUG -fexceptions -DGC_VISIBILITY_HIDDEN_SET -fvisibility=hidden -Wall -Wextra -Wpedantic -Wno-long-long -O2 -march=native -Wno-frame-address -MT extra/gc.lo -MD -MP -MF extra/.deps/gc.Tpo -c extra/gc.c -fno-common -DPIC -o extra/.libs/gc.o\r\n1.\t parser at end of file\r\n2.\tOptimizer\r\n3.\tRunning pass \"require,function(invalidate),require,cgscc(devirt<4>(inline,function-attrs,openmp-opt-cgscc,function(sroa,early-cse,speculative-execution,jump-threading,correlated-propagation,simplifycfg,instcombine,aggressive-instcombine,libcalls-shrinkwrap,tailcallelim,simplifycfg,reassociate,constraint-elimination,loop-mssa(loop-instsimplify,loop-simplifycfg,licm,loop-rotate,licm,simple-loop-unswitch),simplifycfg,instcombine,loop(loop-idiom,indvars,simple-loop-unswitch,loop-deletion,loop-unroll-full),sroa,vector-combine,mldst-motion,gvn<>,sccp,bdce,instcombine,jump-threading,correlated-propagation,adce,memcpyopt,dse,move-auto-init,loop-mssa(licm),coro-elide,simplifycfg,instcombine),function-attrs,function(require),coro-split,coro-annotation-elide)),function(invalidate),cgscc(devirt<4>())\" on module \"extra/gc.c\"\r\n4.\tRunning pass \"cgscc(devirt<4>(inline,function-attrs,openmp-opt-cgscc,function(sroa,early-cse,speculative-execution,jump-threading,correlated-propagation,simplifycfg,instcombine,aggressive-instcombine,libcalls-shrinkwrap,tailcallelim,simplifycfg,reassociate,constraint-elimination,loop-mssa(loop-instsimplify,loop-simplifycfg,licm,loop-rotate,licm,simple-loop-unswitch),simplifycfg,instcombine,loop(loop-idiom,indvars,simple-loop-unswitch,loop-deletion,loop-unroll-full),sroa,vector-combine,mldst-motion,gvn<>,sccp,bdce,instcombine,jump-threading,correlated-propagation,adce,memcpyopt,dse,move-auto-init,loop-mssa(licm),coro-elide,simplifycfg,instcombine),function-attrs,function(require),coro-split,coro-annotation-elide))\" on module \"extra/gc.c\"\r\n5.\tRunning pass \"instcombine\" on function \"GC_push_finalizer_structures\"\r\n #0 0x0000000112ecda98 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x3299a98)\r\n #1 0x0000000112eccb47 llvm::sys::RunSignalHandlers() (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x3298b47)\r\n #2 0x0000000112eccde1 llvm::sys::CleanupOnSignal(unsigned long) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x3298de1)\r\n #3 0x0000000112df2644 CrashRecoverySignalHandler(int) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x31be644)\r\n #4 0x00007ff81abe4fdd (/usr/lib/system/libsystem_platform.dylib+0x7ff80046afdd)\r\n #5 0x0000000112e1d131 computeForAddCarry(llvm::KnownBits const&, llvm::KnownBits const&, bool, bool) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x31e9131)\r\n #6 0x0000000112318cdd llvm::TargetFolder::FoldGEP(llvm::Type*, llvm::Value*, llvm::ArrayRef, llvm::GEPNoWrapFlags) const (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x26e4cdd)\r\n #7 0x00000001102d2177 llvm::IRBuilderBase::CreateGEP(llvm::Type*, llvm::Value*, llvm::ArrayRef, llvm::Twine const&, llvm::GEPNoWrapFlags) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x69e177)\r\n #8 0x000000011209545a llvm::InstCombinerImpl::SimplifyDemandedUseBits(llvm::Instruction*, llvm::APInt const&, llvm::KnownBits&, unsigned int, llvm::SimplifyQuery const&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x246145a)\r\n #9 0x0000000112097524 llvm::InstCombinerImpl::SimplifyDemandedInstructionBits(llvm::Instruction&, llvm::KnownBits&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x2463524)\r\n#10 0x0000000111ffc58b llvm::InstCombinerImpl::visitCallInst(llvm::CallInst&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x23c858b)\r\n#11 0x0000000111f85788 llvm::InstCombinerImpl::run() (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x2351788)\r\n#12 0x0000000111f765e2 combineInstructionsOverFunction(llvm::Function&, llvm::InstructionWorklist&, llvm::AAResults*, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::BranchProbabilityInfo*, llvm::ProfileSummaryInfo*, llvm::InstCombineOptions const&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x23425e2)\r\n#13 0x0000000111fc1b85 llvm::InstCombinePass::run(llvm::Function&, llvm::AnalysisManager&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x238db85)\r\n#14 0x0000000110596272 llvm::detail::PassModel>::run(llvm::Function&, llvm::AnalysisManager&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x962272)\r\n#15 0x0000000112b6736a llvm::PassManager>::run(llvm::Function&, llvm::AnalysisManager&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x2f3336a)\r\n#16 0x000000011003f522 llvm::detail::PassModel>, llvm::AnalysisManager>::run(llvm::Function&, llvm::AnalysisManager&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x40b522)\r\n#17 0x00000001122fe7db llvm::CGSCCToFunctionPassAdaptor::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x26ca7db)\r\n#18 0x0000000110b41712 llvm::detail::PassModel, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0xf0d712)\r\n#19 0x00000001122fa573 llvm::PassManager, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x26c6573)\r\n#20 0x0000000110b3e332 llvm::detail::PassModel, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>, llvm::AnalysisManager, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0xf0a332)\r\n#21 0x00000001122fcc0e llvm::DevirtSCCRepeatedPass::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x26c8c0e)\r\n#22 0x0000000110b413a2 llvm::detail::PassModel, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0xf0d3a2)\r\n#23 0x00000001122fbe83 llvm::ModuleToPostOrderCGSCCPassAdaptor::run(llvm::Module&, llvm::AnalysisManager&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x26c7e83)\r\n#24 0x0000000110b3e012 llvm::detail::PassModel>::run(llvm::Module&, llvm::AnalysisManager&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0xf0a012)\r\n#25 0x0000000112b65a22 llvm::PassManager>::run(llvm::Module&, llvm::AnalysisManager&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x2f31a22)\r\n#26 0x0000000110d25d8b llvm::ModuleInlinerWrapperPass::run(llvm::Module&, llvm::AnalysisManager&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x10f1d8b)\r\n#27 0x0000000110594012 llvm::detail::PassModel>::run(llvm::Module&, llvm::AnalysisManager&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x960012)\r\n#28 0x0000000112b65a22 llvm::PassManager>::run(llvm::Module&, llvm::AnalysisManager&) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x2f31a22)\r\n#29 0x000000010788b478 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::__1::unique_ptr>&, std::__1::unique_ptr>&, clang::BackendConsumer*) (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x172d478)\r\n#30 0x0000000107883b08 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr, std::__1::unique_ptr>, clang::BackendConsumer*) (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x1725b08)\r\n#31 0x0000000107d037d3 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x1ba57d3)\r\n#32 0x000000010635df1d clang::ParseAST(clang::Sema&, bool, bool) (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x1fff1d)\r\n#33 0x000000010877f3d7 clang::FrontendAction::Execute() (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x26213d7)\r\n#34 0x00000001086e0500 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x2582500)\r\n#35 0x00000001087f60e9 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x26980e9)\r\n#36 0x000000010128d4f9 cc1_main(llvm::ArrayRef, char const*, void*) (/opt/llvm-project@HEAD/bin/clang-20+0x1000084f9)\r\n#37 0x0000000101289f88 ExecuteCC1Tool(llvm::SmallVectorImpl&, llvm::ToolContext const&) (/opt/llvm-project@HEAD/bin/clang-20+0x100004f88)\r\n#38 0x00000001082b552e void llvm::function_ref::callback_fn>, std::__1::basic_string, std::__1::allocator>*, bool*) const::$_0>(long) (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x215752e)\r\n#39 0x0000000112df288c llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) (/opt/llvm-project@HEAD/lib/libLLVM.dylib+0x31be88c)\r\n#40 0x00000001082b5431 clang::driver::CC1Command::Execute(llvm::ArrayRef>, std::__1::basic_string, std::__1::allocator>*, bool*) const (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x2157431)\r\n#41 0x0000000108262131 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x2104131)\r\n#42 0x00000001082623bf clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl>&, bool) const (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x21043bf)\r\n#43 0x00000001082b00c0 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl>&) (/opt/llvm-project@HEAD/lib/libclang-cpp.dylib+0x21520c0)\r\n#44 0x00000001012892b3 clang_main(int, char**, llvm::ToolContext const&) (/opt/llvm-project@HEAD/bin/clang-20+0x1000042b3)\r\n#45 0x00000001012984cb main (/opt/llvm-project@HEAD/bin/clang-20+0x1000134cb)\r\n#46 0x00007ff81a82a345 \r\nclang: error: clang frontend command failed with exit code 139 (use -v to see invocation)\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git c25c6c32494c8d1038438b6208d42ba40f25270e)\r\nTarget: x86_64-apple-darwin23.6.0\r\nThread model: posix\r\nInstalledDir: /opt/llvm-project@HEAD/bin\r\nclang: note: diagnostic msg: \r\n********************\r\n```\r\n\r\nFind attached the preprocessed source code at [gc-add69e.c.gz](https://github.com/user-attachments/files/17813033/gc-add69e.c.gz).", "author": "d125q", "labels": ["llvm:instcombine", "crash-on-valid"], "comments": [{"author": "dtcxzyw", "body": "Reproducer: https://godbolt.org/z/Ts478aen6\r\n```\r\n; bin/opt -passes=instcombine test.ll -S\r\n@GC_arrays = external global { i8, i8, i64 }\r\n\r\ndefine ptr @GC_push_finalizer_structures() {\r\nentry:\r\n %aligned_result.i = call ptr @llvm.ptrmask.p0.i64(ptr getelementptr inbounds (i8, ptr @GC_arrays, i64 1), i64 -8)\r\n ret ptr %aligned_result.i\r\n}\r\n```\r\n```\r\nopt: /root/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From*) [with To = llvm::GetElementPtrInst; From = llvm::Value]: Assertion `isa(Val) && \"cast() argument of incompatible type!\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=instcombine \r\n1.\tRunning pass \"function(instcombine)\" on module \"\"\r\n2.\tRunning pass \"instcombine\" on function \"GC_push_finalizer_structures\"\r\n #0 0x0000000005194b38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5194b38)\r\n #1 0x000000000519252c SignalHandler(int) Signals.cpp:0:0\r\n #2 0x000074b7d8442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x000074b7d84969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x000074b7d8442476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x000074b7d84287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x000074b7d842871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x000074b7d8439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x00000000040d9310 decltype(auto) llvm::cast(llvm::Value*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40d9310)\r\n #9 0x00000000040e2f9e llvm::InstCombinerImpl::SimplifyDemandedUseBits(llvm::Instruction*, llvm::APInt const&, llvm::KnownBits&, unsigned int, llvm::SimplifyQuery const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40e2f9e)\r\n#10 0x00000000040e6082 llvm::InstCombinerImpl::SimplifyDemandedInstructionBits(llvm::Instruction&, llvm::KnownBits&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40e6082)\r\n#11 0x00000000040355a6 llvm::InstCombinerImpl::visitCallInst(llvm::CallInst&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40355a6)\r\n#12 0x0000000003fe2311 llvm::InstCombinerImpl::run() (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3fe2311)\r\n#13 0x0000000003fe3cc6 combineInstructionsOverFunction(llvm::Function&, llvm::InstructionWorklist&, llvm::AAResults*, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::BranchProbabilityInfo*, llvm::ProfileSummaryInfo*, llvm::InstCombineOptions const&) (.isra.0) InstructionCombining.cpp:0:0\r\n#14 0x0000000003fe504e llvm::InstCombinePass::run(llvm::Function&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3fe504e)\r\n#15 0x0000000002c5c24e llvm::detail::PassModel>::run(llvm::Function&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2c5c24e)\r\n#16 0x0000000004f949e8 llvm::PassManager>::run(llvm::Function&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f949e8)\r\n#17 0x0000000000e4027e llvm::detail::PassModel>, llvm::AnalysisManager>::run(llvm::Function&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe4027e)\r\n#18 0x0000000004f9340e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f9340e)\r\n#19 0x0000000000e3f92e llvm::detail::PassModel>::run(llvm::Module&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe3f92e)\r\n#20 0x0000000004f92e40 llvm::PassManager>::run(llvm::Module&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f92e40)\r\n#21 0x0000000000909fda llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef, llvm::ArrayRef>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x909fda)\r\n#22 0x00000000008fc70a optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8fc70a)\r\n#23 0x000074b7d8429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#24 0x000074b7d8429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#25 0x00000000008f3e9e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8f3e9e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```"}]}, "verified": true} @@ -76,6 +77,7 @@ {"bug_id": "97452", "issue_url": "https://github.com/llvm/llvm-project/issues/97452", "bug_type": "crash", "base_commit": "5c204b1d2619cbad7b7ad228b62feae08781a6db", "knowledge_cutoff": "2024-07-02T17:49:01Z", "lit_test_dir": ["llvm/test/Transforms/LoopVectorize"], "hints": {"fix_commit": "2b3b405b09a0d965a4aff1f92958418ddbf1e7f6", "components": ["LoopVectorize"], "bug_location_lineno": {"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [[6813, 6818]]}, "bug_location_funcname": {"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": ["LoopVectorizationCostModel::getInstructionCost"]}}, "patch": "commit 2b3b405b09a0d965a4aff1f92958418ddbf1e7f6\nAuthor: Florian Hahn \nDate: Thu Jul 4 11:44:50 2024 +0100\n\n [LV] Don't vectorize first-order recurrence with VF \n \n The assertion added as part of https://github.com/llvm/llvm-project/pull/93395\n surfaced cases where first-order recurrences are vectorized with\n . If vscale is 1, then we are unable to extract the\n penultimate value (second to last lane). Previously this case got\n mis-compiled, trying to extract from an invalid lane (-1)\n https://llvm.godbolt.org/z/3adzYYcf9.\n \n Fixes https://github.com/llvm/llvm-project/issues/97452.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\nindex f9c0c66e6e0a..d7b0240fd8a8 100644\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n@@ -6813,6 +6813,11 @@ LoopVectorizationCostModel::getInstructionCost(Instruction *I, ElementCount VF,\n \n // First-order recurrences are replaced by vector shuffles inside the loop.\n if (VF.isVector() && Legal->isFixedOrderRecurrence(Phi)) {\n+ // For , if vscale = 1 we are unable to extract the\n+ // penultimate value of the recurrence.\n+ // TODO: Consider vscale_range info.\n+ if (VF.isScalable() && VF.getKnownMinValue() == 1)\n+ return InstructionCost::getInvalid();\n SmallVector Mask(VF.getKnownMinValue());\n std::iota(Mask.begin(), Mask.end(), VF.getKnownMinValue() - 1);\n return TTI.getShuffleCost(TargetTransformInfo::SK_Splice,\n", "tests": [{"file": "llvm/test/Transforms/LoopVectorize/RISCV/first-order-recurrence-scalable-vf1.ll", "commands": ["opt -p loop-vectorize -S %s"], "tests": [{"test_name": "", "test_body": "\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\n; Make sure we do not pick as VF for a loop with a\n; first-order recurrence.\ndefine i64 @pr97452_scalable_vf1_for(ptr %src) #0 {\n;\nentry:\n br label %loop\n\nloop:\n %for = phi i64 [ 0, %entry ], [ %l, %loop ]\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.next = add i64 %iv, 1\n %gep = getelementptr inbounds i64, ptr %src, i64 %iv\n %l = load i64, ptr %gep, align 8\n %ec = icmp eq i64 %iv, 22\n br i1 %ec, label %exit, label %loop\n\nexit:\n %res = phi i64 [ %for, %loop ]\n ret i64 %res\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v,+zvl128b,+zvl256b\" }\n;.\n;."}]}, {"file": "llvm/test/Transforms/LoopVectorize/first-order-recurrence-scalable-vf1.ll", "commands": ["opt -p loop-vectorize -scalable-vectorization=on -force-vector-width=1 -force-target-supports-scalable-vectors=true -S %s"], "tests": [{"test_name": "", "test_body": "\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\n\ndefine i64 @pr97452_scalable_vf1_for_live_out(ptr %src) {\n;\nentry:\n br label %loop\n\nloop:\n %for = phi i64 [ 0, %entry ], [ %l, %loop ]\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.next = add i64 %iv, 1\n %gep = getelementptr inbounds i64, ptr %src, i64 %iv\n %l = load i64, ptr %gep, align 8\n %ec = icmp eq i64 %iv, 22\n br i1 %ec, label %exit, label %loop\n\nexit:\n %res = phi i64 [ %for, %loop ]\n ret i64 %res\n}\n\n\ndefine void @pr97452_scalable_vf1_for_no_live_out(ptr %src, ptr noalias %dst) {\n;\nentry:\n br label %loop\n\nloop:\n %for = phi i64 [ 0, %entry ], [ %l, %loop ]\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.next = add i64 %iv, 1\n %gep = getelementptr inbounds i64, ptr %src, i64 %iv\n %l = load i64, ptr %gep, align 8\n %gep.dst = getelementptr inbounds i64, ptr %dst, i64 %iv\n store i64 %l, ptr %gep.dst\n %ec = icmp eq i64 %iv, 22\n br i1 %ec, label %exit, label %loop\n\nexit:\n ret void\n}"}]}], "issue": {"title": "[LoopVectorize] Assertion `Offset <= State.VF.getKnownMinValue() && \"invalid offset to extract from\"' failed.", "body": "Reduced testcase:\r\n```llvm ir\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine i32 @main() #0 {\r\nentry:\r\n br label %for.body\r\n\r\nfor.cond.cleanup: ; preds = %for.body\r\n %.lcssa17 = phi i64 [ %0, %for.body ]\r\n ret i32 0\r\n\r\nfor.body: ; preds = %for.body, %entry\r\n %0 = phi i64 [ 0, %entry ], [ %1, %for.body ]\r\n %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]\r\n %indvars.iv.next = add i64 %indvars.iv, 1\r\n %1 = load i64, ptr null, align 8\r\n %exitcond.not = icmp eq i64 %indvars.iv, 22\r\n br i1 %exitcond.not, label %for.cond.cleanup, label %for.body\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+v,+zvl128b,+zvl256b\" }\r\n```\r\n\r\nCommand/backtrace:\r\n```bash\r\n> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize reduced.ll\r\nWARNING: You're attempting to print out a bitcode file.\r\nThis is inadvisable as it may cause display problems. If\r\nyou REALLY want to taste LLVM bitcode first-hand, you\r\ncan force output with the `-f' option.\r\n\r\nopt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp:569: llvm::Value* llvm::VPInstruction::generatePerPart(llvm::VPTransformState&, unsigned int): Assertion `Offset <= State.VF.getKnownMinValue() && \"invalid offset to extract from\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize reduced.ll\r\n1. Running pass \"function(loop-vectorize)\" on module \"reduced.ll\"\r\n2. Running pass \"loop-vectorize\" on function \"main\"\r\n #0 0x000055972ae01800 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2ed2800)\r\n #1 0x000055972adfec0f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2ecfc0f)\r\n #2 0x000055972adfed65 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x0000728161442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007281614969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007281614969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007281614969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x0000728161442476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007281614287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x000072816142871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x0000728161439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x0000559729f62d80 llvm::VPInstruction::generatePerPart(llvm::VPTransformState&, unsigned int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2033d80)\r\n#12 0x0000559729f63155 llvm::VPInstruction::execute(llvm::VPTransformState&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2034155)\r\n#13 0x0000559729f2de47 llvm::VPBasicBlock::executeRecipes(llvm::VPTransformState*, llvm::BasicBlock*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1ffee47)\r\n#14 0x0000559729f2e141 llvm::VPIRBasicBlock::execute(llvm::VPTransformState*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1fff141)\r\n#15 0x0000559729f30286 llvm::VPlan::execute(llvm::VPTransformState*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2001286)\r\n#16 0x0000559729e2380a llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool, llvm::DenseMap, llvm::detail::DenseMapPair> const*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1ef480a)\r\n#17 0x0000559729e34a7c llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f05a7c)\r\n#18 0x0000559729e36f7e llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f07f7e)\r\n#19 0x0000559729e380a0 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f090a0)\r\n#20 0x0000559728cc6dc6 llvm::detail::PassModel>::run(llvm::Function&, llvm::AnalysisManager&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xd97dc6)\r\n#21 0x000055972ac1ce46 llvm::PassManager>::run(llvm::Function&, llvm::AnalysisManager&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2cede46)\r\n#22 0x0000559728cc9f56 llvm::detail::PassModel>, llvm::AnalysisManager>::run(llvm::Function&, llvm::AnalysisManager&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xd9af56)\r\n#23 0x000055972ac1bbcb llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2cecbcb)\r\n#24 0x0000559728cc6526 llvm::detail::PassModel>::run(llvm::Module&, llvm::AnalysisManager&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xd97526)\r\n#25 0x000055972ac19d02 llvm::PassManager>::run(llvm::Module&, llvm::AnalysisManager&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2cead02)\r\n#26 0x0000559728520136 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef, llvm::ArrayRef>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x5f1136)\r\n#27 0x0000559728511d51 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x5e2d51)\r\n#28 0x0000728161429d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#29 0x0000728161429e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#30 0x0000728161429e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#31 0x0000559728507b85 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x5d8b85)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\nGodbolt: https://godbolt.org/z/ojz8sMa1r\r\n\r\nFound via fuzzer", "author": "patrick-rivos", "labels": ["vectorizers", "crash"], "comments": [{"author": "svs-quic", "body": "Bisected to #93395 \r\ncc: @fhahn "}, {"author": "fhahn", "body": "Thanks for the test case. Should be fixed now. The assertion highlighted a case where we previously miscompiled for the case where VF is ; in that case we are unable to extract the penultimate value (second-to-last) if vscale = 1"}]}, "verified": true} {"bug_id": "102597", "issue_url": "https://github.com/llvm/llvm-project/issues/102597", "bug_type": "miscompilation", "base_commit": "513c3726ebc0a324f7e5a11d25617bb9557324d6", "knowledge_cutoff": "2024-08-09T11:02:59Z", "lit_test_dir": ["llvm/test/Transforms/IndVarSimplify"], "hints": {"fix_commit": "3512bcc2e9ab06b0ae2cab78744550b515e54184", "components": ["ScalarEvolution"], "bug_location_lineno": {"llvm/lib/Analysis/ScalarEvolution.cpp": [[11961, 11969]]}, "bug_location_funcname": {"llvm/lib/Analysis/ScalarEvolution.cpp": ["ScalarEvolution::computeConstantDifference"]}}, "patch": "commit 3512bcc2e9ab06b0ae2cab78744550b515e54184\nAuthor: Nikita Popov \nDate: Mon Aug 12 15:18:32 2024 +0200\n\n [SCEV] Fix incorrect extension in computeConstantDifference()\n \n The Mul factor was zero-extended here, resulting in incorrect\n results for integers larger than 64-bit.\n \n As we currently only multiply by 1 or -1, just split this into\n two cases -- there's no need for a full multiplication here.\n \n Fixes https://github.com/llvm/llvm-project/issues/102597.\n\ndiff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp\nindex 9ecdcbe2c5de..318a9d773dc2 100644\n--- a/llvm/lib/Analysis/ScalarEvolution.cpp\n+++ b/llvm/lib/Analysis/ScalarEvolution.cpp\n@@ -11961,9 +11961,14 @@ ScalarEvolution::computeConstantDifference(const SCEV *More, const SCEV *Less) {\n SmallDenseMap Multiplicity;\n APInt Diff(BW, 0);\n auto Add = [&](const SCEV *S, int Mul) {\n- if (auto *C = dyn_cast(S))\n- Diff += C->getAPInt() * Mul;\n- else\n+ if (auto *C = dyn_cast(S)) {\n+ if (Mul == 1) {\n+ Diff += C->getAPInt();\n+ } else {\n+ assert(Mul == -1);\n+ Diff -= C->getAPInt();\n+ }\n+ } else\n Multiplicity[S] += Mul;\n };\n auto Decompose = [&](const SCEV *S, int Mul) {\n", "tests": [{"file": "llvm/test/Transforms/IndVarSimplify/pr102597.ll", "commands": ["opt -S -passes=indvars < %s"], "tests": [{"test_name": "test", "test_body": "define void @test() {\nentry:\n br label %loop\n\nloop: ; preds = %loop.latch, %entry\n %iv = phi i128 [ 3, %entry ], [ %iv.dec, %loop.latch ]\n %tobool = icmp ne i128 %iv, 0\n br i1 %tobool, label %loop.latch, label %if\n\nif: ; preds = %loop\n call void @foo()\n br label %loop.latch\n\nloop.latch: ; preds = %if, %loop\n %iv.dec = add nsw i128 %iv, -1\n %cmp = icmp sgt i128 %iv, 0\n br i1 %cmp, label %loop, label %exit\n\nexit: ; preds = %loop.latch\n ret void\n}\n\ndeclare void @foo()\n", "additional_args": "-src-unroll=4 -tgt-unroll=4"}]}], "issue": {"title": "[SCEV] WRONG code ", "body": "```\r\nint printf(const char *, ...);\r\n__int128 a = 3, c;\r\nchar b;\r\nint main() {\r\n c = 3;\r\n for (; c >= 0; c--) {\r\n b = 0;\r\n for (; b <= 3; b++) {\r\n if (c)\r\n break;\r\n a = 0;\r\n }\r\n }\r\n printf(\"%d\\n\", (int)a);\r\n}\r\n\r\n```\r\n\r\nclang -march=z15 -O1 wrong0.i -o a.out\r\n\r\nThis program should print '0' as 'a' is set to zero inside the loop. It now prints '3' instead. A bisect leads to a recent commit: 79af689 \" [SCEV] Handle more adds in computeConstantDifference() (#101339)\".\r\n\r\nSeems like IndVarSimplify has gone wrong with an i128:\r\nGOOD <> BROKEN\r\n```\r\n; *** IR Dump After IndVarSimplifyPass on loo ; *** IR Dump After IndVarSimplifyPass on loo\r\n\r\n; Preheader: ; Preheader:\r\nentry: entry:\r\n br label %for.cond1.preheader br label %for.cond1.preheader\r\n\r\n; Loop: ; Loop:\r\nfor.cond1.preheader: for.cond1.preheader: \r\n %storemerge11 = phi i128 [ 3, %entry ], [ % %storemerge11 = phi i128 [ 3, %entry ], [ %\r\n %tobool = icmp ne i128 %storemerge11, 0 | br i1 true, label %for.inc5, label %if.end.\r\n br i1 %tobool, label %for.inc5, label %if.e <\r\n\r\nif.end.lr.ph: if.end.lr.ph: \r\n store i128 0, ptr @a, align 8, !tbaa !4 store i128 0, ptr @a, align 8, !tbaa !4\r\n br label %if.end br label %if.end\r\n\r\nif.end: if.end: \r\n %storemerge89 = phi i8 [ 0, %if.end.lr.ph ] %storemerge89 = phi i8 [ 0, %if.end.lr.ph ]\r\n %inc = add nuw nsw i8 %storemerge89, 1 %inc = add nuw nsw i8 %storemerge89, 1\r\n %cmp2 = icmp ugt i8 %storemerge89, 2 %cmp2 = icmp ugt i8 %storemerge89, 2\r\n %or.cond = or i1 %tobool, %cmp2 | %or.cond = or i1 true, %cmp2\r\n br i1 %or.cond, label %for.inc5.loopexit, l br i1 %or.cond, label %for.inc5.loopexit, l\r\n\r\nfor.inc5: for.inc5: \r\n %storemerge8.lcssa = phi i8 [ 0, %for.cond1 %storemerge8.lcssa = phi i8 [ 0, %for.cond1\r\n %dec = add nsw i128 %storemerge11, -1 %dec = add nsw i128 %storemerge11, -1\r\n %cmp = icmp ugt i128 %storemerge11, 0 %cmp = icmp ugt i128 %storemerge11, 0\r\n br i1 %cmp, label %for.cond1.preheader, lab br i1 %cmp, label %for.cond1.preheader, lab\r\n\r\nfor.inc5.loopexit: for.inc5.loopexit: \r\n %inc.lcssa = phi i8 [ %inc, %if.end ] %inc.lcssa = phi i8 [ %inc, %if.end ]\r\n br label %for.inc5 br label %for.inc5\r\n\r\n; Exit blocks ; Exit blocks\r\nfor.end6: for.end6: \r\n %storemerge8.lcssa.lcssa = phi i8 [ %storem %storemerge8.lcssa.lcssa = phi i8 [ %storem\r\n store i128 -1, ptr @c, align 8, !tbaa !4 store i128 -1, ptr @c, align 8, !tbaa !4\r\n store i8 %storemerge8.lcssa.lcssa, ptr @b, store i8 %storemerge8.lcssa.lcssa, ptr @b, \r\n %0 = load i128, ptr @a, align 8, !tbaa !4 %0 = load i128, ptr @a, align 8, !tbaa !4\r\n %conv7 = trunc i128 %0 to i32 %conv7 = trunc i128 %0 to i32\r\n %call = call signext i32 (ptr, ...) @printf %call = call signext i32 (ptr, ...) @printf\r\n ret i32 0 ret i32 0\r\n\r\n```", "author": "JonPsson1", "labels": ["miscompilation", "llvm:SCEV"], "comments": [{"author": "nikic", "body": "Classic mistake: https://github.com/llvm/llvm-project/blob/2f8f58dd17a11934e8c8ec212b6474f76fb18e61/llvm/lib/Analysis/ScalarEvolution.cpp#L11967 This `* Mul` doesn't do what I wanted it to do :)\r\n\r\nI should really pick up https://github.com/llvm/llvm-project/pull/80309 again to prevent this kind of mistake in the first place."}, {"author": "JonPsson1", "body": "Is this commit self-contained in the sense that I could revert it on my testing machines? Or will you revert / fix soon?"}]}, "verified": true} {"bug_id": "108698", "issue_url": "https://github.com/llvm/llvm-project/issues/108698", "bug_type": "miscompilation", "base_commit": "ba8e4246e2f17030788e8a4954bf5c290332206f", "knowledge_cutoff": "2024-09-14T13:16:53Z", "lit_test_dir": ["llvm/test/Transforms/VectorCombine"], "hints": {"fix_commit": "87663fdab9d0e7bcc0b963ea078da9e2eb574908", "components": ["VectorCombine"], "bug_location_lineno": {"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [[2597, 2607], [2628, 2634]]}, "bug_location_funcname": {"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": ["VectorCombine::shrinkType"]}}, "patch": "commit 87663fdab9d0e7bcc0b963ea078da9e2eb574908\nAuthor: Yingwei Zheng \nDate: Sun Sep 15 18:38:06 2024 +0800\n\n [VectorCombine] Don't shrink lshr if the shamt is not less than bitwidth (#108705)\n \n Consider the following case:\n ```\n define <2 x i32> @test(<2 x i64> %vec.ind16, <2 x i32> %broadcast.splat20) {\n %19 = icmp eq <2 x i64> %vec.ind16, zeroinitializer\n %20 = zext <2 x i1> %19 to <2 x i32>\n %21 = lshr <2 x i32> %20, %broadcast.splat20\n ret <2 x i32> %21\n }\n ```\n After https://github.com/llvm/llvm-project/pull/104606, we shrink the\n lshr into:\n ```\n define <2 x i32> @test(<2 x i64> %vec.ind16, <2 x i32> %broadcast.splat20) {\n %1 = icmp eq <2 x i64> %vec.ind16, zeroinitializer\n %2 = trunc <2 x i32> %broadcast.splat20 to <2 x i1>\n %3 = lshr <2 x i1> %1, %2\n %4 = zext <2 x i1> %3 to <2 x i32>\n ret <2 x i32> %4\n }\n ```\n It is incorrect since `lshr i1 X, 1` returns `poison`.\n This patch adds additional check on the shamt operand. The lshr will get\n shrunk iff we ensure that the shamt is less than bitwidth of the smaller\n type. As `computeKnownBits(&I, *DL).countMaxActiveBits() > BW` always\n evaluates to true for `lshr(zext(X), Y)`, this check will only apply to\n bitwise logical instructions.\n \n Alive2: https://alive2.llvm.org/ce/z/j_RmTa\n Fixes https://github.com/llvm/llvm-project/issues/108698.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp\nindex d7afe2f426d3..58701bfa60a3 100644\n--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp\n+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp\n@@ -2597,11 +2597,19 @@ bool VectorCombine::shrinkType(llvm::Instruction &I) {\n auto *SmallTy = cast(ZExted->getType());\n unsigned BW = SmallTy->getElementType()->getPrimitiveSizeInBits();\n \n- // Check that the expression overall uses at most the same number of bits as\n- // ZExted\n- KnownBits KB = computeKnownBits(&I, *DL);\n- if (KB.countMaxActiveBits() > BW)\n- return false;\n+ if (I.getOpcode() == Instruction::LShr) {\n+ // Check that the shift amount is less than the number of bits in the\n+ // smaller type. Otherwise, the smaller lshr will return a poison value.\n+ KnownBits ShAmtKB = computeKnownBits(I.getOperand(1), *DL);\n+ if (ShAmtKB.getMaxValue().uge(BW))\n+ return false;\n+ } else {\n+ // Check that the expression overall uses at most the same number of bits as\n+ // ZExted\n+ KnownBits KB = computeKnownBits(&I, *DL);\n+ if (KB.countMaxActiveBits() > BW)\n+ return false;\n+ }\n \n // Calculate costs of leaving current IR as it is and moving ZExt operation\n // later, along with adding truncates if needed\n@@ -2628,7 +2636,7 @@ bool VectorCombine::shrinkType(llvm::Instruction &I) {\n return false;\n \n // Check if we can propagate ZExt through its other users\n- KB = computeKnownBits(UI, *DL);\n+ KnownBits KB = computeKnownBits(UI, *DL);\n if (KB.countMaxActiveBits() > BW)\n return false;\n \n", "tests": [{"file": "llvm/test/Transforms/VectorCombine/AArch64/shrink-types.ll", "commands": ["opt -passes=vector-combine -S %s"], "tests": [{"test_name": "pr108698", "test_body": "target triple = \"aarch64\"\n\ndefine <2 x i32> @pr108698(<2 x i64> %x, <2 x i32> %y) {\n %cmp = icmp eq <2 x i64> %x, zeroinitializer\n %ext = zext <2 x i1> %cmp to <2 x i32>\n %lshr = lshr <2 x i32> %ext, %y\n ret <2 x i32> %lshr\n}\n"}]}], "issue": {"title": "wrong code at -O{2,3} on x86_64-linux-gnu", "body": "It appears to be a recent regression as it doesn't reproduce with 18.1.0 and earlier. \r\n\r\nCompiler Explorer: https://godbolt.org/z/EGasYh8x1\r\n\r\n```\r\n[691] % clangtk -v\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git 223e2efa5e886502a9467b7ef700ebce9b7886e8)\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[692] % \r\n[692] % clangtk -O1 small.c; ./a.out\r\n[693] % \r\n[693] % clangtk -O2 small.c\r\n[694] % ./a.out\r\nAborted\r\n[695] % \r\n[695] % cat small.c\r\nchar a[8];\r\nint b = 1, c;\r\nint main() {\r\n for (; c < 8; c++)\r\n a[c] = !c >> b;\r\n if (a[0] != 0)\r\n __builtin_abort();\r\n return 0;\r\n}\r\n```", "author": "zhendongsu", "labels": ["miscompilation", "vectorizers"], "comments": [{"author": "dtcxzyw", "body": "Reproducer: https://alive2.llvm.org/ce/z/5SkPZS\r\n```\r\n; bin/opt -passes=vector-combine test.ll -S\r\n\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\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine <2 x i32> @test(<2 x i64> %vec.ind16, <2 x i32> %broadcast.splat20) {\r\n %19 = icmp eq <2 x i64> %vec.ind16, zeroinitializer\r\n %20 = zext <2 x i1> %19 to <2 x i32>\r\n %21 = lshr <2 x i32> %20, %broadcast.splat20\r\n ret <2 x i32> %21\r\n}\r\n```\r\n```\r\ndefine <2 x i32> @test(<2 x i64> %vec.ind16, <2 x i32> %broadcast.splat20) {\r\n %1 = icmp eq <2 x i64> %vec.ind16, zeroinitializer\r\n %2 = trunc <2 x i32> %broadcast.splat20 to <2 x i1>\r\n %3 = lshr <2 x i1> %1, %2\r\n %4 = zext <2 x i1> %3 to <2 x i32>\r\n ret <2 x i32> %4\r\n}\r\n```"}, {"author": "dtcxzyw", "body": "Related PR: https://github.com/llvm/llvm-project/pull/104606\r\n"}]}, "verified": true} +{"bug_id": "130250", "issue_url": "https://github.com/llvm/llvm-project/issues/130250", "bug_type": "crash", "base_commit": "3ed4daf9a749fe8590ad291f63fabce48fb4135f", "knowledge_cutoff": "2025-03-07T05:51:40Z", "lit_test_dir": ["llvm/test/Transforms/PhaseOrdering", "llvm/test/Transforms/VectorCombine"], "hints": {"fix_commit": "0ee8f699780569d7a6b94d61cd833285bb67eca1", "components": ["VectorCombine"], "bug_location_lineno": {"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [[2037, 2043], [2051, 2074]]}, "bug_location_funcname": {"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": ["VectorCombine::foldShuffleOfSelects"]}}, "patch": "commit 0ee8f699780569d7a6b94d61cd833285bb67eca1\nAuthor: hanbeom \nDate: Sat Mar 8 01:40:26 2025 +0900\n\n [VectorCombine] Fix invalid shuffle cost argument of foldShuffleOfSelects (#130281)\n \n In the previous code (#128032), it specified the destination vector as the\n getShuffleCost argument. Because the shuffle mask specifies the indices\n of the two vectors specified as elements, the maximum value is twice the\n size of the source vector. This causes a problem if the destination\n vector is smaller than the source vector and specify an index in the\n mask that exceeds the size of the destination vector.\n \n Fix the problem by correcting the previous code, which was using wrong\n argument in the Cost calculation.\n \n Fixes #130250\n\ndiff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp\nindex 4d4a1a6e04d3..019d79567b4a 100644\n--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp\n+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp\n@@ -2037,7 +2037,6 @@ bool VectorCombine::foldShuffleOfSelects(Instruction &I) {\n m_Mask(Mask))))\n return false;\n \n- auto *DstVecTy = dyn_cast(I.getType());\n auto *C1VecTy = dyn_cast(C1->getType());\n auto *C2VecTy = dyn_cast(C2->getType());\n if (!C1VecTy || !C2VecTy || C1VecTy != C2VecTy)\n@@ -2051,24 +2050,26 @@ bool VectorCombine::foldShuffleOfSelects(Instruction &I) {\n (SI0FOp->getFastMathFlags() != SI1FOp->getFastMathFlags())))\n return false;\n \n+ auto *SrcVecTy = dyn_cast(T1->getType());\n+ auto *DstVecTy = dyn_cast(I.getType());\n auto SK = TargetTransformInfo::SK_PermuteTwoSrc;\n auto SelOp = Instruction::Select;\n InstructionCost OldCost = TTI.getCmpSelInstrCost(\n- SelOp, T1->getType(), C1VecTy, CmpInst::BAD_ICMP_PREDICATE, CostKind);\n- OldCost += TTI.getCmpSelInstrCost(SelOp, T2->getType(), C2VecTy,\n+ SelOp, SrcVecTy, C1VecTy, CmpInst::BAD_ICMP_PREDICATE, CostKind);\n+ OldCost += TTI.getCmpSelInstrCost(SelOp, SrcVecTy, C2VecTy,\n CmpInst::BAD_ICMP_PREDICATE, CostKind);\n- OldCost += TTI.getShuffleCost(SK, DstVecTy, Mask, CostKind, 0, nullptr,\n+ OldCost += TTI.getShuffleCost(SK, SrcVecTy, Mask, CostKind, 0, nullptr,\n {I.getOperand(0), I.getOperand(1)}, &I);\n \n- auto *C1C2VecTy = cast(\n- toVectorTy(Type::getInt1Ty(I.getContext()), DstVecTy->getNumElements()));\n InstructionCost NewCost =\n- TTI.getShuffleCost(SK, C1C2VecTy, Mask, CostKind, 0, nullptr, {C1, C2});\n+ TTI.getShuffleCost(SK, C1VecTy, Mask, CostKind, 0, nullptr, {C1, C2});\n NewCost +=\n- TTI.getShuffleCost(SK, DstVecTy, Mask, CostKind, 0, nullptr, {T1, T2});\n+ TTI.getShuffleCost(SK, SrcVecTy, Mask, CostKind, 0, nullptr, {T1, T2});\n NewCost +=\n- TTI.getShuffleCost(SK, DstVecTy, Mask, CostKind, 0, nullptr, {F1, F2});\n- NewCost += TTI.getCmpSelInstrCost(SelOp, DstVecTy, DstVecTy,\n+ TTI.getShuffleCost(SK, SrcVecTy, Mask, CostKind, 0, nullptr, {F1, F2});\n+ auto *C1C2ShuffledVecTy = cast(\n+ toVectorTy(Type::getInt1Ty(I.getContext()), DstVecTy->getNumElements()));\n+ NewCost += TTI.getCmpSelInstrCost(SelOp, DstVecTy, C1C2ShuffledVecTy,\n CmpInst::BAD_ICMP_PREDICATE, CostKind);\n \n LLVM_DEBUG(dbgs() << \"Found a shuffle feeding two selects: \" << I\n", "tests": [{"file": "llvm/test/Transforms/PhaseOrdering/X86/blendv-select.ll", "commands": ["opt < %s -O3 -S -mtriple=x86_64-- -mcpu=x86-64-v2", "opt < %s -O3 -S -mtriple=x86_64-- -mcpu=x86-64-v3", "opt < %s -O3 -S -mtriple=x86_64-- -mcpu=x86-64-v4"], "tests": [{"test_name": "x86_pblendvb_v8f32_v4f32", "test_body": "define <8 x float> @x86_pblendvb_v8f32_v4f32(<8 x float> %a, <8 x float> %b, <8 x float> %c, <8 x float> %d) {\n %a.bc = bitcast <8 x float> %a to <32 x i8>\n %b.bc = bitcast <8 x float> %b to <32 x i8>\n %a.lo = shufflevector <32 x i8> %a.bc, <32 x i8> poison, <16 x i32> \n %b.lo = shufflevector <32 x i8> %b.bc, <32 x i8> poison, <16 x i32> \n %a.hi = shufflevector <32 x i8> %a.bc, <32 x i8> poison, <16 x i32> \n %b.hi = shufflevector <32 x i8> %b.bc, <32 x i8> poison, <16 x i32> \n %cmp = fcmp olt <8 x float> %c, %d\n %sext = sext <8 x i1> %cmp to <8 x i32>\n %sext.bc = bitcast <8 x i32> %sext to <32 x i8>\n %sext.lo = shufflevector <32 x i8> %sext.bc, <32 x i8> poison, <16 x i32> \n %sext.hi = shufflevector <32 x i8> %sext.bc, <32 x i8> poison, <16 x i32> \n %sel.lo = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %a.lo, <16 x i8> %b.lo, <16 x i8> %sext.lo)\n %sel.hi = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %a.hi, <16 x i8> %b.hi, <16 x i8> %sext.hi)\n %concat = shufflevector <16 x i8> %sel.lo, <16 x i8> %sel.hi, <32 x i32> \n %res = bitcast <32 x i8> %concat to <8 x float>\n ret <8 x float> %res\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)\ndeclare <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8>, <16 x i8>, <16 x i8>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }\n"}, {"test_name": "x86_pblendvb_v32i16_v16i16", "test_body": "define <8 x i64> @x86_pblendvb_v32i16_v16i16(<8 x i64> %a, <8 x i64> %b, <8 x i64> %c, <8 x i64> %d) {\n %a.bc = bitcast <8 x i64> %a to <64 x i8>\n %b.bc = bitcast <8 x i64> %b to <64 x i8>\n %c.bc = bitcast <8 x i64> %c to <32 x i16>\n %d.bc = bitcast <8 x i64> %d to <32 x i16>\n %a.lo = shufflevector <64 x i8> %a.bc, <64 x i8> poison, <32 x i32> \n %b.lo = shufflevector <64 x i8> %b.bc, <64 x i8> poison, <32 x i32> \n %a.hi = shufflevector <64 x i8> %a.bc, <64 x i8> poison, <32 x i32> \n %b.hi = shufflevector <64 x i8> %b.bc, <64 x i8> poison, <32 x i32> \n %cmp = icmp slt <32 x i16> %c.bc, %d.bc\n %sext = sext <32 x i1> %cmp to <32 x i16>\n %sext.bc = bitcast <32 x i16> %sext to <64 x i8>\n %sext.lo = shufflevector <64 x i8> %sext.bc, <64 x i8> poison, <32 x i32> \n %sext.hi = shufflevector <64 x i8> %sext.bc, <64 x i8> poison, <32 x i32> \n %sel.lo = tail call <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8> %a.lo, <32 x i8> %b.lo, <32 x i8> %sext.lo)\n %sel.hi = tail call <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8> %a.hi, <32 x i8> %b.hi, <32 x i8> %sext.hi)\n %concat = shufflevector <32 x i8> %sel.lo, <32 x i8> %sel.hi, <64 x i32> \n %res = bitcast <64 x i8> %concat to <8 x i64>\n ret <8 x i64> %res\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)\ndeclare <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8>, <32 x i8>, <32 x i8>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }\n"}, {"test_name": "x86_pblendvb_v64i8_v32i8", "test_body": "define <8 x i64> @x86_pblendvb_v64i8_v32i8(<8 x i64> %a, <8 x i64> %b, <8 x i64> %c, <8 x i64> %d) {\n %a.bc = bitcast <8 x i64> %a to <64 x i8>\n %b.bc = bitcast <8 x i64> %b to <64 x i8>\n %c.bc = bitcast <8 x i64> %c to <64 x i8>\n %d.bc = bitcast <8 x i64> %d to <64 x i8>\n %a.lo = shufflevector <64 x i8> %a.bc, <64 x i8> poison, <32 x i32> \n %b.lo = shufflevector <64 x i8> %b.bc, <64 x i8> poison, <32 x i32> \n %a.hi = shufflevector <64 x i8> %a.bc, <64 x i8> poison, <32 x i32> \n %b.hi = shufflevector <64 x i8> %b.bc, <64 x i8> poison, <32 x i32> \n %cmp = icmp slt <64 x i8> %c.bc, %d.bc\n %sext = sext <64 x i1> %cmp to <64 x i8>\n %sext.lo = shufflevector <64 x i8> %sext, <64 x i8> poison, <32 x i32> \n %sext.hi = shufflevector <64 x i8> %sext, <64 x i8> poison, <32 x i32> \n %sel.lo = tail call <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8> %a.lo, <32 x i8> %b.lo, <32 x i8> %sext.lo)\n %sel.hi = tail call <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8> %a.hi, <32 x i8> %b.hi, <32 x i8> %sext.hi)\n %concat = shufflevector <32 x i8> %sel.lo, <32 x i8> %sel.hi, <64 x i32> \n %res = bitcast <64 x i8> %concat to <8 x i64>\n ret <8 x i64> %res\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)\ndeclare <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8>, <32 x i8>, <32 x i8>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }\n"}, {"test_name": "x86_pblendvb_v4f64_v2f64", "test_body": "define <4 x double> @x86_pblendvb_v4f64_v2f64(<4 x double> %a, <4 x double> %b, <4 x double> %c, <4 x double> %d) {\n %a.bc = bitcast <4 x double> %a to <32 x i8>\n %b.bc = bitcast <4 x double> %b to <32 x i8>\n %a.lo = shufflevector <32 x i8> %a.bc, <32 x i8> poison, <16 x i32> \n %b.lo = shufflevector <32 x i8> %b.bc, <32 x i8> poison, <16 x i32> \n %a.hi = shufflevector <32 x i8> %a.bc, <32 x i8> poison, <16 x i32> \n %b.hi = shufflevector <32 x i8> %b.bc, <32 x i8> poison, <16 x i32> \n %cmp = fcmp olt <4 x double> %c, %d\n %sext = sext <4 x i1> %cmp to <4 x i64>\n %sext.bc = bitcast <4 x i64> %sext to <32 x i8>\n %sext.lo = shufflevector <32 x i8> %sext.bc, <32 x i8> poison, <16 x i32> \n %sext.hi = shufflevector <32 x i8> %sext.bc, <32 x i8> poison, <16 x i32> \n %sel.lo = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %a.lo, <16 x i8> %b.lo, <16 x i8> %sext.lo)\n %sel.hi = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %a.hi, <16 x i8> %b.hi, <16 x i8> %sext.hi)\n %concat = shufflevector <16 x i8> %sel.lo, <16 x i8> %sel.hi, <32 x i32> \n %res = bitcast <32 x i8> %concat to <4 x double>\n ret <4 x double> %res\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)\ndeclare <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8>, <16 x i8>, <16 x i8>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }\n"}, {"test_name": "x86_pblendvb_v16i16_v8i16", "test_body": "define <4 x i64> @x86_pblendvb_v16i16_v8i16(<4 x i64> %a, <4 x i64> %b, <4 x i64> %c, <4 x i64> %d) {\n %a.bc = bitcast <4 x i64> %a to <32 x i8>\n %b.bc = bitcast <4 x i64> %b to <32 x i8>\n %c.bc = bitcast <4 x i64> %c to <16 x i16>\n %d.bc = bitcast <4 x i64> %d to <16 x i16>\n %a.lo = shufflevector <32 x i8> %a.bc, <32 x i8> poison, <16 x i32> \n %b.lo = shufflevector <32 x i8> %b.bc, <32 x i8> poison, <16 x i32> \n %a.hi = shufflevector <32 x i8> %a.bc, <32 x i8> poison, <16 x i32> \n %b.hi = shufflevector <32 x i8> %b.bc, <32 x i8> poison, <16 x i32> \n %cmp = icmp slt <16 x i16> %c.bc, %d.bc\n %sext = sext <16 x i1> %cmp to <16 x i16>\n %sext.bc = bitcast <16 x i16> %sext to <32 x i8>\n %sext.lo = shufflevector <32 x i8> %sext.bc, <32 x i8> poison, <16 x i32> \n %sext.hi = shufflevector <32 x i8> %sext.bc, <32 x i8> poison, <16 x i32> \n %sel.lo = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %a.lo, <16 x i8> %b.lo, <16 x i8> %sext.lo)\n %sel.hi = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %a.hi, <16 x i8> %b.hi, <16 x i8> %sext.hi)\n %concat = shufflevector <16 x i8> %sel.lo, <16 x i8> %sel.hi, <32 x i32> \n %res = bitcast <32 x i8> %concat to <4 x i64>\n ret <4 x i64> %res\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)\ndeclare <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8>, <16 x i8>, <16 x i8>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }\n"}, {"test_name": "x86_pblendvb_v8i32_v4i32", "test_body": "define <4 x i64> @x86_pblendvb_v8i32_v4i32(<4 x i64> %a, <4 x i64> %b, <4 x i64> %c, <4 x i64> %d) {\n %a.bc = bitcast <4 x i64> %a to <32 x i8>\n %b.bc = bitcast <4 x i64> %b to <32 x i8>\n %c.bc = bitcast <4 x i64> %c to <8 x i32>\n %d.bc = bitcast <4 x i64> %d to <8 x i32>\n %a.lo = shufflevector <32 x i8> %a.bc, <32 x i8> poison, <16 x i32> \n %b.lo = shufflevector <32 x i8> %b.bc, <32 x i8> poison, <16 x i32> \n %a.hi = shufflevector <32 x i8> %a.bc, <32 x i8> poison, <16 x i32> \n %b.hi = shufflevector <32 x i8> %b.bc, <32 x i8> poison, <16 x i32> \n %cmp = icmp slt <8 x i32> %c.bc, %d.bc\n %sext = sext <8 x i1> %cmp to <8 x i32>\n %sext.bc = bitcast <8 x i32> %sext to <32 x i8>\n %sext.lo = shufflevector <32 x i8> %sext.bc, <32 x i8> poison, <16 x i32> \n %sext.hi = shufflevector <32 x i8> %sext.bc, <32 x i8> poison, <16 x i32> \n %sel.lo = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %a.lo, <16 x i8> %b.lo, <16 x i8> %sext.lo)\n %sel.hi = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %a.hi, <16 x i8> %b.hi, <16 x i8> %sext.hi)\n %concat = shufflevector <16 x i8> %sel.lo, <16 x i8> %sel.hi, <32 x i32> \n %res = bitcast <32 x i8> %concat to <4 x i64>\n ret <4 x i64> %res\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)\ndeclare <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8>, <16 x i8>, <16 x i8>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }\n"}, {"test_name": "x86_pblendvb_v4i64_v2i64", "test_body": "define <4 x i64> @x86_pblendvb_v4i64_v2i64(<4 x i64> %a, <4 x i64> %b, <4 x i64> %c, <4 x i64> %d) {\n %a.bc = bitcast <4 x i64> %a to <32 x i8>\n %b.bc = bitcast <4 x i64> %b to <32 x i8>\n %a.lo = shufflevector <32 x i8> %a.bc, <32 x i8> poison, <16 x i32> \n %b.lo = shufflevector <32 x i8> %b.bc, <32 x i8> poison, <16 x i32> \n %a.hi = shufflevector <32 x i8> %a.bc, <32 x i8> poison, <16 x i32> \n %b.hi = shufflevector <32 x i8> %b.bc, <32 x i8> poison, <16 x i32> \n %cmp = icmp slt <4 x i64> %c, %d\n %sext = sext <4 x i1> %cmp to <4 x i64>\n %sext.bc = bitcast <4 x i64> %sext to <32 x i8>\n %sext.lo = shufflevector <32 x i8> %sext.bc, <32 x i8> poison, <16 x i32> \n %sext.hi = shufflevector <32 x i8> %sext.bc, <32 x i8> poison, <16 x i32> \n %sel.lo = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %a.lo, <16 x i8> %b.lo, <16 x i8> %sext.lo)\n %sel.hi = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %a.hi, <16 x i8> %b.hi, <16 x i8> %sext.hi)\n %concat = shufflevector <16 x i8> %sel.lo, <16 x i8> %sel.hi, <32 x i32> \n %res = bitcast <32 x i8> %concat to <4 x i64>\n ret <4 x i64> %res\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)\ndeclare <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8>, <16 x i8>, <16 x i8>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }\n"}, {"test_name": "x86_pblendvb_v32i8_v16i8", "test_body": "define <4 x i64> @x86_pblendvb_v32i8_v16i8(<4 x i64> %a, <4 x i64> %b, <4 x i64> %c, <4 x i64> %d) {\n %a.bc = bitcast <4 x i64> %a to <32 x i8>\n %b.bc = bitcast <4 x i64> %b to <32 x i8>\n %c.bc = bitcast <4 x i64> %c to <32 x i8>\n %d.bc = bitcast <4 x i64> %d to <32 x i8>\n %a.lo = shufflevector <32 x i8> %a.bc, <32 x i8> poison, <16 x i32> \n %b.lo = shufflevector <32 x i8> %b.bc, <32 x i8> poison, <16 x i32> \n %a.hi = shufflevector <32 x i8> %a.bc, <32 x i8> poison, <16 x i32> \n %b.hi = shufflevector <32 x i8> %b.bc, <32 x i8> poison, <16 x i32> \n %cmp = icmp slt <32 x i8> %c.bc, %d.bc\n %sext = sext <32 x i1> %cmp to <32 x i8>\n %sext.lo = shufflevector <32 x i8> %sext, <32 x i8> poison, <16 x i32> \n %sext.hi = shufflevector <32 x i8> %sext, <32 x i8> poison, <16 x i32> \n %sel.lo = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %a.lo, <16 x i8> %b.lo, <16 x i8> %sext.lo)\n %sel.hi = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %a.hi, <16 x i8> %b.hi, <16 x i8> %sext.hi)\n %concat = shufflevector <16 x i8> %sel.lo, <16 x i8> %sel.hi, <32 x i32> \n %res = bitcast <32 x i8> %concat to <4 x i64>\n ret <4 x i64> %res\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)\ndeclare <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8>, <16 x i8>, <16 x i8>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }\n"}, {"test_name": "x86_pblendvb_v16i32_v8i32", "test_body": "define <8 x i64> @x86_pblendvb_v16i32_v8i32(<8 x i64> %a, <8 x i64> %b, <8 x i64> %c, <8 x i64> %d) {\n %a.bc = bitcast <8 x i64> %a to <64 x i8>\n %b.bc = bitcast <8 x i64> %b to <64 x i8>\n %c.bc = bitcast <8 x i64> %c to <16 x i32>\n %d.bc = bitcast <8 x i64> %d to <16 x i32>\n %a.lo = shufflevector <64 x i8> %a.bc, <64 x i8> poison, <32 x i32> \n %b.lo = shufflevector <64 x i8> %b.bc, <64 x i8> poison, <32 x i32> \n %a.hi = shufflevector <64 x i8> %a.bc, <64 x i8> poison, <32 x i32> \n %b.hi = shufflevector <64 x i8> %b.bc, <64 x i8> poison, <32 x i32> \n %cmp = icmp slt <16 x i32> %c.bc, %d.bc\n %sext = sext <16 x i1> %cmp to <16 x i32>\n %sext.bc = bitcast <16 x i32> %sext to <64 x i8>\n %sext.lo = shufflevector <64 x i8> %sext.bc, <64 x i8> poison, <32 x i32> \n %sext.hi = shufflevector <64 x i8> %sext.bc, <64 x i8> poison, <32 x i32> \n %sel.lo = tail call <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8> %a.lo, <32 x i8> %b.lo, <32 x i8> %sext.lo)\n %sel.hi = tail call <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8> %a.hi, <32 x i8> %b.hi, <32 x i8> %sext.hi)\n %concat = shufflevector <32 x i8> %sel.lo, <32 x i8> %sel.hi, <64 x i32> \n %res = bitcast <64 x i8> %concat to <8 x i64>\n ret <8 x i64> %res\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)\ndeclare <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8>, <32 x i8>, <32 x i8>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }\n"}]}, {"file": "llvm/test/Transforms/VectorCombine/AArch64/shuffletoidentity.ll", "commands": ["opt -passes=vector-combine -S %s"], "tests": [{"test_name": "bitcast_smax_v8i32_v4i32", "test_body": "target triple = \"aarch64\"\n\ndefine <4 x i64> @bitcast_smax_v8i32_v4i32(<4 x i64> %a, <4 x i64> %b) {\n %a.bc0 = bitcast <4 x i64> %a to <8 x i32>\n %b.bc0 = bitcast <4 x i64> %b to <8 x i32>\n %cmp = icmp slt <8 x i32> %a.bc0, %b.bc0\n %cmp.lo = shufflevector <8 x i1> %cmp, <8 x i1> poison, <4 x i32> \n %cmp.hi = shufflevector <8 x i1> %cmp, <8 x i1> poison, <4 x i32> \n %a.bc1 = bitcast <4 x i64> %a to <8 x i32>\n %b.bc1 = bitcast <4 x i64> %b to <8 x i32>\n %a.lo = shufflevector <8 x i32> %a.bc1, <8 x i32> poison, <4 x i32> \n %b.lo = shufflevector <8 x i32> %b.bc1, <8 x i32> poison, <4 x i32> \n %lo = select <4 x i1> %cmp.lo, <4 x i32> %b.lo, <4 x i32> %a.lo\n %a.bc2 = bitcast <4 x i64> %a to <8 x i32>\n %b.bc2 = bitcast <4 x i64> %b to <8 x i32>\n %a.hi = shufflevector <8 x i32> %a.bc2, <8 x i32> poison, <4 x i32> \n %b.hi = shufflevector <8 x i32> %b.bc2, <8 x i32> poison, <4 x i32> \n %hi = select <4 x i1> %cmp.hi, <4 x i32> %b.hi, <4 x i32> %a.hi\n %concat = shufflevector <4 x i32> %lo, <4 x i32> %hi, <8 x i32> \n %res = bitcast <8 x i32> %concat to <4 x i64>\n ret <4 x i64> %res\n}\n"}]}, {"file": "llvm/test/Transforms/VectorCombine/X86/shuffle-of-selects.ll", "commands": ["opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mcpu=x86-64-v2", "opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mcpu=x86-64-v3", "opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mcpu=x86-64-v4"], "tests": [{"test_name": "src_v8tov16_i16", "test_body": "define <16 x i16> @src_v8tov16_i16(<8 x i1> %a, <8 x i1> %b, <8 x i16> %x, <8 x i16> %y, <8 x i16> %z) {\n %select.xz = select <8 x i1> %a, <8 x i16> %x, <8 x i16> %z\n %select.yx = select <8 x i1> %b, <8 x i16> %y, <8 x i16> %x\n %res = shufflevector <8 x i16> %select.xz, <8 x i16> %select.yx, <16 x i32> \n ret <16 x i16> %res\n}\n"}, {"test_name": "src_v4tov8_float", "test_body": "define <8 x float> @src_v4tov8_float(<4 x i1> %a, <4 x i1> %b, <4 x float> %x, <4 x float> %y, <4 x float> %z) {\n %select.xz = select <4 x i1> %a, <4 x float> %x, <4 x float> %z\n %select.yx = select <4 x i1> %b, <4 x float> %y, <4 x float> %x\n %res = shufflevector <4 x float> %select.xz, <4 x float> %select.yx, <8 x i32> \n ret <8 x float> %res\n}\n"}, {"test_name": "src_v4tov8_i16", "test_body": "define <8 x i16> @src_v4tov8_i16(<4 x i1> %a, <4 x i1> %b, <4 x i16> %x, <4 x i16> %y, <4 x i16> %z) {\n %select.xz = select <4 x i1> %a, <4 x i16> %x, <4 x i16> %z\n %select.yx = select <4 x i1> %b, <4 x i16> %y, <4 x i16> %x\n %res = shufflevector <4 x i16> %select.xz, <4 x i16> %select.yx, <8 x i32> \n ret <8 x i16> %res\n}\n"}, {"test_name": "src_v2tov4_i64", "test_body": "define <4 x i64> @src_v2tov4_i64(<2 x i1> %a, <2 x i1> %b, <2 x i64> %x, <2 x i64> %y, <2 x i64> %z) {\n %select.xz = select <2 x i1> %a, <2 x i64> %x, <2 x i64> %z\n %select.yx = select <2 x i1> %b, <2 x i64> %y, <2 x i64> %x\n %res = shufflevector <2 x i64> %select.xz, <2 x i64> %select.yx, <4 x i32> \n ret <4 x i64> %res\n}\n"}, {"test_name": "src_v2tov2_i64", "test_body": "define <2 x i64> @src_v2tov2_i64(<2 x i1> %a, <2 x i1> %b, <2 x i64> %x, <2 x i64> %y, <2 x i64> %z) {\n %select.xz = select <2 x i1> %a, <2 x i64> %x, <2 x i64> %z\n %select.yx = select <2 x i1> %b, <2 x i64> %y, <2 x i64> %x\n %res = shufflevector <2 x i64> %select.xz, <2 x i64> %select.yx, <2 x i32> \n ret <2 x i64> %res\n}\n"}, {"test_name": "src_v2tov4_i32", "test_body": "define <4 x i32> @src_v2tov4_i32(<2 x i1> %a, <2 x i1> %b, <2 x i32> %x, <2 x i32> %y, <2 x i32> %z) {\n %select.xz = select <2 x i1> %a, <2 x i32> %x, <2 x i32> %z\n %select.yx = select <2 x i1> %b, <2 x i32> %y, <2 x i32> %x\n %res = shufflevector <2 x i32> %select.xz, <2 x i32> %select.yx, <4 x i32> \n ret <4 x i32> %res\n}\n"}, {"test_name": "src_v2tov2_double", "test_body": "define <2 x double> @src_v2tov2_double(<2 x i1> %a, <2 x i1> %b, <2 x double> %x, <2 x double> %y, <2 x double> %z) {\n %select.xz = select <2 x i1> %a, <2 x double> %x, <2 x double> %z\n %select.yx = select <2 x i1> %b, <2 x double> %y, <2 x double> %x\n %res = shufflevector <2 x double> %select.xz, <2 x double> %select.yx, <2 x i32> \n ret <2 x double> %res\n}\n"}, {"test_name": "test_mask0", "test_body": "define <2 x float> @test_mask0(<4 x i1> %c, <4 x float> %x, <4 x float> %y, <4 x float> %z) {\n %select.xy = select <4 x i1> %c, <4 x float> %x, <4 x float> %y\n %select.yz = select <4 x i1> %c, <4 x float> %y, <4 x float> %z\n %res = shufflevector <4 x float> %select.xy, <4 x float> %select.yz, <2 x i32> \n ret <2 x float> %res\n}\n"}, {"test_name": "src_v2tov4_i16", "test_body": "define <4 x i16> @src_v2tov4_i16(<2 x i1> %a, <2 x i1> %b, <2 x i16> %x, <2 x i16> %y, <2 x i16> %z) {\n %select.xz = select <2 x i1> %a, <2 x i16> %x, <2 x i16> %z\n %select.yx = select <2 x i1> %b, <2 x i16> %y, <2 x i16> %x\n %res = shufflevector <2 x i16> %select.xz, <2 x i16> %select.yx, <4 x i32> \n ret <4 x i16> %res\n}\n"}, {"test_name": "src_v4tov8_i32", "test_body": "define <8 x i32> @src_v4tov8_i32(<4 x i1> %a, <4 x i1> %b, <4 x i32> %x, <4 x i32> %y, <4 x i32> %z) {\n %select.xz = select <4 x i1> %a, <4 x i32> %x, <4 x i32> %z\n %select.yx = select <4 x i1> %b, <4 x i32> %y, <4 x i32> %x\n %res = shufflevector <4 x i32> %select.xz, <4 x i32> %select.yx, <8 x i32> \n ret <8 x i32> %res\n}\n"}, {"test_name": "src_v8tov8_i16", "test_body": "define <8 x i16> @src_v8tov8_i16(<8 x i1> %a, <8 x i1> %b, <8 x i16> %x, <8 x i16> %y, <8 x i16> %z) {\n %select.xz = select <8 x i1> %a, <8 x i16> %x, <8 x i16> %z\n %select.yx = select <8 x i1> %b, <8 x i16> %y, <8 x i16> %x\n %res = shufflevector <8 x i16> %select.xz, <8 x i16> %select.yx, <8 x i32> \n ret <8 x i16> %res\n}\n"}, {"test_name": "src_v2tov4_float", "test_body": "define <4 x float> @src_v2tov4_float(<2 x i1> %a, <2 x i1> %b, <2 x float> %x, <2 x float> %y, <2 x float> %z) {\n %select.xz = select <2 x i1> %a, <2 x float> %x, <2 x float> %z\n %select.yx = select <2 x i1> %b, <2 x float> %y, <2 x float> %x\n %res = shufflevector <2 x float> %select.xz, <2 x float> %select.yx, <4 x i32> \n ret <4 x float> %res\n}\n"}, {"test_name": "test_mask1", "test_body": "define <2 x float> @test_mask1(<4 x i1> %c, <4 x float> %x, <4 x float> %y, <4 x float> %z) {\n %select.xy = select <4 x i1> %c, <4 x float> %x, <4 x float> %y\n %select.yz = select <4 x i1> %c, <4 x float> %y, <4 x float> %z\n %res = shufflevector <4 x float> %select.xy, <4 x float> %select.yz, <2 x i32> \n ret <2 x float> %res\n}\n"}, {"test_name": "src_v2tov4_double", "test_body": "define <4 x double> @src_v2tov4_double(<2 x i1> %a, <2 x i1> %b, <2 x double> %x, <2 x double> %y, <2 x double> %z) {\n %select.xz = select <2 x i1> %a, <2 x double> %x, <2 x double> %z\n %select.yx = select <2 x i1> %b, <2 x double> %y, <2 x double> %x\n %res = shufflevector <2 x double> %select.xz, <2 x double> %select.yx, <4 x i32> \n ret <4 x double> %res\n}\n"}, {"test_name": "src_v2tov4_float_nnan", "test_body": "define <4 x float> @src_v2tov4_float_nnan(<2 x i1> %a, <2 x i1> %b, <2 x float> %x, <2 x float> %y, <2 x float> %z) {\n %select.xz = select nnan <2 x i1> %a, <2 x float> %x, <2 x float> %z\n %select.yx = select nnan <2 x i1> %b, <2 x float> %y, <2 x float> %x\n %res = shufflevector <2 x float> %select.xz, <2 x float> %select.yx, <4 x i32> \n ret <4 x float> %res\n}\n"}]}], "issue": {"title": "A/F: `I >= 0 && I < (NumOpElts * 2) && \"Out-of-bounds shuffle mask element\" after upstream commit 5d1029b", "body": "One of our internal tests recently started hitting an assertion failure when building which I bisected back to 5d1029b4a87f36a394c169b89b26a74d17f7ff01. I was able to reduce the test case to the following code:\n```c++\ntypedef float e __attribute__((__vector_size__(16)));\ne g(e h, e j) { return __builtin_ia32_cmpltps(j, h); }\ne k(float, float l, float n, float) { return {n, l}; }\ne o, p;\ntypedef union q {\n e r;\n} t;\ntypedef union u {\n e r;\n} w;\nunion aa {\n t ab;\n w ac;\n float f[];\n aa(t v) : ab(v) {}\n e ad;\n aa(e v) : ad(v) {}\n};\n#define ae(v) aa(v).ab\n#define af(v) aa(v).ac\n#define ag(a, b, c, d) ae(k(d, c, b, a))\n#define ah(v, ai) aa(v).f[ai]\n#define aj(a, b) af(g(a.r, b.r))\n#define ak(a, b, m) ae(al(a.r, b.r, m.r))\nt am(t an, t abcd) {\n e ao = __builtin_shufflevector(an.r, abcd.r, 0, 4, 1, 5);\n t ap = ae(ao);\n return ap;\n}\ne al(e, e, e aq) {\n e ar = __builtin_ia32_blendvps(o, p, aq);\n return ar;\n}\nfloat as(t v, int s) { return ah(v, s); }\nw at(t a, t b) { return aj(a, b); }\nt au(w aq) {\n t b, a;\n return ak(a, b, aq);\n}\nt av(t an, t abcd) { return am(an, abcd); }\nt aw_x, bl, bq_ay;\nt bf();\nstruct bc {\n t bd;\n bc(t bg) { bd = bg; }\n t be() { return bd; }\n};\nstruct bh {\n t bi;\n int i;\n bh(t bg, int bj) : bi(bg), i(bj) {}\n operator float() {\n float bk = as(bi, i);\n return bk;\n }\n};\nfloat bm_x;\nstruct bm {\n bm(float y, float z) { bl = ag(bm_x, y, z, 0.0f); }\n bm(bc y, bc z) {\n q bn = z.be(), bo(bn), bp = y.be();\n bl = av(bo, bp);\n }\n bh operator[](int bj) { return bh(bl, bj); }\n};\nbc bq() {\n t __trans_tmp_3 = bf();\n u bb = at(bq_ay, aw_x);\n __trans_tmp_3 = au(bb);\n return __trans_tmp_3;\n}\nbm bs() { return bm(bq(), bq()); }\nvoid bx() {\n unsigned char by, bz;\n bm ca = bs();\n bz = ca[1];\n by = ca[2];\n bm(bz, by);\n}\n```\nIf compiled with a compiler that includes 5d1029b4a87f36a394c169b89b26a74d17f7ff01 and with optimizations and AVX enabled, the compiler hits an assertion failure:\n```\n$ ~/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang -c -O2 -mavx repro.cpp\nclang: /home/dyung/src/upstream/llvm_clean_git/llvm/lib/IR/Instructions.cpp:1906: bool isSingleSourceMaskImpl(llvm::ArrayRef, int): Assertion `I >= 0 && I < (NumOpElts * 2) && \"Out-of-bounds shuffle mask element\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\nStack dump:\n0. Program arguments: /home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang -c -O2 repro.cpp -mavx\n1. parser at end of file\n2. Optimizer\n3. Running pass \"function(float2int,lower-constant-intrinsics,loop(loop-rotate,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize,infer-alignment,loop-load-elim,instcombine,simplifycfg,slp-vectorizer,vector-combine,instcombine,loop-unroll,transform-warning,sroa,infer-alignment,instcombine,loop-mssa(licm),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg)\" on module \"repro.cpp\"\n4. Running pass \"vector-combine\" on function \"_Z2bxv\"\n #0 0x0000561cf26380ef llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x224f0ef)\n #1 0x0000561cf2635c04 llvm::sys::CleanupOnSignal(unsigned long) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x224cc04)\n #2 0x0000561cf2586258 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0\n #3 0x00007f5f727e6420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\n #4 0x00007f5f722b300b raise /build/glibc-FcRMwW/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\n #5 0x00007f5f72292859 abort /build/glibc-FcRMwW/glibc-2.31/stdlib/abort.c:81:7\n #6 0x00007f5f72292729 get_sysdep_segment_value /build/glibc-FcRMwW/glibc-2.31/intl/loadmsgcat.c:509:8\n #7 0x00007f5f72292729 _nl_load_domain /build/glibc-FcRMwW/glibc-2.31/intl/loadmsgcat.c:970:34\n #8 0x00007f5f722a3fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\n #9 0x0000561cf203aa46 isSingleSourceMaskImpl(llvm::ArrayRef, int) Instructions.cpp:0:0\n#10 0x0000561cf20436e4 llvm::ShuffleVectorInst::isSelectMask(llvm::ArrayRef, int) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x1c5a6e4)\n#11 0x0000561cf116c2b0 llvm::X86TTIImpl::getShuffleCost(llvm::TargetTransformInfo::ShuffleKind, llvm::VectorType*, llvm::ArrayRef, llvm::TargetTransformInfo::TargetCostKind, int, llvm::VectorType*, llvm::ArrayRef, llvm::Instruction const*) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0xd832b0)\n#12 0x0000561cf17404ed llvm::TargetTransformInfo::getShuffleCost(llvm::TargetTransformInfo::ShuffleKind, llvm::VectorType*, llvm::ArrayRef, llvm::TargetTransformInfo::TargetCostKind, int, llvm::VectorType*, llvm::ArrayRef, llvm::Instruction const*) const (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x13574ed)\n#13 0x0000561cf42a667a (anonymous namespace)::VectorCombine::foldShuffleOfSelects(llvm::Instruction&) VectorCombine.cpp:0:0\n#14 0x0000561cf42c0e55 (anonymous namespace)::VectorCombine::run()::'lambda'(llvm::Instruction&)::operator()(llvm::Instruction&) const (.isra.0) VectorCombine.cpp:0:0\n#15 0x0000561cf42c1d85 llvm::VectorCombinePass::run(llvm::Function&, llvm::AnalysisManager&) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x3ed8d85)\n#16 0x0000561cf3b8f1a6 llvm::detail::PassModel>::run(llvm::Function&, llvm::AnalysisManager&) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x37a61a6)\n#17 0x0000561cf20deb09 llvm::PassManager>::run(llvm::Function&, llvm::AnalysisManager&) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x1cf5b09)\n#18 0x0000561cf11a9906 llvm::detail::PassModel>, llvm::AnalysisManager>::run(llvm::Function&, llvm::AnalysisManager&) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0xdc0906)\n#19 0x0000561cf20dd372 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager&) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x1cf4372)\n#20 0x0000561cf11aa2c6 llvm::detail::PassModel>::run(llvm::Module&, llvm::AnalysisManager&) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0xdc12c6)\n#21 0x0000561cf20dcd91 llvm::PassManager>::run(llvm::Module&, llvm::AnalysisManager&) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x1cf3d91)\n#22 0x0000561cf28d99aa (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr>&, std::unique_ptr>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\n#23 0x0000561cf28dd9db clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr, std::unique_ptr>, clang::BackendConsumer*) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x24f49db)\n#24 0x0000561cf3021121 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x2c38121)\n#25 0x0000561cf4a4170c clang::ParseAST(clang::Sema&, bool, bool) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x465870c)\n#26 0x0000561cf3021548 clang::CodeGenAction::ExecuteAction() (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x2c38548)\n#27 0x0000561cf32f80f9 clang::FrontendAction::Execute() (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x2f0f0f9)\n#28 0x0000561cf3278f4e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x2e8ff4e)\n#29 0x0000561cf33ed2b6 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x30042b6)\n#30 0x0000561cf1125ccd cc1_main(llvm::ArrayRef, char const*, void*) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0xd3cccd)\n#31 0x0000561cf111d5ca ExecuteCC1Tool(llvm::SmallVectorImpl&, llvm::ToolContext const&) driver.cpp:0:0\n#32 0x0000561cf306b3cd void llvm::function_ref::callback_fn>, std::__cxx11::basic_string, std::allocator>*, bool*) const::'lambda'()>(long) Job.cpp:0:0\n#33 0x0000561cf2586760 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x219d760)\n#34 0x0000561cf306b9ef clang::driver::CC1Command::Execute(llvm::ArrayRef>, std::__cxx11::basic_string, std::allocator>*, bool*) const (.part.0) Job.cpp:0:0\n#35 0x0000561cf302c9c4 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x2c439c4)\n#36 0x0000561cf302da5e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl>&, bool) const (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x2c44a5e)\n#37 0x0000561cf3035ef5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl>&) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x2c4cef5)\n#38 0x0000561cf1122aab clang_main(int, char**, llvm::ToolContext const&) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0xd39aab)\n#39 0x0000561cf10546bb main (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0xc6b6bb)\n#40 0x00007f5f72294083 __libc_start_main /build/glibc-FcRMwW/glibc-2.31/csu/../csu/libc-start.c:342:3\n#41 0x0000561cf111d05e _start (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0xd3405e)\nclang: error: clang frontend command failed with exit code 134 (use -v to see invocation)\nclang version 21.0.0 (https://github.com/llvm/llvm-project.git 5d1029b4a87f36a394c169b89b26a74d17f7ff01)\nTarget: x86_64-unknown-linux-gnu\nThread model: posix\nInstalledDir: /home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin\nBuild config: +assertions\n```", "author": "dyung", "labels": ["crash", "llvm:transforms"], "comments": [{"author": "ParkHanbum", "body": "Can you help me compile the sample?\nnever mind. I get the crash."}, {"author": "ParkHanbum", "body": "```\ndefine void @test(<4 x i1> %z, <4 x float> %1, <4 x float> %2) {\n%a = select <4 x i1> %z, <4 x float> %1, <4 x float> %2\n%b = select <4 x i1> %z, <4 x float> %1, <4 x float> %2\n%c = shufflevector <4 x float> %a, <4 x float> %b, <2 x i32> \nret void\n}\n```\nThe problematic IR is shown above.\n\n```\n * frame #4: 0x00000001043d7fe8 clang++`isIdentityMaskImpl(llvm::ArrayRef, int) (.cold.3) + 36\n frame #5: 0x0000000100fd5334 clang++`llvm::ShuffleVectorInst::isSelectMask(llvm::ArrayRef, int) + 256\n frame #6: 0x0000000100095ff8 clang++`llvm::BasicTTIImplBase::improveShuffleKindFromMask(llvm::TargetTransformInfo::ShuffleKind, llvm::ArrayRef, llvm::VectorType*, int&, llvm::VectorType*&) const + 184\n frame #7: 0x000000010033e104 clang++`llvm::X86TTIImpl::getShuffleCost(llvm::TargetTransformInfo::ShuffleKind, llvm::VectorType*, llvm::ArrayRef, llvm::TargetTransformInfo::TargetCostKind, int, llvm::VectorType*, llvm::ArrayRef, llvm::Instruction const*) + 128\n```\n\nThis is where the crash happens.\n\n\n```\n OldCost += TTI.getShuffleCost(SK, DstVecTy, Mask, CostKind, 0, nullptr,\n {I.getOperand(0), I.getOperand(1)}, &I);\n```\n\nThe problematic IR is shown above.\n\nTo calculate the OldCost, call getShuffleCost.\nThe DstVecTy passed as an argument is `<2 x float>` and the Mask is .\n\nThe second Mask specifier is 5, which is greater than NumOpElts * 2 of DstVecTy, so this assertion seems to be thrown.\n(If we increase the Mask to <3 x i32> or decrease the Mask size to <2 x i32> , the error will not occur.)\n\nI will add a fix after further analysis.\n\n\n"}, {"author": "RKSimon", "body": "@ParkHanbum You must use the source type not destination type for getShuffleCost"}, {"author": "ParkHanbum", "body": "@RKSimon I'm sorry, I made a mistake. I'll push up the patch quickly.\n"}, {"author": "RKSimon", "body": "You just need the fix + test coverage - no need to revert the existing patch if you are prompt"}]}, "verified": true} {"bug_id": "106083", "issue_url": "https://github.com/llvm/llvm-project/issues/106083", "bug_type": "crash", "base_commit": "d075debc508898d5f365f8e909c54d6f4edada85", "knowledge_cutoff": "2024-08-26T14:36:57Z", "lit_test_dir": ["llvm/test/Transforms/DFAJumpThreading"], "hints": {"fix_commit": "d4a38c8ff5c993e14c42895b51a47272fb03a857", "components": ["DFAJumpThreading"], "bug_location_lineno": {"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": [[194, 200], [202, 207], [223, 254]]}, "bug_location_funcname": {"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": ["unfold"]}}, "patch": "commit d4a38c8ff5c993e14c42895b51a47272fb03a857\nAuthor: Usman Nadeem \nDate: Tue Sep 24 08:54:36 2024 -0700\n\n [DFAJumpThreading] Handle select unfolding when user phi is not a dir… (#109511)\n \n …ect successor\n \n Previously the code assumed that the select instruction is defined in a\n block that is a direct predecessor of the block where the PHINode uses\n it. So, we were hitting an assertion when we tried to access the def\n block as an incoming block for the user phi node.\n \n This patch handles that case by using the correct end block and creating\n a new phi node that aggregates both the values of the select in that end\n block, and then using that new unfolded phi to overwrite the original\n user phi node.\n \n Fixes #106083\n \n Change-Id: Ie471994cca232318f74a6e6438efa21e561c2dc0\n\ndiff --git a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp\nindex ef9c264482a6..0e2b5c925a6a 100644\n--- a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp\n+++ b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp\n@@ -194,7 +194,6 @@ void unfold(DomTreeUpdater *DTU, LoopInfo *LI, SelectInstToUnfold SIToUnfold,\n SelectInst *SI = SIToUnfold.getInst();\n PHINode *SIUse = SIToUnfold.getUse();\n BasicBlock *StartBlock = SI->getParent();\n- BasicBlock *EndBlock = SIUse->getParent();\n BranchInst *StartBlockTerm =\n dyn_cast(StartBlock->getTerminator());\n \n@@ -202,6 +201,7 @@ void unfold(DomTreeUpdater *DTU, LoopInfo *LI, SelectInstToUnfold SIToUnfold,\n assert(SI->hasOneUse());\n \n if (StartBlockTerm->isUnconditional()) {\n+ BasicBlock *EndBlock = StartBlock->getUniqueSuccessor();\n // Arbitrarily choose the 'false' side for a new input value to the PHI.\n BasicBlock *NewBlock = BasicBlock::Create(\n SI->getContext(), Twine(SI->getName(), \".si.unfold.false\"),\n@@ -223,32 +223,44 @@ void unfold(DomTreeUpdater *DTU, LoopInfo *LI, SelectInstToUnfold SIToUnfold,\n NewBlock->getFirstInsertionPt());\n NewPhi->addIncoming(SIOp2, StartBlock);\n \n- if (auto *OpSi = dyn_cast(SIOp1))\n- NewSIsToUnfold->push_back(SelectInstToUnfold(OpSi, SIUse));\n- if (auto *OpSi = dyn_cast(SIOp2))\n- NewSIsToUnfold->push_back(SelectInstToUnfold(OpSi, NewPhi));\n-\n- // Update the phi node of SI.\n- for (unsigned Idx = 0; Idx < SIUse->getNumIncomingValues(); ++Idx) {\n- if (SIUse->getIncomingBlock(Idx) == StartBlock)\n- SIUse->setIncomingValue(Idx, SIOp1);\n+ // Update any other PHI nodes in EndBlock.\n+ for (PHINode &Phi : EndBlock->phis()) {\n+ if (SIUse == &Phi)\n+ continue;\n+ Phi.addIncoming(Phi.getIncomingValueForBlock(StartBlock), NewBlock);\n }\n- SIUse->addIncoming(NewPhi, NewBlock);\n \n- // Update any other PHI nodes in EndBlock.\n- for (auto II = EndBlock->begin(); PHINode *Phi = dyn_cast(II);\n- ++II) {\n- if (Phi != SIUse)\n- Phi->addIncoming(Phi->getIncomingValueForBlock(StartBlock), NewBlock);\n+ // Update the phi node of SI, which is its only use.\n+ if (EndBlock == SIUse->getParent()) {\n+ SIUse->addIncoming(NewPhi, NewBlock);\n+ SIUse->replaceUsesOfWith(SI, SIOp1);\n+ } else {\n+ PHINode *EndPhi = PHINode::Create(SIUse->getType(), pred_size(EndBlock),\n+ Twine(SI->getName(), \".si.unfold.phi\"),\n+ EndBlock->getFirstInsertionPt());\n+ for (BasicBlock *Pred : predecessors(EndBlock)) {\n+ if (Pred != StartBlock && Pred != NewBlock)\n+ EndPhi->addIncoming(EndPhi, Pred);\n+ }\n+\n+ EndPhi->addIncoming(SIOp1, StartBlock);\n+ EndPhi->addIncoming(NewPhi, NewBlock);\n+ SIUse->replaceUsesOfWith(SI, EndPhi);\n+ SIUse = EndPhi;\n }\n \n- StartBlockTerm->eraseFromParent();\n+ if (auto *OpSi = dyn_cast(SIOp1))\n+ NewSIsToUnfold->push_back(SelectInstToUnfold(OpSi, SIUse));\n+ if (auto *OpSi = dyn_cast(SIOp2))\n+ NewSIsToUnfold->push_back(SelectInstToUnfold(OpSi, NewPhi));\n \n // Insert the real conditional branch based on the original condition.\n+ StartBlockTerm->eraseFromParent();\n BranchInst::Create(EndBlock, NewBlock, SI->getCondition(), StartBlock);\n DTU->applyUpdates({{DominatorTree::Insert, StartBlock, EndBlock},\n {DominatorTree::Insert, StartBlock, NewBlock}});\n } else {\n+ BasicBlock *EndBlock = SIUse->getParent();\n BasicBlock *NewBlockT = BasicBlock::Create(\n SI->getContext(), Twine(SI->getName(), \".si.unfold.true\"),\n EndBlock->getParent(), EndBlock);\n", "tests": [{"file": "llvm/test/Transforms/DFAJumpThreading/dfa-jump-threading-transform.ll", "commands": ["opt -S -passes=dfa-jump-threading %s"], "tests": [{"test_name": "test2", "test_body": "define i32 @test2(i32 %init) {\nentry:\n %cmp = icmp eq i32 %init, 0\n %sel = select i1 %cmp, i32 0, i32 2\n br label %loop.1\n\nloop.1: ; preds = %loop.1.backedge, %entry\n %state.1 = phi i32 [ %sel, %entry ], [ %state.1.be2, %loop.1.backedge ]\n br label %loop.2\n\nloop.2: ; preds = %loop.2.backedge, %loop.1\n %state.2 = phi i32 [ %state.1, %loop.1 ], [ %state.2.be, %loop.2.backedge ]\n br label %loop.3\n\nloop.3: ; preds = %case2, %loop.2\n %state = phi i32 [ %state.2, %loop.2 ], [ 3, %case2 ]\n switch i32 %state, label %infloop.i [\n i32 2, label %case2\n i32 3, label %case3\n i32 4, label %case4\n i32 0, label %case0\n i32 1, label %case1\n ]\n\ncase2: ; preds = %loop.3\n br i1 %cmp, label %loop.3, label %loop.1.backedge\n\ncase3: ; preds = %loop.3\n br i1 %cmp, label %loop.2.backedge, label %case4\n\ncase4: ; preds = %case3, %loop.3\n br i1 %cmp, label %loop.2.backedge, label %loop.1.backedge\n\nloop.1.backedge: ; preds = %case4, %case2\n %state.1.be = phi i32 [ 2, %case4 ], [ 4, %case2 ]\n %state.1.be2 = select i1 %cmp, i32 1, i32 %state.1.be\n br label %loop.1\n\nloop.2.backedge: ; preds = %case4, %case3\n %state.2.be = phi i32 [ 3, %case4 ], [ 0, %case3 ]\n br label %loop.2\n\ncase0: ; preds = %loop.3\n br label %exit\n\ncase1: ; preds = %loop.3\n br label %exit\n\ninfloop.i: ; preds = %infloop.i, %loop.3\n br label %infloop.i\n\nexit: ; preds = %case1, %case0\n ret i32 0\n}\n"}, {"test_name": "pr106083_select_dead_uses", "test_body": "define void @pr106083_select_dead_uses(i1 %cmp1, i1 %not, ptr %p) {\nbb:\n %spec.select = select i1 %cmp1, i32 0, i32 1\n br label %.loopexit6\n\n.loopexit6: ; preds = %select.unfold, %bb\n br i1 %not, label %select.unfold, label %bb1\n\nbb1: ; preds = %.loopexit6\n %i = load i32, ptr %p, align 4\n %not2 = icmp eq i32 0, 0\n %spec.select7 = select i1 %not2, i32 %spec.select, i32 0\n br label %select.unfold\n\nselect.unfold: ; preds = %bb1, %.loopexit6\n %_2 = phi i32 [ 0, %.loopexit6 ], [ %spec.select7, %bb1 ]\n switch i32 %_2, label %bb2 [\n i32 0, label %.preheader.preheader\n i32 1, label %.loopexit6\n ]\n\n.preheader.preheader: ; preds = %select.unfold\n ret void\n\nbb2: ; preds = %select.unfold\n unreachable\n}\n"}, {"test_name": "test1", "test_body": "define i32 @test1(i32 %num) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.inc, %entry\n %count = phi i32 [ 0, %entry ], [ %inc, %for.inc ]\n %state = phi i32 [ 1, %entry ], [ %state.next, %for.inc ]\n switch i32 %state, label %for.inc [\n i32 1, label %case1\n i32 2, label %case2\n ]\n\ncase1: ; preds = %for.body\n br label %for.inc\n\ncase2: ; preds = %for.body\n %cmp = icmp eq i32 %count, 50\n %sel = select i1 %cmp, i32 1, i32 2\n br label %for.inc\n\nfor.inc: ; preds = %case2, %case1, %for.body\n %state.next = phi i32 [ %sel, %case2 ], [ 1, %for.body ], [ 2, %case1 ]\n %inc = add nsw i32 %count, 1\n %cmp.exit = icmp slt i32 %inc, %num\n br i1 %cmp.exit, label %for.body, label %for.end\n\nfor.end: ; preds = %for.inc\n ret i32 0\n}\n"}, {"test_name": "pr106083_invalidBBarg_fold", "test_body": "define void @pr106083_invalidBBarg_fold(i1 %cmp1, i1 %cmp2, i1 %not, ptr %d) {\nbb:\n %sel = select i1 %cmp1, i32 0, i32 1\n br label %BB1\n\nBB1: ; preds = %BB1.backedge, %BB7, %bb\n %i = phi i16 [ 0, %BB1.backedge ], [ 0, %bb ], [ 1, %BB7 ]\n br i1 %not, label %BB7, label %BB2\n\nBB2: ; preds = %BB1\n store i16 0, ptr %d, align 2\n %spec.select = select i1 %cmp2, i32 %sel, i32 0\n br label %BB7\n\nBB7: ; preds = %BB2, %BB1\n %d.promoted4 = phi i16 [ 0, %BB1 ], [ 1, %BB2 ]\n %_3 = phi i32 [ 0, %BB1 ], [ %spec.select, %BB2 ]\n switch i32 %_3, label %BB1.backedge [\n i32 0, label %BB1\n i32 1, label %BB8\n ]\n\nBB1.backedge: ; preds = %BB7\n br label %BB1\n\nBB8: ; preds = %BB7\n ret void\n}\n"}, {"test_name": "pr78059_bitwidth", "test_body": "define void @pr78059_bitwidth() {\n.split.preheader:\n br label %.split\n\n.split: ; preds = %.split, %.split.preheader\n %0 = phi i128 [ 0, %.split.preheader ], [ -1, %.split ]\n switch i128 %0, label %end [\n i128 -1, label %end\n i128 0, label %.split\n ]\n\nend: ; preds = %.split, %.split\n ret void\n}\n"}]}], "issue": {"title": "[DFAJumpThreading] crash since b167ada", "body": "Seeing many assertions that go away if I revert b167ada \"[DFAJumpThreading] Rewrite the way paths are enumerated (#96127)\".\r\n\r\n```\r\nclang-20 -cc1 -triple s390x-unknown-linux-gnu -target-cpu z15 -O3 -w -mllvm -enable-dfa-jump-thread -o /dev/null -emit-llvm -x ir tc_dfa-jt_invalidbbarg.ll\r\n...\r\n10 0x000002aa0a73e544 (anonymous namespace)::DFAJumpThreading::run\r\n...\r\n```\r\n\r\n```\r\nclang-20 -cc1 -triple s390x-unknown-linux-gnu -target-cpu z16 -O3 -w -mllvm -enable-dfa-jump-thread -o /dev/null -emit-llvm -x ir tc_select_mustbedeadnow.ll\r\n...\r\n#10 0x000002aa1b0c0968 llvm::DFAJumpThreadingPass::run\r\n...\r\n\r\n```\r\n[tcs_dfa-jt.tar.gz](https://github.com/user-attachments/files/16750050/tcs_dfa-jt.tar.gz)\r\n", "author": "JonPsson1", "labels": ["crash", "llvm:transforms"], "comments": [{"author": "mikaelholmen", "body": "Perhaps the same assertion I reported here:\r\n https://github.com/llvm/llvm-project/pull/96127#issuecomment-2303862037\r\n?"}, {"author": "JonPsson1", "body": "> Perhaps the same assertion I reported here: [#96127 (comment)](https://github.com/llvm/llvm-project/pull/96127#issuecomment-2303862037) ?\r\n\r\nYes, same assertion, and in addition my second test case above triggered another assertion."}]}, "verified": true} {"bug_id": "106257", "issue_url": "https://github.com/llvm/llvm-project/issues/106257", "bug_type": "crash", "base_commit": "a4989cd603b8e8185e35e3c2b7b48b422d4898be", "knowledge_cutoff": "2024-08-27T17:46:38Z", "lit_test_dir": ["llvm/test/Transforms/LoopVectorize"], "hints": {"fix_commit": "4b84288f00f3e112045bbc4be4f1539147574ead", "components": ["LoopVectorize"], "bug_location_lineno": {"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [[8648, 8653]]}, "bug_location_funcname": {"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": ["addUsersInExitBlock"]}}, "patch": "commit 4b84288f00f3e112045bbc4be4f1539147574ead\nAuthor: Florian Hahn \nDate: Wed Aug 28 19:12:04 2024 +0100\n\n [VPlan] Pass live-ins used as exit values straight to live-out.\n \n Live-ins that are used as exit values don't need to be extracted, they\n can be passed through directly. This fixes a crash when trying to\n extract from a live-in.\n \n Fixes https://github.com/llvm/llvm-project/issues/106257.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\nindex 4c68a95b9c26..cb104c4ed2d0 100644\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n@@ -8648,6 +8648,11 @@ addUsersInExitBlock(VPlan &Plan,\n \n // Introduce VPUsers modeling the exit values.\n for (const auto &[ExitPhi, V] : ExitingValuesToFix) {\n+ // Pass live-in values used by exit phis directly through to the live-out.\n+ if (V->isLiveIn()) {\n+ Plan.addLiveOut(ExitPhi, V);\n+ continue;\n+ }\n VPValue *Ext = B.createNaryOp(\n VPInstruction::ExtractFromEnd,\n {V, Plan.getOrAddLiveIn(ConstantInt::get(\n", "tests": [{"file": "llvm/test/Transforms/LoopVectorize/extract-from-end-vector-constant.ll", "commands": ["opt -p loop-vectorize -force-vector-width=4 -S %s"], "tests": [{"test_name": "exit_value_vector_live_in", "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine <2 x i64> @exit_value_vector_live_in(ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next.1, %loop ]\n %gep = getelementptr i16, ptr %dst, i64 %iv\n store i16 0, ptr %gep, align 2\n %iv.next.1 = add i64 %iv, 1\n %ec = icmp ult i64 %iv, 1000\n br i1 %ec, label %loop, label %exit\n\nexit: ; preds = %loop\n %res = phi <2 x i64> [ zeroinitializer, %loop ]\n ret <2 x i64> %res\n}\n"}, {"test_name": "exit_value_scalar_live_in", "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine i64 @exit_value_scalar_live_in(ptr %dst, i64 %in) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next.1, %loop ]\n %gep = getelementptr i16, ptr %dst, i64 %iv\n store i16 0, ptr %gep, align 2\n %iv.next.1 = add i64 %iv, 1\n %ec = icmp ult i64 %iv, 1000\n br i1 %ec, label %loop, label %exit\n\nexit: ; preds = %loop\n %res = phi i64 [ %in, %loop ]\n ret i64 %res\n}\n"}]}], "issue": {"title": "[LoopVectorize] Assertion `(GeneratedValue->getType()->isVectorTy() == !GeneratesPerFirstLaneOnly || State.VF.isScalar()) && \"scalar value but not only first lane defined\"' failed.", "body": "Testcase:\r\n```llvm ir\r\n; ModuleID = 'reduced.bc'\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine fastcc void @g() #0 {\r\nfor.cond1.preheader.us.preheader:\r\n br label %for.cond.cleanup20.us.us.1\r\n\r\nfor.cond.cleanup20.us.us.1: ; preds = %for.cond.cleanup20.us.us.1, %for.cond1.preheader.us.preheader\r\n %indvars.iv.1 = phi i64 [ 0, %for.cond1.preheader.us.preheader ], [ %indvars.iv.next.1, %for.cond.cleanup20.us.us.1 ]\r\n %arrayidx.us.us.1 = getelementptr [0 x i16], ptr null, i64 0, i64 %indvars.iv.1\r\n store i16 0, ptr %arrayidx.us.us.1, align 2\r\n %indvars.iv.next.1 = add i64 %indvars.iv.1, 1\r\n %cmp12.us.us.1 = icmp ult i64 %indvars.iv.1, 1\r\n br i1 %cmp12.us.us.1, label %for.cond.cleanup20.us.us.1, label %for.cond.cleanup14.us.us.1\r\n\r\nfor.cond.cleanup14.us.us.1: ; preds = %for.cond.cleanup20.us.us.1\r\n %.lcssa.1 = phi <2 x i64> [ zeroinitializer, %for.cond.cleanup20.us.us.1 ]\r\n ret void\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-b,-e,-experimental-smctr,-experimental-smmpm,-experimental-smnpm,-experimental-ssctr,-experimental-ssnpm,-experimental-sspm,-experimental-supm,-experimental-zacas,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-experimental-zvbc32e,-experimental-zvkgs,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smepmp,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssqosid,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zaamo,-zabha,-zalrsc,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-ztso,-zvbb,-zvbc,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\n```\r\nhttps://godbolt.org/z/aoe8vdc1f\r\n\r\nCommand/backtrace:\r\n```\r\n> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize -S reduced.ll\r\nopt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp:732: virtual void llvm::VPInstruction::execute(llvm::VPTransformState&): Assertion `(GeneratedValue->getType()->isVectorTy() == !GeneratesPerFirstLaneOnly || State.VF.isScalar()) && \"scalar value but not only first lane defined\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize -S reduced.ll\r\n1. Running pass \"function(loop-vectorize)\" on module \"reduced.ll\"\r\n2. Running pass \"loop-vectorize\" on function \"g\"\r\n #0 0x0000644a7eb61500 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x300e500)\r\n #1 0x0000644a7eb5e91f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x300b91f)\r\n #2 0x0000644a7eb5ea75 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x0000790e6c842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x0000790e6c8969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x0000790e6c8969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x0000790e6c8969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x0000790e6c842476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x0000790e6c8287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x0000790e6c82871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x0000790e6c839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x0000644a7dc8e57a llvm::VPInstruction::execute(llvm::VPTransformState&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x213b57a)\r\n#12 0x0000644a7dc4f617 llvm::VPBasicBlock::executeRecipes(llvm::VPTransformState*, llvm::BasicBlock*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20fc617)\r\n#13 0x0000644a7dc4f910 llvm::VPIRBasicBlock::execute(llvm::VPTransformState*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20fc910)\r\n#14 0x0000644a7dc51c2d llvm::VPlan::execute(llvm::VPTransformState*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20fec2d)\r\n#15 0x0000644a7db37af9 llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool, llvm::DenseMap, llvm::detail::DenseMapPair> const*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1fe4af9)\r\n#16 0x0000644a7db4afce llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1ff7fce)\r\n#17 0x0000644a7db4d101 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1ffa101)\r\n#18 0x0000644a7db4d777 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1ffa777)\r\n#19 0x0000644a7c9b0a46 llvm::detail::PassModel>::run(llvm::Function&, llvm::AnalysisManager&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe5da46)\r\n#20 0x0000644a7e96c95f llvm::PassManager>::run(llvm::Function&, llvm::AnalysisManager&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e1995f)\r\n#21 0x0000644a7c9b3bd6 llvm::detail::PassModel>, llvm::AnalysisManager>::run(llvm::Function&, llvm::AnalysisManager&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe60bd6)\r\n#22 0x0000644a7e96b6db llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e186db)\r\n#23 0x0000644a7c9afe76 llvm::detail::PassModel>::run(llvm::Module&, llvm::AnalysisManager&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe5ce76)\r\n#24 0x0000644a7e96971d llvm::PassManager>::run(llvm::Module&, llvm::AnalysisManager&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e1671d)\r\n#25 0x0000644a7c1d9e36 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef, llvm::ArrayRef>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x686e36)\r\n#26 0x0000644a7c1cbbc1 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x678bc1)\r\n#27 0x0000790e6c829d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#28 0x0000790e6c829e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#29 0x0000790e6c829e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#30 0x0000644a7c1c1f75 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x66ef75)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\n\r\nFound via fuzzer", "author": "patrick-rivos", "labels": ["vectorizers", "crash"], "comments": []}, "verified": true} {"bug_id": "108098", "issue_url": "https://github.com/llvm/llvm-project/issues/108098", "bug_type": "crash", "base_commit": "b8239e1201f5871bed5b633b76fa9536672f287f", "knowledge_cutoff": "2024-09-10T21:48:37Z", "lit_test_dir": ["llvm/test/Analysis/CostModel", "llvm/test/Transforms/LoopVectorize"], "hints": {"fix_commit": "ea83e1c05a5adee5d8f9e680356ee57556ba64a1", "components": ["LoopVectorize"], "bug_location_lineno": {"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [[1182, 1194]]}, "bug_location_funcname": {"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": ["setWideningDecision"]}}, "patch": "commit ea83e1c05a5adee5d8f9e680356ee57556ba64a1\nAuthor: Florian Hahn \nDate: Wed Sep 11 21:04:33 2024 +0100\n\n [LV] Assign cost to all interleave members when not interleaving.\n \n At the moment, the full cost of all interleave group members is assigned\n to the instruction at the group's insert position, even if the decision\n was to not form an interleave group.\n \n This can lead to inaccurate cost estimates, e.g. if the instruction at\n the insert position is dead. If the decision is to not vectorize but\n scalarize or scather/gather, then the cost will be to total cost for all\n members. In those cases, assign individual the cost per member, to more\n closely reflect to choice per instruction.\n \n This fixes a divergence between legacy and VPlan-based cost model.\n \n Fixes https://github.com/llvm/llvm-project/issues/108098.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\nindex 640a7bf3d672..3b6b154b9660 100644\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n@@ -1182,13 +1182,23 @@ public:\n InstructionCost Cost) {\n assert(VF.isVector() && \"Expected VF >=2\");\n /// Broadcast this decicion to all instructions inside the group.\n- /// But the cost will be assigned to one instruction only.\n+ /// When interleaving, the cost will only be assigned one instruction, the\n+ /// insert position. For other cases, add the appropriate fraction of the\n+ /// total cost to each instruction. This ensures accurate costs are used,\n+ /// even if the insert position instruction is not used.\n+ InstructionCost InsertPosCost = Cost;\n+ InstructionCost OtherMemberCost = 0;\n+ if (W != CM_Interleave)\n+ OtherMemberCost = InsertPosCost = Cost / Grp->getNumMembers();\n+ ;\n for (unsigned Idx = 0; Idx < Grp->getFactor(); ++Idx) {\n if (auto *I = Grp->getMember(Idx)) {\n if (Grp->getInsertPos() == I)\n- WideningDecisions[std::make_pair(I, VF)] = std::make_pair(W, Cost);\n+ WideningDecisions[std::make_pair(I, VF)] =\n+ std::make_pair(W, InsertPosCost);\n else\n- WideningDecisions[std::make_pair(I, VF)] = std::make_pair(W, 0);\n+ WideningDecisions[std::make_pair(I, VF)] =\n+ std::make_pair(W, OtherMemberCost);\n }\n }\n }\n", "tests": [{"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-f32-stride-5.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x float], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %in0 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.4\n %v0 = load float, ptr %in0, align 4\n %v1 = load float, ptr %in1, align 4\n %v2 = load float, ptr %in2, align 4\n %v3 = load float, ptr %in3, align 4\n %v4 = load float, ptr %in4, align 4\n %reduce.add.0 = fadd float %v0, %v1\n %reduce.add.1 = fadd float %reduce.add.0, %v2\n %reduce.add.2 = fadd float %reduce.add.1, %v3\n %reduce.add.3 = fadd float %reduce.add.2, %v4\n %reduce.add.3.narrow = fptoui float %reduce.add.3 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.3.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 5\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-f32-stride-7.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x float], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %iv.6 = add nuw nsw i64 %iv, 6\n %in0 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.4\n %in5 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.5\n %in6 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.6\n %v0 = load float, ptr %in0, align 4\n %v1 = load float, ptr %in1, align 4\n %v2 = load float, ptr %in2, align 4\n %v3 = load float, ptr %in3, align 4\n %v4 = load float, ptr %in4, align 4\n %v5 = load float, ptr %in5, align 4\n %v6 = load float, ptr %in6, align 4\n %reduce.add.0 = fadd float %v0, %v1\n %reduce.add.1 = fadd float %reduce.add.0, %v2\n %reduce.add.2 = fadd float %reduce.add.1, %v3\n %reduce.add.3 = fadd float %reduce.add.2, %v4\n %reduce.add.4 = fadd float %reduce.add.3, %v5\n %reduce.add.5 = fadd float %reduce.add.4, %v6\n %reduce.add.5.narrow = fptoui float %reduce.add.5 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.5.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 7\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-f32-stride-8.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x float], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %iv.6 = add nuw nsw i64 %iv, 6\n %iv.7 = add nuw nsw i64 %iv, 7\n %in0 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.4\n %in5 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.5\n %in6 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.6\n %in7 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.7\n %v0 = load float, ptr %in0, align 4\n %v1 = load float, ptr %in1, align 4\n %v2 = load float, ptr %in2, align 4\n %v3 = load float, ptr %in3, align 4\n %v4 = load float, ptr %in4, align 4\n %v5 = load float, ptr %in5, align 4\n %v6 = load float, ptr %in6, align 4\n %v7 = load float, ptr %in7, align 4\n %reduce.add.0 = fadd float %v0, %v1\n %reduce.add.1 = fadd float %reduce.add.0, %v2\n %reduce.add.2 = fadd float %reduce.add.1, %v3\n %reduce.add.3 = fadd float %reduce.add.2, %v4\n %reduce.add.4 = fadd float %reduce.add.3, %v5\n %reduce.add.5 = fadd float %reduce.add.4, %v6\n %reduce.add.6 = fadd float %reduce.add.5, %v7\n %reduce.add.6.narrow = fptoui float %reduce.add.6 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.6.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 8\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-f64-stride-2.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x double], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %in0 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.1\n %v0 = load double, ptr %in0, align 8\n %v1 = load double, ptr %in1, align 8\n %reduce.add.0 = fadd double %v0, %v1\n %reduce.add.0.narrow = fptoui double %reduce.add.0 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.0.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 2\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-f64-stride-3.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x double], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %in0 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.2\n %v0 = load double, ptr %in0, align 8\n %v1 = load double, ptr %in1, align 8\n %v2 = load double, ptr %in2, align 8\n %reduce.add.0 = fadd double %v0, %v1\n %reduce.add.1 = fadd double %reduce.add.0, %v2\n %reduce.add.1.narrow = fptoui double %reduce.add.1 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.1.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 3\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-f64-stride-4.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x double], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %in0 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.3\n %v0 = load double, ptr %in0, align 8\n %v1 = load double, ptr %in1, align 8\n %v2 = load double, ptr %in2, align 8\n %v3 = load double, ptr %in3, align 8\n %reduce.add.0 = fadd double %v0, %v1\n %reduce.add.1 = fadd double %reduce.add.0, %v2\n %reduce.add.2 = fadd double %reduce.add.1, %v3\n %reduce.add.2.narrow = fptoui double %reduce.add.2 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.2.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 4\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-f64-stride-5.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x double], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %in0 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.4\n %v0 = load double, ptr %in0, align 8\n %v1 = load double, ptr %in1, align 8\n %v2 = load double, ptr %in2, align 8\n %v3 = load double, ptr %in3, align 8\n %v4 = load double, ptr %in4, align 8\n %reduce.add.0 = fadd double %v0, %v1\n %reduce.add.1 = fadd double %reduce.add.0, %v2\n %reduce.add.2 = fadd double %reduce.add.1, %v3\n %reduce.add.3 = fadd double %reduce.add.2, %v4\n %reduce.add.3.narrow = fptoui double %reduce.add.3 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.3.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 5\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-f64-stride-6.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x double], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %in0 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.4\n %in5 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.5\n %v0 = load double, ptr %in0, align 8\n %v1 = load double, ptr %in1, align 8\n %v2 = load double, ptr %in2, align 8\n %v3 = load double, ptr %in3, align 8\n %v4 = load double, ptr %in4, align 8\n %v5 = load double, ptr %in5, align 8\n %reduce.add.0 = fadd double %v0, %v1\n %reduce.add.1 = fadd double %reduce.add.0, %v2\n %reduce.add.2 = fadd double %reduce.add.1, %v3\n %reduce.add.3 = fadd double %reduce.add.2, %v4\n %reduce.add.4 = fadd double %reduce.add.3, %v5\n %reduce.add.4.narrow = fptoui double %reduce.add.4 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.4.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 6\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-f64-stride-7.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x double], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %iv.6 = add nuw nsw i64 %iv, 6\n %in0 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.4\n %in5 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.5\n %in6 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.6\n %v0 = load double, ptr %in0, align 8\n %v1 = load double, ptr %in1, align 8\n %v2 = load double, ptr %in2, align 8\n %v3 = load double, ptr %in3, align 8\n %v4 = load double, ptr %in4, align 8\n %v5 = load double, ptr %in5, align 8\n %v6 = load double, ptr %in6, align 8\n %reduce.add.0 = fadd double %v0, %v1\n %reduce.add.1 = fadd double %reduce.add.0, %v2\n %reduce.add.2 = fadd double %reduce.add.1, %v3\n %reduce.add.3 = fadd double %reduce.add.2, %v4\n %reduce.add.4 = fadd double %reduce.add.3, %v5\n %reduce.add.5 = fadd double %reduce.add.4, %v6\n %reduce.add.5.narrow = fptoui double %reduce.add.5 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.5.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 7\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-f64-stride-8.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x double], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %iv.6 = add nuw nsw i64 %iv, 6\n %iv.7 = add nuw nsw i64 %iv, 7\n %in0 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.4\n %in5 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.5\n %in6 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.6\n %in7 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.7\n %v0 = load double, ptr %in0, align 8\n %v1 = load double, ptr %in1, align 8\n %v2 = load double, ptr %in2, align 8\n %v3 = load double, ptr %in3, align 8\n %v4 = load double, ptr %in4, align 8\n %v5 = load double, ptr %in5, align 8\n %v6 = load double, ptr %in6, align 8\n %v7 = load double, ptr %in7, align 8\n %reduce.add.0 = fadd double %v0, %v1\n %reduce.add.1 = fadd double %reduce.add.0, %v2\n %reduce.add.2 = fadd double %reduce.add.1, %v3\n %reduce.add.3 = fadd double %reduce.add.2, %v4\n %reduce.add.4 = fadd double %reduce.add.3, %v5\n %reduce.add.5 = fadd double %reduce.add.4, %v6\n %reduce.add.6 = fadd double %reduce.add.5, %v7\n %reduce.add.6.narrow = fptoui double %reduce.add.6 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.6.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 8\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i16-stride-5.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl,+avx512bw --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i16], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %in0 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.4\n %v0 = load i16, ptr %in0, align 2\n %v1 = load i16, ptr %in1, align 2\n %v2 = load i16, ptr %in2, align 2\n %v3 = load i16, ptr %in3, align 2\n %v4 = load i16, ptr %in4, align 2\n %reduce.add.0 = add i16 %v0, %v1\n %reduce.add.1 = add i16 %reduce.add.0, %v2\n %reduce.add.2 = add i16 %reduce.add.1, %v3\n %reduce.add.3 = add i16 %reduce.add.2, %v4\n %reduce.add.3.narrow = trunc i16 %reduce.add.3 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.3.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 5\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i16-stride-7.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl,+avx512bw --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i16], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %iv.6 = add nuw nsw i64 %iv, 6\n %in0 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.4\n %in5 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.5\n %in6 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.6\n %v0 = load i16, ptr %in0, align 2\n %v1 = load i16, ptr %in1, align 2\n %v2 = load i16, ptr %in2, align 2\n %v3 = load i16, ptr %in3, align 2\n %v4 = load i16, ptr %in4, align 2\n %v5 = load i16, ptr %in5, align 2\n %v6 = load i16, ptr %in6, align 2\n %reduce.add.0 = add i16 %v0, %v1\n %reduce.add.1 = add i16 %reduce.add.0, %v2\n %reduce.add.2 = add i16 %reduce.add.1, %v3\n %reduce.add.3 = add i16 %reduce.add.2, %v4\n %reduce.add.4 = add i16 %reduce.add.3, %v5\n %reduce.add.5 = add i16 %reduce.add.4, %v6\n %reduce.add.5.narrow = trunc i16 %reduce.add.5 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.5.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 7\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i16-stride-8.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl,+avx512bw --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i16], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %iv.6 = add nuw nsw i64 %iv, 6\n %iv.7 = add nuw nsw i64 %iv, 7\n %in0 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.4\n %in5 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.5\n %in6 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.6\n %in7 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.7\n %v0 = load i16, ptr %in0, align 2\n %v1 = load i16, ptr %in1, align 2\n %v2 = load i16, ptr %in2, align 2\n %v3 = load i16, ptr %in3, align 2\n %v4 = load i16, ptr %in4, align 2\n %v5 = load i16, ptr %in5, align 2\n %v6 = load i16, ptr %in6, align 2\n %v7 = load i16, ptr %in7, align 2\n %reduce.add.0 = add i16 %v0, %v1\n %reduce.add.1 = add i16 %reduce.add.0, %v2\n %reduce.add.2 = add i16 %reduce.add.1, %v3\n %reduce.add.3 = add i16 %reduce.add.2, %v4\n %reduce.add.4 = add i16 %reduce.add.3, %v5\n %reduce.add.5 = add i16 %reduce.add.4, %v6\n %reduce.add.6 = add i16 %reduce.add.5, %v7\n %reduce.add.6.narrow = trunc i16 %reduce.add.6 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.6.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 8\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i32-stride-4-indices-01uu.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i32], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %in0 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.1\n %v0 = load i32, ptr %in0, align 4\n %v1 = load i32, ptr %in1, align 4\n %reduce.add.0 = add i32 %v0, %v1\n %reduce.add.1 = add i32 %reduce.add.0, 0\n %reduce.add.2 = add i32 %reduce.add.1, 0\n %reduce.add.2.narrow = trunc i32 %reduce.add.2 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.2.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv, 4\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i32-stride-5.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i32], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %in0 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.4\n %v0 = load i32, ptr %in0, align 4\n %v1 = load i32, ptr %in1, align 4\n %v2 = load i32, ptr %in2, align 4\n %v3 = load i32, ptr %in3, align 4\n %v4 = load i32, ptr %in4, align 4\n %reduce.add.0 = add i32 %v0, %v1\n %reduce.add.1 = add i32 %reduce.add.0, %v2\n %reduce.add.2 = add i32 %reduce.add.1, %v3\n %reduce.add.3 = add i32 %reduce.add.2, %v4\n %reduce.add.3.narrow = trunc i32 %reduce.add.3 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.3.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 5\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i32-stride-7.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i32], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %iv.6 = add nuw nsw i64 %iv, 6\n %in0 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.4\n %in5 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.5\n %in6 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.6\n %v0 = load i32, ptr %in0, align 4\n %v1 = load i32, ptr %in1, align 4\n %v2 = load i32, ptr %in2, align 4\n %v3 = load i32, ptr %in3, align 4\n %v4 = load i32, ptr %in4, align 4\n %v5 = load i32, ptr %in5, align 4\n %v6 = load i32, ptr %in6, align 4\n %reduce.add.0 = add i32 %v0, %v1\n %reduce.add.1 = add i32 %reduce.add.0, %v2\n %reduce.add.2 = add i32 %reduce.add.1, %v3\n %reduce.add.3 = add i32 %reduce.add.2, %v4\n %reduce.add.4 = add i32 %reduce.add.3, %v5\n %reduce.add.5 = add i32 %reduce.add.4, %v6\n %reduce.add.5.narrow = trunc i32 %reduce.add.5 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.5.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 7\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i32-stride-8.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i32], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %iv.6 = add nuw nsw i64 %iv, 6\n %iv.7 = add nuw nsw i64 %iv, 7\n %in0 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.4\n %in5 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.5\n %in6 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.6\n %in7 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.7\n %v0 = load i32, ptr %in0, align 4\n %v1 = load i32, ptr %in1, align 4\n %v2 = load i32, ptr %in2, align 4\n %v3 = load i32, ptr %in3, align 4\n %v4 = load i32, ptr %in4, align 4\n %v5 = load i32, ptr %in5, align 4\n %v6 = load i32, ptr %in6, align 4\n %v7 = load i32, ptr %in7, align 4\n %reduce.add.0 = add i32 %v0, %v1\n %reduce.add.1 = add i32 %reduce.add.0, %v2\n %reduce.add.2 = add i32 %reduce.add.1, %v3\n %reduce.add.3 = add i32 %reduce.add.2, %v4\n %reduce.add.4 = add i32 %reduce.add.3, %v5\n %reduce.add.5 = add i32 %reduce.add.4, %v6\n %reduce.add.6 = add i32 %reduce.add.5, %v7\n %reduce.add.6.narrow = trunc i32 %reduce.add.6 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.6.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 8\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i64-stride-2.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i64], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %in0 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.1\n %v0 = load i64, ptr %in0, align 8\n %v1 = load i64, ptr %in1, align 8\n %reduce.add.0 = add i64 %v0, %v1\n %reduce.add.0.narrow = trunc i64 %reduce.add.0 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.0.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 2\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i64-stride-3.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i64], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %in0 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.2\n %v0 = load i64, ptr %in0, align 8\n %v1 = load i64, ptr %in1, align 8\n %v2 = load i64, ptr %in2, align 8\n %reduce.add.0 = add i64 %v0, %v1\n %reduce.add.1 = add i64 %reduce.add.0, %v2\n %reduce.add.1.narrow = trunc i64 %reduce.add.1 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.1.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 3\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i64-stride-4.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i64], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %in0 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.3\n %v0 = load i64, ptr %in0, align 8\n %v1 = load i64, ptr %in1, align 8\n %v2 = load i64, ptr %in2, align 8\n %v3 = load i64, ptr %in3, align 8\n %reduce.add.0 = add i64 %v0, %v1\n %reduce.add.1 = add i64 %reduce.add.0, %v2\n %reduce.add.2 = add i64 %reduce.add.1, %v3\n %reduce.add.2.narrow = trunc i64 %reduce.add.2 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.2.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 4\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i64-stride-5.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i64], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %in0 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.4\n %v0 = load i64, ptr %in0, align 8\n %v1 = load i64, ptr %in1, align 8\n %v2 = load i64, ptr %in2, align 8\n %v3 = load i64, ptr %in3, align 8\n %v4 = load i64, ptr %in4, align 8\n %reduce.add.0 = add i64 %v0, %v1\n %reduce.add.1 = add i64 %reduce.add.0, %v2\n %reduce.add.2 = add i64 %reduce.add.1, %v3\n %reduce.add.3 = add i64 %reduce.add.2, %v4\n %reduce.add.3.narrow = trunc i64 %reduce.add.3 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.3.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 5\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i64-stride-6.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i64], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %in0 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.4\n %in5 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.5\n %v0 = load i64, ptr %in0, align 8\n %v1 = load i64, ptr %in1, align 8\n %v2 = load i64, ptr %in2, align 8\n %v3 = load i64, ptr %in3, align 8\n %v4 = load i64, ptr %in4, align 8\n %v5 = load i64, ptr %in5, align 8\n %reduce.add.0 = add i64 %v0, %v1\n %reduce.add.1 = add i64 %reduce.add.0, %v2\n %reduce.add.2 = add i64 %reduce.add.1, %v3\n %reduce.add.3 = add i64 %reduce.add.2, %v4\n %reduce.add.4 = add i64 %reduce.add.3, %v5\n %reduce.add.4.narrow = trunc i64 %reduce.add.4 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.4.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 6\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i64-stride-7.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i64], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %iv.6 = add nuw nsw i64 %iv, 6\n %in0 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.4\n %in5 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.5\n %in6 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.6\n %v0 = load i64, ptr %in0, align 8\n %v1 = load i64, ptr %in1, align 8\n %v2 = load i64, ptr %in2, align 8\n %v3 = load i64, ptr %in3, align 8\n %v4 = load i64, ptr %in4, align 8\n %v5 = load i64, ptr %in5, align 8\n %v6 = load i64, ptr %in6, align 8\n %reduce.add.0 = add i64 %v0, %v1\n %reduce.add.1 = add i64 %reduce.add.0, %v2\n %reduce.add.2 = add i64 %reduce.add.1, %v3\n %reduce.add.3 = add i64 %reduce.add.2, %v4\n %reduce.add.4 = add i64 %reduce.add.3, %v5\n %reduce.add.5 = add i64 %reduce.add.4, %v6\n %reduce.add.5.narrow = trunc i64 %reduce.add.5 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.5.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 7\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i64-stride-8.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i64], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %iv.6 = add nuw nsw i64 %iv, 6\n %iv.7 = add nuw nsw i64 %iv, 7\n %in0 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.4\n %in5 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.5\n %in6 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.6\n %in7 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.7\n %v0 = load i64, ptr %in0, align 8\n %v1 = load i64, ptr %in1, align 8\n %v2 = load i64, ptr %in2, align 8\n %v3 = load i64, ptr %in3, align 8\n %v4 = load i64, ptr %in4, align 8\n %v5 = load i64, ptr %in5, align 8\n %v6 = load i64, ptr %in6, align 8\n %v7 = load i64, ptr %in7, align 8\n %reduce.add.0 = add i64 %v0, %v1\n %reduce.add.1 = add i64 %reduce.add.0, %v2\n %reduce.add.2 = add i64 %reduce.add.1, %v3\n %reduce.add.3 = add i64 %reduce.add.2, %v4\n %reduce.add.4 = add i64 %reduce.add.3, %v5\n %reduce.add.5 = add i64 %reduce.add.4, %v6\n %reduce.add.6 = add i64 %reduce.add.5, %v7\n %reduce.add.6.narrow = trunc i64 %reduce.add.6 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.6.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 8\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i8-stride-5.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl,+avx512bw --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i8], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %in0 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.4\n %v0 = load i8, ptr %in0, align 1\n %v1 = load i8, ptr %in1, align 1\n %v2 = load i8, ptr %in2, align 1\n %v3 = load i8, ptr %in3, align 1\n %v4 = load i8, ptr %in4, align 1\n %reduce.add.0 = add i8 %v0, %v1\n %reduce.add.1 = add i8 %reduce.add.0, %v2\n %reduce.add.2 = add i8 %reduce.add.1, %v3\n %reduce.add.3 = add i8 %reduce.add.2, %v4\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.3, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 5\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i8-stride-7.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl,+avx512bw --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i8], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %iv.6 = add nuw nsw i64 %iv, 6\n %in0 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.4\n %in5 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.5\n %in6 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.6\n %v0 = load i8, ptr %in0, align 1\n %v1 = load i8, ptr %in1, align 1\n %v2 = load i8, ptr %in2, align 1\n %v3 = load i8, ptr %in3, align 1\n %v4 = load i8, ptr %in4, align 1\n %v5 = load i8, ptr %in5, align 1\n %v6 = load i8, ptr %in6, align 1\n %reduce.add.0 = add i8 %v0, %v1\n %reduce.add.1 = add i8 %reduce.add.0, %v2\n %reduce.add.2 = add i8 %reduce.add.1, %v3\n %reduce.add.3 = add i8 %reduce.add.2, %v4\n %reduce.add.4 = add i8 %reduce.add.3, %v5\n %reduce.add.5 = add i8 %reduce.add.4, %v6\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.5, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 7\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i8-stride-8.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl,+avx512bw --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i8], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %iv.6 = add nuw nsw i64 %iv, 6\n %iv.7 = add nuw nsw i64 %iv, 7\n %in0 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.4\n %in5 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.5\n %in6 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.6\n %in7 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.7\n %v0 = load i8, ptr %in0, align 1\n %v1 = load i8, ptr %in1, align 1\n %v2 = load i8, ptr %in2, align 1\n %v3 = load i8, ptr %in3, align 1\n %v4 = load i8, ptr %in4, align 1\n %v5 = load i8, ptr %in5, align 1\n %v6 = load i8, ptr %in6, align 1\n %v7 = load i8, ptr %in7, align 1\n %reduce.add.0 = add i8 %v0, %v1\n %reduce.add.1 = add i8 %reduce.add.0, %v2\n %reduce.add.2 = add i8 %reduce.add.1, %v3\n %reduce.add.3 = add i8 %reduce.add.2, %v4\n %reduce.add.4 = add i8 %reduce.add.3, %v5\n %reduce.add.5 = add i8 %reduce.add.4, %v6\n %reduce.add.6 = add i8 %reduce.add.5, %v7\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.6, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 8\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/interleaved-store-f64-stride-8.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i8], align 128\n@B = external global [1024 x double], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %iv.6 = add nuw nsw i64 %iv, 6\n %iv.7 = add nuw nsw i64 %iv, 7\n %in = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.0\n %v.narrow = load i8, ptr %in, align 1\n %v = uitofp i8 %v.narrow to double\n %v0 = fadd double %v, 0.000000e+00\n %v1 = fadd double %v, 1.000000e+00\n %v2 = fadd double %v, 2.000000e+00\n %v3 = fadd double %v, 3.000000e+00\n %v4 = fadd double %v, 4.000000e+00\n %v5 = fadd double %v, 5.000000e+00\n %v6 = fadd double %v, 6.000000e+00\n %v7 = fadd double %v, 7.000000e+00\n %out0 = getelementptr inbounds [1024 x double], ptr @B, i64 0, i64 %iv.0\n %out1 = getelementptr inbounds [1024 x double], ptr @B, i64 0, i64 %iv.1\n %out2 = getelementptr inbounds [1024 x double], ptr @B, i64 0, i64 %iv.2\n %out3 = getelementptr inbounds [1024 x double], ptr @B, i64 0, i64 %iv.3\n %out4 = getelementptr inbounds [1024 x double], ptr @B, i64 0, i64 %iv.4\n %out5 = getelementptr inbounds [1024 x double], ptr @B, i64 0, i64 %iv.5\n %out6 = getelementptr inbounds [1024 x double], ptr @B, i64 0, i64 %iv.6\n %out7 = getelementptr inbounds [1024 x double], ptr @B, i64 0, i64 %iv.7\n store double %v0, ptr %out0, align 8\n store double %v1, ptr %out1, align 8\n store double %v2, ptr %out2, align 8\n store double %v3, ptr %out3, align 8\n store double %v4, ptr %out4, align 8\n store double %v5, ptr %out5, align 8\n store double %v6, ptr %out6, align 8\n store double %v7, ptr %out7, align 8\n %iv.next = add nuw nsw i64 %iv.0, 8\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/interleaved-store-i64-stride-8.ll", "commands": ["opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i8], align 128\n@B = external global [1024 x i64], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %iv.6 = add nuw nsw i64 %iv, 6\n %iv.7 = add nuw nsw i64 %iv, 7\n %in = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.0\n %v.narrow = load i8, ptr %in, align 1\n %v = zext i8 %v.narrow to i64\n %v0 = add i64 %v, 0\n %v1 = add i64 %v, 1\n %v2 = add i64 %v, 2\n %v3 = add i64 %v, 3\n %v4 = add i64 %v, 4\n %v5 = add i64 %v, 5\n %v6 = add i64 %v, 6\n %v7 = add i64 %v, 7\n %out0 = getelementptr inbounds [1024 x i64], ptr @B, i64 0, i64 %iv.0\n %out1 = getelementptr inbounds [1024 x i64], ptr @B, i64 0, i64 %iv.1\n %out2 = getelementptr inbounds [1024 x i64], ptr @B, i64 0, i64 %iv.2\n %out3 = getelementptr inbounds [1024 x i64], ptr @B, i64 0, i64 %iv.3\n %out4 = getelementptr inbounds [1024 x i64], ptr @B, i64 0, i64 %iv.4\n %out5 = getelementptr inbounds [1024 x i64], ptr @B, i64 0, i64 %iv.5\n %out6 = getelementptr inbounds [1024 x i64], ptr @B, i64 0, i64 %iv.6\n %out7 = getelementptr inbounds [1024 x i64], ptr @B, i64 0, i64 %iv.7\n store i64 %v0, ptr %out0, align 8\n store i64 %v1, ptr %out1, align 8\n store i64 %v2, ptr %out2, align 8\n store i64 %v3, ptr %out3, align 8\n store i64 %v4, ptr %out4, align 8\n store i64 %v5, ptr %out5, align 8\n store i64 %v6, ptr %out6, align 8\n store i64 %v7, ptr %out7, align 8\n %iv.next = add nuw nsw i64 %iv.0, 8\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Analysis/CostModel/X86/masked-interleaved-store-i16.ll", "commands": ["opt -passes=loop-vectorize -enable-interleaved-mem-accesses -prefer-predicate-over-epilogue=predicate-dont-vectorize -S -mcpu=skx --debug-only=loop-vectorize < %s 2>&1", "opt -passes=loop-vectorize -enable-interleaved-mem-accesses -enable-masked-interleaved-mem-accesses -prefer-predicate-over-epilogue=predicate-dont-vectorize -S -mcpu=skx --debug-only=loop-vectorize < %s 2>&1"], "tests": [{"test_name": "test2", "test_body": "target datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @test2(ptr noalias nocapture %points, i32 %numPoints, ptr noalias nocapture readonly %x, ptr noalias nocapture readonly %y) {\nentry:\n %cmp15 = icmp sgt i32 %numPoints, 0\n br i1 %cmp15, label %for.body.preheader, label %for.end\n\nfor.body.preheader: ; preds = %entry\n %wide.trip.count = zext i32 %numPoints to i64\n br label %for.body\n\nfor.body: ; preds = %for.body, %for.body.preheader\n %indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]\n %arrayidx = getelementptr inbounds i16, ptr %x, i64 %indvars.iv\n %0 = load i16, ptr %arrayidx, align 2\n %1 = shl nsw i64 %indvars.iv, 2\n %arrayidx2 = getelementptr inbounds i16, ptr %points, i64 %1\n store i16 %0, ptr %arrayidx2, align 2\n %arrayidx4 = getelementptr inbounds i16, ptr %y, i64 %indvars.iv\n %2 = load i16, ptr %arrayidx4, align 2\n %3 = or disjoint i64 %1, 1\n %arrayidx7 = getelementptr inbounds i16, ptr %points, i64 %3\n store i16 %2, ptr %arrayidx7, align 2\n %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1\n %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count\n br i1 %exitcond.not, label %for.end.loopexit, label %for.body\n\nfor.end.loopexit: ; preds = %for.body\n br label %for.end\n\nfor.end: ; preds = %for.end.loopexit, %entry\n ret void\n}\n"}, {"test_name": "test1", "test_body": "target datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @test1(ptr noalias nocapture %points, ptr noalias nocapture readonly %x, ptr noalias nocapture readonly %y) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]\n %arrayidx = getelementptr inbounds i16, ptr %x, i64 %indvars.iv\n %0 = load i16, ptr %arrayidx, align 2\n %1 = shl nuw nsw i64 %indvars.iv, 2\n %arrayidx2 = getelementptr inbounds i16, ptr %points, i64 %1\n store i16 %0, ptr %arrayidx2, align 2\n %arrayidx4 = getelementptr inbounds i16, ptr %y, i64 %indvars.iv\n %2 = load i16, ptr %arrayidx4, align 2\n %3 = or disjoint i64 %1, 1\n %arrayidx7 = getelementptr inbounds i16, ptr %points, i64 %3\n store i16 %2, ptr %arrayidx7, align 2\n %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1\n %exitcond.not = icmp eq i64 %indvars.iv.next, 1024\n br i1 %exitcond.not, label %for.end, label %for.body\n\nfor.end: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Transforms/LoopVectorize/AArch64/interleaved-vs-scalar.ll", "commands": ["opt < %s -force-vector-width=2 -force-vector-interleave=1 -passes=loop-vectorize -S --debug-only=loop-vectorize 2>&1"], "tests": [{"test_name": "test", "test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64--linux-gnu\"\n\n%pair = type { i8, i8 }\n\ndefine void @test(ptr %p, ptr %q, i64 %n) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr %pair, ptr %p, i64 %i, i32 0\n %tmp1 = load i8, ptr %tmp0, align 1\n %tmp2 = getelementptr %pair, ptr %p, i64 %i, i32 1\n %tmp3 = load i8, ptr %tmp2, align 1\n %add = add i8 %tmp1, %tmp3\n %qi = getelementptr i8, ptr %q, i64 %i\n store i8 %add, ptr %qi, align 1\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp eq i64 %i.next, %n\n br i1 %cond, label %for.end, label %for.body\n\nfor.end: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Transforms/LoopVectorize/AArch64/interleaved_cost.ll", "commands": ["opt -passes=loop-vectorize -force-vector-width=2 -debug-only=loop-vectorize -disable-output < %s 2>&1", "opt -passes=loop-vectorize -force-vector-width=4 -debug-only=loop-vectorize -disable-output < %s 2>&1", "opt -passes=loop-vectorize -force-vector-width=8 -debug-only=loop-vectorize -disable-output < %s 2>&1", "opt -passes=loop-vectorize -force-vector-width=16 -debug-only=loop-vectorize -disable-output < %s 2>&1"], "tests": [{"test_name": "i8_factor_2", "test_body": "target datalayout = \"e-m:e-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64\"\n\n%i8.2 = type { i8, i8 }\n\ndefine void @i8_factor_2(ptr %data, i64 %n) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i8.2, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i8.2, ptr %data, i64 %i, i32 1\n %tmp2 = load i8, ptr %tmp0, align 1\n %tmp3 = load i8, ptr %tmp1, align 1\n store i8 %tmp2, ptr %tmp0, align 1\n store i8 %tmp3, ptr %tmp1, align 1\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n"}, {"test_name": "i16_factor_2", "test_body": "target datalayout = \"e-m:e-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64\"\n\n%i16.2 = type { i16, i16 }\n\ndefine void @i16_factor_2(ptr %data, i64 %n) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i16.2, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i16.2, ptr %data, i64 %i, i32 1\n %tmp2 = load i16, ptr %tmp0, align 2\n %tmp3 = load i16, ptr %tmp1, align 2\n store i16 %tmp2, ptr %tmp0, align 2\n store i16 %tmp3, ptr %tmp1, align 2\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n"}, {"test_name": "i32_factor_2", "test_body": "target datalayout = \"e-m:e-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64\"\n\n%i32.2 = type { i32, i32 }\n\ndefine void @i32_factor_2(ptr %data, i64 %n) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i32.2, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i32.2, ptr %data, i64 %i, i32 1\n %tmp2 = load i32, ptr %tmp0, align 4\n %tmp3 = load i32, ptr %tmp1, align 4\n store i32 %tmp2, ptr %tmp0, align 4\n store i32 %tmp3, ptr %tmp1, align 4\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n"}, {"test_name": "i64_factor_2", "test_body": "target datalayout = \"e-m:e-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64\"\n\n%i64.2 = type { i64, i64 }\n\ndefine void @i64_factor_2(ptr %data, i64 %n) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i64.2, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i64.2, ptr %data, i64 %i, i32 1\n %tmp2 = load i64, ptr %tmp0, align 8\n %tmp3 = load i64, ptr %tmp1, align 8\n store i64 %tmp2, ptr %tmp0, align 8\n store i64 %tmp3, ptr %tmp1, align 8\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n"}, {"test_name": "i64_factor_8", "test_body": "target datalayout = \"e-m:e-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64\"\n\n%i64.8 = type { i64, i64, i64, i64, i64, i64, i64, i64 }\n\ndefine void @i64_factor_8(ptr %data, i64 %n) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i64.8, ptr %data, i64 %i, i32 2\n %tmp1 = getelementptr inbounds %i64.8, ptr %data, i64 %i, i32 6\n %tmp2 = load i64, ptr %tmp0, align 8\n %tmp3 = load i64, ptr %tmp1, align 8\n store i64 %tmp2, ptr %tmp0, align 8\n store i64 %tmp3, ptr %tmp1, align 8\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n"}]}, {"file": "llvm/test/Transforms/LoopVectorize/ARM/mve-interleaved-cost.ll", "commands": ["opt -passes=loop-vectorize -force-vector-width=2 -debug-only=loop-vectorize -disable-output < %s 2>&1", "opt -passes=loop-vectorize -force-vector-width=4 -debug-only=loop-vectorize -disable-output < %s 2>&1", "opt -passes=loop-vectorize -force-vector-width=8 -debug-only=loop-vectorize -disable-output < %s 2>&1", "opt -passes=loop-vectorize -force-vector-width=16 -debug-only=loop-vectorize -disable-output < %s 2>&1"], "tests": [{"test_name": "i16_factor_3", "test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%i16.3 = type { i16, i16, i16 }\n\ndefine void @i16_factor_3(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i16.3, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i16.3, ptr %data, i64 %i, i32 1\n %tmp2 = getelementptr inbounds %i16.3, ptr %data, i64 %i, i32 2\n %tmp3 = load i16, ptr %tmp0, align 2\n %tmp4 = load i16, ptr %tmp1, align 2\n %tmp5 = load i16, ptr %tmp2, align 2\n store i16 %tmp3, ptr %tmp0, align 2\n store i16 %tmp4, ptr %tmp1, align 2\n store i16 %tmp5, ptr %tmp2, align 2\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n"}, {"test_name": "f16_factor_2", "test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%f16.2 = type { half, half }\n\ndefine void @f16_factor_2(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %f16.2, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %f16.2, ptr %data, i64 %i, i32 1\n %tmp2 = load half, ptr %tmp0, align 2\n %tmp3 = load half, ptr %tmp1, align 2\n store half %tmp2, ptr %tmp0, align 2\n store half %tmp3, ptr %tmp1, align 2\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n"}, {"test_name": "i32_factor_2", "test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%i32.2 = type { i32, i32 }\n\ndefine void @i32_factor_2(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i32.2, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i32.2, ptr %data, i64 %i, i32 1\n %tmp2 = load i32, ptr %tmp0, align 4\n %tmp3 = load i32, ptr %tmp1, align 4\n store i32 %tmp2, ptr %tmp0, align 4\n store i32 %tmp3, ptr %tmp1, align 4\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n"}, {"test_name": "i64_factor_4", "test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%i64.4 = type { i64, i64, i64, i64 }\n\ndefine void @i64_factor_4(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i64.4, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i64.4, ptr %data, i64 %i, i32 1\n %tmp2 = getelementptr inbounds %i64.4, ptr %data, i64 %i, i32 2\n %tmp3 = getelementptr inbounds %i64.4, ptr %data, i64 %i, i32 3\n %tmp4 = load i64, ptr %tmp0, align 8\n %tmp5 = load i64, ptr %tmp1, align 8\n %tmp6 = load i64, ptr %tmp2, align 8\n %tmp7 = load i64, ptr %tmp3, align 8\n store i64 %tmp4, ptr %tmp0, align 8\n store i64 %tmp5, ptr %tmp1, align 8\n store i64 %tmp6, ptr %tmp2, align 8\n store i64 %tmp7, ptr %tmp3, align 8\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n"}, {"test_name": "f32_factor_3", "test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%f32.3 = type { float, float, float }\n\ndefine void @f32_factor_3(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %f32.3, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %f32.3, ptr %data, i64 %i, i32 1\n %tmp2 = getelementptr inbounds %f32.3, ptr %data, i64 %i, i32 2\n %tmp3 = load float, ptr %tmp0, align 4\n %tmp4 = load float, ptr %tmp1, align 4\n %tmp5 = load float, ptr %tmp2, align 4\n store float %tmp3, ptr %tmp0, align 4\n store float %tmp4, ptr %tmp1, align 4\n store float %tmp5, ptr %tmp2, align 4\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n"}, {"test_name": "i64_factor_3", "test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%i64.3 = type { i64, i64, i64 }\n\ndefine void @i64_factor_3(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i64.3, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i64.3, ptr %data, i64 %i, i32 1\n %tmp2 = getelementptr inbounds %i64.3, ptr %data, i64 %i, i32 2\n %tmp3 = load i64, ptr %tmp0, align 8\n %tmp4 = load i64, ptr %tmp1, align 8\n %tmp5 = load i64, ptr %tmp2, align 8\n store i64 %tmp3, ptr %tmp0, align 8\n store i64 %tmp4, ptr %tmp1, align 8\n store i64 %tmp5, ptr %tmp2, align 8\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n"}, {"test_name": "f16_factor_3", "test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%f16.3 = type { half, half, half }\n\ndefine void @f16_factor_3(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %f16.3, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %f16.3, ptr %data, i64 %i, i32 1\n %tmp2 = getelementptr inbounds %f16.3, ptr %data, i64 %i, i32 2\n %tmp3 = load half, ptr %tmp0, align 2\n %tmp4 = load half, ptr %tmp1, align 2\n %tmp5 = load half, ptr %tmp2, align 2\n store half %tmp3, ptr %tmp0, align 2\n store half %tmp4, ptr %tmp1, align 2\n store half %tmp5, ptr %tmp2, align 2\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n"}, {"test_name": "i8_factor_3", "test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%i8.3 = type { i8, i8, i8 }\n\ndefine void @i8_factor_3(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i8.3, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i8.3, ptr %data, i64 %i, i32 1\n %tmp2 = getelementptr inbounds %i8.3, ptr %data, i64 %i, i32 2\n %tmp3 = load i8, ptr %tmp0, align 1\n %tmp4 = load i8, ptr %tmp1, align 1\n %tmp5 = load i8, ptr %tmp2, align 1\n store i8 %tmp3, ptr %tmp0, align 1\n store i8 %tmp4, ptr %tmp1, align 1\n store i8 %tmp5, ptr %tmp2, align 1\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n"}, {"test_name": "f32_factor_2", "test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%f32.2 = type { float, float }\n\ndefine void @f32_factor_2(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %f32.2, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %f32.2, ptr %data, i64 %i, i32 1\n %tmp2 = load float, ptr %tmp0, align 4\n %tmp3 = load float, ptr %tmp1, align 4\n store float %tmp2, ptr %tmp0, align 4\n store float %tmp3, ptr %tmp1, align 4\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n"}, {"test_name": "i8_factor_4", "test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%i8.4 = type { i8, i8, i8, i8 }\n\ndefine void @i8_factor_4(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i8.4, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i8.4, ptr %data, i64 %i, i32 1\n %tmp2 = getelementptr inbounds %i8.4, ptr %data, i64 %i, i32 2\n %tmp3 = getelementptr inbounds %i8.4, ptr %data, i64 %i, i32 3\n %tmp4 = load i8, ptr %tmp0, align 1\n %tmp5 = load i8, ptr %tmp1, align 1\n %tmp6 = load i8, ptr %tmp2, align 1\n %tmp7 = load i8, ptr %tmp3, align 1\n store i8 %tmp4, ptr %tmp0, align 1\n store i8 %tmp5, ptr %tmp1, align 1\n store i8 %tmp6, ptr %tmp2, align 1\n store i8 %tmp7, ptr %tmp3, align 1\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n"}, {"test_name": "i16_factor_2", "test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%i16.2 = type { i16, i16 }\n\ndefine void @i16_factor_2(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i16.2, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i16.2, ptr %data, i64 %i, i32 1\n %tmp2 = load i16, ptr %tmp0, align 2\n %tmp3 = load i16, ptr %tmp1, align 2\n store i16 %tmp2, ptr %tmp0, align 2\n store i16 %tmp3, ptr %tmp1, align 2\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n"}, {"test_name": "i16_factor_4", "test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%i16.4 = type { i16, i16, i16, i16 }\n\ndefine void @i16_factor_4(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i16.4, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i16.4, ptr %data, i64 %i, i32 1\n %tmp2 = getelementptr inbounds %i16.4, ptr %data, i64 %i, i32 2\n %tmp3 = getelementptr inbounds %i16.4, ptr %data, i64 %i, i32 3\n %tmp4 = load i16, ptr %tmp0, align 2\n %tmp5 = load i16, ptr %tmp1, align 2\n %tmp6 = load i16, ptr %tmp2, align 2\n %tmp7 = load i16, ptr %tmp3, align 2\n store i16 %tmp4, ptr %tmp0, align 2\n store i16 %tmp5, ptr %tmp1, align 2\n store i16 %tmp6, ptr %tmp2, align 2\n store i16 %tmp7, ptr %tmp3, align 2\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n"}, {"test_name": "f64_factor_3", "test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%f64.3 = type { double, double, double }\n\ndefine void @f64_factor_3(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %f64.3, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %f64.3, ptr %data, i64 %i, i32 1\n %tmp2 = getelementptr inbounds %f64.3, ptr %data, i64 %i, i32 2\n %tmp3 = load double, ptr %tmp0, align 8\n %tmp4 = load double, ptr %tmp1, align 8\n %tmp5 = load double, ptr %tmp2, align 8\n store double %tmp3, ptr %tmp0, align 8\n store double %tmp4, ptr %tmp1, align 8\n store double %tmp5, ptr %tmp2, align 8\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n"}, {"test_name": "i8_factor_2", "test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%i8.2 = type { i8, i8 }\n\ndefine void @i8_factor_2(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i8.2, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i8.2, ptr %data, i64 %i, i32 1\n %tmp2 = load i8, ptr %tmp0, align 1\n %tmp3 = load i8, ptr %tmp1, align 1\n store i8 %tmp2, ptr %tmp0, align 1\n store i8 %tmp3, ptr %tmp1, align 1\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n"}, {"test_name": "i32_factor_4", "test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%i32.4 = type { i32, i32, i32, i32 }\n\ndefine void @i32_factor_4(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i32.4, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i32.4, ptr %data, i64 %i, i32 1\n %tmp2 = getelementptr inbounds %i32.4, ptr %data, i64 %i, i32 2\n %tmp3 = getelementptr inbounds %i32.4, ptr %data, i64 %i, i32 3\n %tmp4 = load i32, ptr %tmp0, align 4\n %tmp5 = load i32, ptr %tmp1, align 4\n %tmp6 = load i32, ptr %tmp2, align 4\n %tmp7 = load i32, ptr %tmp3, align 4\n store i32 %tmp4, ptr %tmp0, align 4\n store i32 %tmp5, ptr %tmp1, align 4\n store i32 %tmp6, ptr %tmp2, align 4\n store i32 %tmp7, ptr %tmp3, align 4\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n"}, {"test_name": "i32_factor_3", "test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%i32.3 = type { i32, i32, i32 }\n\ndefine void @i32_factor_3(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i32.3, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i32.3, ptr %data, i64 %i, i32 1\n %tmp2 = getelementptr inbounds %i32.3, ptr %data, i64 %i, i32 2\n %tmp3 = load i32, ptr %tmp0, align 4\n %tmp4 = load i32, ptr %tmp1, align 4\n %tmp5 = load i32, ptr %tmp2, align 4\n store i32 %tmp3, ptr %tmp0, align 4\n store i32 %tmp4, ptr %tmp1, align 4\n store i32 %tmp5, ptr %tmp2, align 4\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n"}, {"test_name": "f64_factor_2", "test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%f64.2 = type { double, double }\n\ndefine void @f64_factor_2(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %f64.2, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %f64.2, ptr %data, i64 %i, i32 1\n %tmp2 = load double, ptr %tmp0, align 8\n %tmp3 = load double, ptr %tmp1, align 8\n store double %tmp2, ptr %tmp0, align 8\n store double %tmp3, ptr %tmp1, align 8\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n"}, {"test_name": "f16_factor_4", "test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%f16.4 = type { half, half, half, half }\n\ndefine void @f16_factor_4(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %f16.4, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %f16.4, ptr %data, i64 %i, i32 1\n %tmp2 = getelementptr inbounds %f16.4, ptr %data, i64 %i, i32 2\n %tmp3 = getelementptr inbounds %f16.4, ptr %data, i64 %i, i32 3\n %tmp4 = load half, ptr %tmp0, align 2\n %tmp5 = load half, ptr %tmp1, align 2\n %tmp6 = load half, ptr %tmp2, align 2\n %tmp7 = load half, ptr %tmp3, align 2\n store half %tmp4, ptr %tmp0, align 2\n store half %tmp5, ptr %tmp1, align 2\n store half %tmp6, ptr %tmp2, align 2\n store half %tmp7, ptr %tmp3, align 2\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n"}, {"test_name": "i64_factor_2", "test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%i64.2 = type { i64, i64 }\n\ndefine void @i64_factor_2(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i64.2, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i64.2, ptr %data, i64 %i, i32 1\n %tmp2 = load i64, ptr %tmp0, align 8\n %tmp3 = load i64, ptr %tmp1, align 8\n store i64 %tmp2, ptr %tmp0, align 8\n store i64 %tmp3, ptr %tmp1, align 8\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n"}, {"test_name": "f64_factor_4", "test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%f64.4 = type { double, double, double, double }\n\ndefine void @f64_factor_4(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %f64.4, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %f64.4, ptr %data, i64 %i, i32 1\n %tmp2 = getelementptr inbounds %f64.4, ptr %data, i64 %i, i32 2\n %tmp3 = getelementptr inbounds %f64.4, ptr %data, i64 %i, i32 3\n %tmp4 = load double, ptr %tmp0, align 8\n %tmp5 = load double, ptr %tmp1, align 8\n %tmp6 = load double, ptr %tmp2, align 8\n %tmp7 = load double, ptr %tmp3, align 8\n store double %tmp4, ptr %tmp0, align 8\n store double %tmp5, ptr %tmp1, align 8\n store double %tmp6, ptr %tmp2, align 8\n store double %tmp7, ptr %tmp3, align 8\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n"}, {"test_name": "f32_factor_4", "test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%f32.4 = type { float, float, float, float }\n\ndefine void @f32_factor_4(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %f32.4, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %f32.4, ptr %data, i64 %i, i32 1\n %tmp2 = getelementptr inbounds %f32.4, ptr %data, i64 %i, i32 2\n %tmp3 = getelementptr inbounds %f32.4, ptr %data, i64 %i, i32 3\n %tmp4 = load float, ptr %tmp0, align 4\n %tmp5 = load float, ptr %tmp1, align 4\n %tmp6 = load float, ptr %tmp2, align 4\n %tmp7 = load float, ptr %tmp3, align 4\n store float %tmp4, ptr %tmp0, align 4\n store float %tmp5, ptr %tmp1, align 4\n store float %tmp6, ptr %tmp2, align 4\n store float %tmp7, ptr %tmp3, align 4\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n"}]}, {"file": "llvm/test/Transforms/LoopVectorize/RISCV/dead-ops-cost.ll", "commands": ["opt -p loop-vectorize -mtriple riscv64-linux-gnu -mattr=+v,+f -S %s"], "tests": [{"test_name": "dead_load", "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine void @dead_load(ptr %p, i16 %start) {\nentry:\n %start.ext = sext i16 %start to i64\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ %start.ext, %entry ], [ %iv.next, %loop ]\n %gep = getelementptr i16, ptr %p, i64 %iv\n store i16 0, ptr %gep, align 2\n %l = load i16, ptr %gep, align 2\n %iv.next = add i64 %iv, 3\n %cmp = icmp slt i64 %iv, 111\n br i1 %cmp, label %loop, label %exit\n\nexit: ; preds = %loop\n ret void\n}\n"}, {"test_name": "cost_of_exit_branch_and_cond_insts", "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i16 @llvm.umax.i16(i16, i16) #0\n\ndefine i32 @cost_of_exit_branch_and_cond_insts(ptr %a, ptr %b, i1 %c, i16 %x) #1 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]\n br i1 %c, label %then, label %loop.exiting\n\nthen: ; preds = %loop.header\n %gep = getelementptr inbounds i32, ptr %b, i32 %iv\n store i1 false, ptr %a, align 1\n store i32 0, ptr %gep, align 4\n br label %loop.exiting\n\nloop.exiting: ; preds = %then, %loop.header\n %iv.next = add i32 %iv, 1\n %umax = tail call i16 @llvm.umax.i16(i16 %x, i16 111)\n %umax.ext = zext i16 %umax to i32\n %sub = sub i32 770, %umax.ext\n %ec = icmp slt i32 %iv, %sub\n br i1 %ec, label %loop.latch, label %exit\n\nloop.latch: ; preds = %loop.exiting\n br label %loop.header\n\nexit: ; preds = %loop.exiting\n br label %return\n\nreturn: ; preds = %exit\n ret i32 0\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\nattributes #1 = { \"target-features\"=\"+64bit,+v\" }\n"}, {"test_name": "gather_interleave_group_with_dead_insert_pos", "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine void @gather_interleave_group_with_dead_insert_pos(i64 %N, ptr noalias %src, ptr noalias %dst) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]\n %gep.src.0 = getelementptr i8, ptr %src, i64 %iv\n %l.dead = load i8, ptr %gep.src.0, align 1\n %iv.1 = add i64 %iv, 1\n %gep.src.1 = getelementptr i8, ptr %src, i64 %iv.1\n %l.1 = load i8, ptr %gep.src.1, align 1\n %ext = zext i8 %l.1 to i32\n %gep.dst = getelementptr i32, ptr %dst, i64 %iv\n store i32 %ext, ptr %gep.dst, align 4\n %iv.next = add nsw i64 %iv, 4\n %ec = icmp slt i64 %iv, %N\n br i1 %ec, label %loop, label %exit\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n"}, {"test_name": "test_phi_in_latch_redundant", "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine void @test_phi_in_latch_redundant(ptr %dst, i32 %a) {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n br i1 false, label %loop.latch, label %then\n\nthen: ; preds = %loop.header\n %not.a = xor i32 %a, -1\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n %p = phi i32 [ %not.a, %then ], [ 0, %loop.header ]\n %gep = getelementptr i32, ptr %dst, i64 %iv\n store i32 %p, ptr %gep, align 4\n %iv.next = add i64 %iv, 9\n %ec = icmp slt i64 %iv, 322\n br i1 %ec, label %loop.header, label %exit\n\nexit: ; preds = %loop.latch\n ret void\n}\n"}, {"test_name": "dead_live_out_due_to_scalar_epilogue_required", "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine i8 @dead_live_out_due_to_scalar_epilogue_required(ptr %src, ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %idxprom = sext i32 %iv to i64\n %gep.src = getelementptr i8, ptr %src, i64 %idxprom\n %l = load i8, ptr %gep.src, align 1\n %gep.dst = getelementptr i8, ptr %dst, i64 %idxprom\n store i8 0, ptr %gep.dst, align 1\n %iv.next = add i32 %iv, 4\n %cmp = icmp ult i32 %iv, 1001\n br i1 %cmp, label %loop, label %exit\n\nexit: ; preds = %loop\n %r = phi i8 [ %l, %loop ]\n ret i8 %r\n}\n"}]}, {"file": "llvm/test/Transforms/LoopVectorize/SystemZ/mem-interleaving-costs-03.ll", "commands": ["opt -mtriple=s390x-unknown-linux -mcpu=z16 -passes=loop-vectorize -debug-only=loop-vectorize -force-vector-width=4 -disable-output < %s 2>&1"], "tests": [{"test_name": "fun", "test_body": "define noundef i32 @fun(i32 %argc, ptr nocapture readnone %argv) {\nentry:\n %l_4774.i = alloca [4 x [2 x i128]], align 8\n call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %l_4774.i)\n br label %for.cond4.preheader.i\n\nfor.cond4.preheader.i: ; preds = %for.cond4.preheader.i, %entry\n %indvars.iv8.i = phi i64 [ 0, %entry ], [ %indvars.iv.next9.i, %for.cond4.preheader.i ]\n %arrayidx10.i = getelementptr inbounds [4 x [2 x i128]], ptr %l_4774.i, i64 0, i64 %indvars.iv8.i, i64 0\n store i128 8721036757475490113, ptr %arrayidx10.i, align 8\n %arrayidx10.i.c = getelementptr inbounds [4 x [2 x i128]], ptr %l_4774.i, i64 0, i64 %indvars.iv8.i, i64 1\n store i128 8721036757475490113, ptr %arrayidx10.i.c, align 8\n %indvars.iv.next9.i = add nuw nsw i64 %indvars.iv8.i, 1\n %exitcond.not.i = icmp eq i64 %indvars.iv.next9.i, 4\n br i1 %exitcond.not.i, label %func_1.exit, label %for.cond4.preheader.i\n\nfunc_1.exit: ; preds = %for.cond4.preheader.i\n %arrayidx195.i = getelementptr inbounds [4 x [2 x i128]], ptr %l_4774.i, i64 0, i64 1\n %0 = load i128, ptr %arrayidx195.i, align 8\n %cmp200.i = icmp ne i128 %0, 0\n %conv202.i = zext i1 %cmp200.i to i64\n %call203.i = tail call i64 @safe_sub_func_int64_t_s_s(i64 noundef %conv202.i, i64 noundef 9139899272418802852)\n call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %l_4774.i)\n br label %for.cond\n\nfor.cond: ; preds = %for.cond, %func_1.exit\n br label %for.cond\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)\ndeclare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)\ndeclare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0\n\ndeclare dso_local i64 @safe_sub_func_int64_t_s_s(i64, i64)\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }\n"}]}], "issue": {"title": "[VPlan] Assertion \" VPlan cost model and legacy cost model disagreed\"' failed.", "body": "Tested using: 15106c26662a WITH commits from #107894 cherry-picked on top.\r\n```\r\n> git log --oneline\r\n2bfba9bc7d37 (HEAD -> main) !fixup add TODO\r\n28acd6af75ff Add initial loop-invariant code motion transform.\r\n15106c26662a (origin/main, origin/HEAD) [flang][runtime] Fix odd \"invalid descriptor\" runtime crash\r\n```\r\nTestcase:\r\n```c\r\nchar a;\r\nextern int b[];\r\nshort c;\r\nchar d[1];\r\nvoid checksum() {\r\n for (long e = 0; e < 3;)\r\n for (long f = 0; e < 3; e = 709692)\r\n for (; f < c; f += 4) {\r\n a = d[f];\r\n b[f] = d[f - 1];\r\n }\r\n}\r\n```\r\n`clang -march=rv64gcv -O3 red.c`\r\n\r\nTestcase:\r\n```llvm ir\r\n; ModuleID = 'reduced.bc'\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine void @g(i64 %conv) #0 {\r\nentry:\r\n br label %for.body8.us23\r\n\r\nfor.body8.us23: ; preds = %for.body8.us23, %entry\r\n %f.121.us24 = phi i64 [ %add.us30, %for.body8.us23 ], [ 0, %entry ]\r\n %arrayidx.us25 = getelementptr [1 x i8], ptr null, i64 0, i64 %f.121.us24\r\n %0 = load i8, ptr %arrayidx.us25, align 1\r\n %sub.us26 = add i64 %f.121.us24, 1\r\n %arrayidx9.us27 = getelementptr [1 x i8], ptr null, i64 0, i64 %sub.us26\r\n %1 = load i8, ptr %arrayidx9.us27, align 1\r\n %conv10.us28 = zext i8 %1 to i32\r\n %arrayidx11.us29 = getelementptr [0 x i32], ptr null, i64 0, i64 %f.121.us24\r\n store i32 %conv10.us28, ptr null, align 4\r\n %add.us30 = add nsw i64 %f.121.us24, 4\r\n %cmp6.us31 = icmp slt i64 %f.121.us24, %conv\r\n br i1 %cmp6.us31, label %for.body8.us23, label %for.cond.cleanup.split.us\r\n\r\nfor.cond.cleanup.split.us: ; preds = %for.body8.us23\r\n ret void\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-b,-e,-experimental-smctr,-experimental-smmpm,-experimental-smnpm,-experimental-ssctr,-experimental-ssnpm,-experimental-sspm,-experimental-supm,-experimental-zacas,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-experimental-zvbc32e,-experimental-zvkgs,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smepmp,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssqosid,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zaamo,-zabha,-zalrsc,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-ztso,-zvbb,-zvbc,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\n```\r\n\r\nCommand/backtrace:\r\n```\r\n> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt --passes loop-vectorize reduced.ll -S\r\nopt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7394: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt --passes loop-vectorize reduced.ll -S\r\n1. Running pass \"function(loop-vectorize)\" on module \"reduced.ll\"\r\n2. Running pass \"loop-vectorize\" on function \"g\"\r\n #0 0x00005fabff5a9d80 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x3072d80)\r\n #1 0x00005fabff5a718f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x307018f)\r\n #2 0x00005fabff5a72e5 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007fe3d2042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007fe3d20969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007fe3d20969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007fe3d20969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x00007fe3d2042476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007fe3d20287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x00007fe3d202871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x00007fe3d2039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x00005fabfe550a26 llvm::LoopVectorizationPlanner::computeBestVF() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2019a26)\r\n#12 0x00005fabfe5678fb llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20308fb)\r\n#13 0x00005fabfe56a911 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2033911)\r\n#14 0x00005fabfe56af87 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2033f87)\r\n#15 0x00005fabfd3adf96 llvm::detail::PassModel>::run(llvm::Function&, llvm::AnalysisManager&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe76f96)\r\n#16 0x00005fabff3b51ef llvm::PassManager>::run(llvm::Function&, llvm::AnalysisManager&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e7e1ef)\r\n#17 0x00005fabfd3b11c6 llvm::detail::PassModel>, llvm::AnalysisManager>::run(llvm::Function&, llvm::AnalysisManager&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe7a1c6)\r\n#18 0x00005fabff3b357b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e7c57b)\r\n#19 0x00005fabfd3ad376 llvm::detail::PassModel>::run(llvm::Module&, llvm::AnalysisManager&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe76376)\r\n#20 0x00005fabff3b40dd llvm::PassManager>::run(llvm::Module&, llvm::AnalysisManager&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e7d0dd)\r\n#21 0x00005fabfcbd49db llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef, llvm::ArrayRef>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x69d9db)\r\n#22 0x00005fabfcbc6701 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x68f701)\r\n#23 0x00007fe3d2029d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#24 0x00007fe3d2029e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#25 0x00007fe3d2029e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#26 0x00005fabfcbbcc65 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x685c65)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\nhttps://godbolt.org/z/TTchhsf9h\r\n\r\nFound via fuzzer\r\n\r\nRelated/prior issue: https://github.com/llvm/llvm-project/issues/107473\r\n\r\ncc @fhahn", "author": "patrick-rivos", "labels": ["vectorizers", "crash"], "comments": []}, "verified": true} @@ -119,6 +121,7 @@ {"bug_id": "104422", "issue_url": "https://github.com/llvm/llvm-project/issues/104422", "bug_type": "miscompilation", "base_commit": "13a6a7975256ebdbce85f1174ae2eec735fa0d7a", "knowledge_cutoff": "2024-08-15T09:29:27Z", "lit_test_dir": ["llvm/test/Transforms/SLPVectorizer"], "hints": {"fix_commit": "56140a8258a3498cfcd9f0f05c182457d43cbfd2", "components": ["SLPVectorizer"], "bug_location_lineno": {"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [[15663, 15669]]}, "bug_location_funcname": {"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": ["BoUpSLP::collectValuesToDemote"]}}, "patch": "commit 56140a8258a3498cfcd9f0f05c182457d43cbfd2\nAuthor: Alexey Bataev \nDate: Thu Aug 15 07:57:37 2024 -0700\n\n [SLP]Fix PR104422: Wrong value truncation\n \n The minbitwidth restrictions can be skipped only for immediate reduced\n values, for other nodes still need to check if external users allow\n bitwidth reduction.\n \n Fixes https://github.com/llvm/llvm-project/issues/104422\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex 81841a8f6928..87b4ed599b5b 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -15663,7 +15663,8 @@ bool BoUpSLP::collectValuesToDemote(\n if (any_of(E.Scalars, [&](Value *V) {\n return !all_of(V->users(), [=](User *U) {\n return getTreeEntry(U) ||\n- (UserIgnoreList && UserIgnoreList->contains(U)) ||\n+ (E.Idx == 0 && UserIgnoreList &&\n+ UserIgnoreList->contains(U)) ||\n (!isa(U) && U->getType()->isSized() &&\n !U->getType()->isScalableTy() &&\n DL->getTypeSizeInBits(U->getType()) <= BitWidth);\n", "tests": [{"file": "llvm/test/Transforms/SLPVectorizer/X86/operand-is-reduced-val.ll", "commands": ["opt -S --passes=slp-vectorizer < %s -slp-threshold=-10"], "tests": [{"test_name": "src", "test_body": "define i64 @src(i32 %a) {\nentry:\n %0 = sext i32 %a to i64\n %1 = add nsw i64 %0, 4294967297\n %2 = sext i32 %a to i64\n %3 = add nsw i64 %2, 4294967297\n %4 = add i64 %3, %1\n %5 = and i64 %3, 1\n %6 = add i64 %4, %5\n %7 = sext i32 %a to i64\n %8 = add nsw i64 %7, 4294967297\n %9 = add i64 %8, %6\n %10 = and i64 %8, 1\n %11 = add i64 %9, %10\n %12 = sext i32 %a to i64\n %13 = add nsw i64 %12, 4294967297\n %14 = add i64 %13, %11\n %15 = and i64 %13, 1\n %16 = add i64 %14, %15\n %17 = sext i32 %a to i64\n %18 = add nsw i64 %17, 4294967297\n %19 = add i64 %18, %16\n %20 = and i64 %18, 1\n %21 = add i64 %19, %20\n ret i64 %21\n}\n"}]}], "issue": {"title": "[SLPVectorizer] Wrong value truncation ", "body": "- There seems to be an issue with SLPVectorizer. In the following example, a 2-byte wide value is incorrectly truncated:\r\n\r\n```\r\ndefine i64 @test(ptr addrspace(1) %arr, i32 %a) {\r\nentry:\r\n br label %loop\r\n\r\nloop:\r\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\r\n %local_1_7 = phi i64 [ 0, %entry ], [ %4, %loop ]\r\n %0 = sext i32 %a to i64\r\n %1 = add nsw i64 %0, 4294967297\r\n %2 = add i64 %1, %local_1_7\r\n %3 = and i64 %1, 1\r\n %4 = add i64 %2, %3\r\n %iv.next = add nuw nsw i64 %iv, 1\r\n %5 = icmp ugt i64 %iv, 355\r\n br i1 %5, label %exit, label %loop\r\n\r\nexit:\r\n ret i64 %4\r\n}\r\n```\r\n- In the loop we summarize the constant 4294967297 (`0x1'0000'0001`), but after running SLPVectorizer over the unrolled loop, the constant is truncated to `1`:\r\n```\r\nloop: \r\n %iv = phi i64 [ 0, %entry ], [ %iv.next.16, %loop ]\r\n %local_1_7 = phi i64 [ 0, %entry ], [ %op.rdx3, %loop ]\r\n %2 = add <16 x i32> %1, \r\n %3 = sext <16 x i32> %2 to <16 x i64>\r\n...\r\n```\r\n- Command to reproduce: `opt -passes=loop-unroll,slp-vectorizer -unroll-count=17`\r\n- https://godbolt.org/z/zcPefTPzW\r\n- Looks like the issue was caused by the https://github.com/llvm/llvm-project/commit/7f2167868d8c1cedd3915883412b9c787a2f01db\r\n\r\n@alexey-bataev Could you please take a look?\r\n", "author": "aleks-tmb", "labels": ["miscompilation", "release:backport", "llvm:SLPVectorizer"], "comments": [{"author": "nikic", "body": "This probably needs an LLVM 19 backport?\r\n\r\n/cherry-pick 65ac12d3c9877ecf5b97552364e7eead887d94eb 56140a8258a3498cfcd9f0f05c182457d43cbfd2"}]}, "verified": true} {"bug_id": "112078", "issue_url": "https://github.com/llvm/llvm-project/issues/112078", "bug_type": "miscompilation", "base_commit": "39aae575744de7ae77e755142e0746a5b473b3ed", "knowledge_cutoff": "2024-10-12T04:08:35Z", "lit_test_dir": ["llvm/test/Transforms/InstCombine"], "hints": {"fix_commit": "9edc454ee601e04500529c98b753d3bd8f427d01", "components": ["InstCombine"], "bug_location_lineno": {"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": [[935, 943], [945, 955], [3362, 3370]]}, "bug_location_funcname": {"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": ["InstCombinerImpl::foldAndOrOfICmps", "foldIsPowerOf2OrZero"]}}, "patch": "commit 9edc454ee601e04500529c98b753d3bd8f427d01\nAuthor: Yingwei Zheng \nDate: Mon Oct 14 20:52:55 2024 +0800\n\n [InstCombine] Drop range attributes in `foldIsPowerOf2OrZero` (#112178)\n \n Closes https://github.com/llvm/llvm-project/issues/112078.\n\ndiff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp\nindex 453071f3f982..64bee4ab974e 100644\n--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp\n+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp\n@@ -935,9 +935,11 @@ static Value *foldSignedTruncationCheck(ICmpInst *ICmp0, ICmpInst *ICmp1,\n \n /// Fold (icmp eq ctpop(X) 1) | (icmp eq X 0) into (icmp ult ctpop(X) 2) and\n /// fold (icmp ne ctpop(X) 1) & (icmp ne X 0) into (icmp ugt ctpop(X) 1).\n-/// Also used for logical and/or, must be poison safe.\n+/// Also used for logical and/or, must be poison safe if range attributes are\n+/// dropped.\n static Value *foldIsPowerOf2OrZero(ICmpInst *Cmp0, ICmpInst *Cmp1, bool IsAnd,\n- InstCombiner::BuilderTy &Builder) {\n+ InstCombiner::BuilderTy &Builder,\n+ InstCombinerImpl &IC) {\n CmpInst::Predicate Pred0, Pred1;\n Value *X;\n if (!match(Cmp0, m_ICmp(Pred0, m_Intrinsic(m_Value(X)),\n@@ -945,11 +947,19 @@ static Value *foldIsPowerOf2OrZero(ICmpInst *Cmp0, ICmpInst *Cmp1, bool IsAnd,\n !match(Cmp1, m_ICmp(Pred1, m_Specific(X), m_ZeroInt())))\n return nullptr;\n \n- Value *CtPop = Cmp0->getOperand(0);\n- if (IsAnd && Pred0 == ICmpInst::ICMP_NE && Pred1 == ICmpInst::ICMP_NE)\n+ auto *CtPop = cast(Cmp0->getOperand(0));\n+ if (IsAnd && Pred0 == ICmpInst::ICMP_NE && Pred1 == ICmpInst::ICMP_NE) {\n+ // Drop range attributes and re-infer them in the next iteration.\n+ CtPop->dropPoisonGeneratingAnnotations();\n+ IC.addToWorklist(CtPop);\n return Builder.CreateICmpUGT(CtPop, ConstantInt::get(CtPop->getType(), 1));\n- if (!IsAnd && Pred0 == ICmpInst::ICMP_EQ && Pred1 == ICmpInst::ICMP_EQ)\n+ }\n+ if (!IsAnd && Pred0 == ICmpInst::ICMP_EQ && Pred1 == ICmpInst::ICMP_EQ) {\n+ // Drop range attributes and re-infer them in the next iteration.\n+ CtPop->dropPoisonGeneratingAnnotations();\n+ IC.addToWorklist(CtPop);\n return Builder.CreateICmpULT(CtPop, ConstantInt::get(CtPop->getType(), 2));\n+ }\n \n return nullptr;\n }\n@@ -3362,9 +3372,9 @@ Value *InstCombinerImpl::foldAndOrOfICmps(ICmpInst *LHS, ICmpInst *RHS,\n /*IsLogical*/ false, Builder, Q))\n return V;\n \n- if (Value *V = foldIsPowerOf2OrZero(LHS, RHS, IsAnd, Builder))\n+ if (Value *V = foldIsPowerOf2OrZero(LHS, RHS, IsAnd, Builder, *this))\n return V;\n- if (Value *V = foldIsPowerOf2OrZero(RHS, LHS, IsAnd, Builder))\n+ if (Value *V = foldIsPowerOf2OrZero(RHS, LHS, IsAnd, Builder, *this))\n return V;\n \n // TODO: One of these directions is fine with logical and/or, the other could\n", "tests": [{"file": "llvm/test/Transforms/InstCombine/ispow2.ll", "commands": ["opt < %s -passes=instcombine -S"], "tests": [{"test_name": "is_pow2or0_decrement_op", "test_body": "define i1 @is_pow2or0_decrement_op(i8 %x) {\n %dec = add i8 %x, -1\n %and = and i8 %dec, %x\n %cmp = icmp eq i8 %and, 0\n ret i1 %cmp\n}\n"}, {"test_name": "is_pow2_negate_op_vec", "test_body": "define <2 x i1> @is_pow2_negate_op_vec(<2 x i32> %x) {\n %neg = sub <2 x i32> zeroinitializer, %x\n %and = and <2 x i32> %neg, %x\n %cmp = icmp eq <2 x i32> %and, %x\n %notzero = icmp ne <2 x i32> %x, zeroinitializer\n %r = and <2 x i1> %cmp, %notzero\n ret <2 x i1> %r\n}\n"}, {"test_name": "is_pow2_ctpop_wrong_cmp_op1_logical", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2_ctpop_wrong_cmp_op1_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ult i32 %t0, 3\n %notzero = icmp ne i32 %x, 0\n %r = select i1 %notzero, i1 %cmp, i1 false\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "is_pow2_negate_op", "test_body": "define i1 @is_pow2_negate_op(i32 %x) {\n %neg = sub i32 0, %x\n %and = and i32 %neg, %x\n %cmp = icmp eq i32 %and, %x\n %notzero = icmp ne i32 %x, 0\n %r = and i1 %notzero, %cmp\n ret i1 %r\n}\n"}, {"test_name": "not_pow2_nz_known_bits", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @not_pow2_nz_known_bits(i32 %xin) {\n %x = or i32 %xin, 1\n %cnt = call i32 @llvm.ctpop.i32(i32 %x)\n %r = icmp ne i32 %cnt, 1\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "is_pow2_nz_known_bits", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2_nz_known_bits(i32 %xin) {\n %x = or i32 %xin, 64\n %cnt = call i32 @llvm.ctpop.i32(i32 %x)\n %r = icmp eq i32 %cnt, 1\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "is_power2_or_zero_with_range", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_power2_or_zero_with_range(i32 %x) {\n %ctpop = call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp eq i32 %ctpop, 1\n %notzero = icmp eq i32 %x, 0\n %res = select i1 %notzero, i1 true, i1 %cmp\n ret i1 %res\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "blsmsk_is_p2_or_z", "test_body": "define i1 @blsmsk_is_p2_or_z(i32 %xx, i32 %yy) {\n %x = or i32 %xx, %yy\n %xm1 = add i32 %x, -1\n %y = xor i32 %x, %xm1\n %r = icmp uge i32 %x, %y\n ret i1 %r\n}\n"}, {"test_name": "isnot_pow2nor0_ctpop_commute_vec", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <2 x i8> @llvm.ctpop.v2i8(<2 x i8>) #0\n\ndefine <2 x i1> @isnot_pow2nor0_ctpop_commute_vec(<2 x i8> %x) {\n %t0 = tail call <2 x i8> @llvm.ctpop.v2i8(<2 x i8> %x)\n %cmp = icmp ne <2 x i8> %t0, splat (i8 1)\n %notzero = icmp ne <2 x i8> %x, zeroinitializer\n %r = and <2 x i1> %notzero, %cmp\n ret <2 x i1> %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "is_pow2or0_ctpop_wrong_pred1", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2or0_ctpop_wrong_pred1(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ne i32 %t0, 1\n %iszero = icmp eq i32 %x, 0\n %r = or i1 %iszero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "is_pow2_non_zero_ne_1", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #1\n\ndefine i1 @is_pow2_non_zero_ne_1(i32 %x) {\n %notzero = icmp ne i32 %x, 0\n call void @llvm.assume(i1 %notzero)\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ne i32 %t0, 1\n ret i1 %cmp\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\nattributes #1 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n"}, {"test_name": "blsmsk_is_p2_or_z_fail", "test_body": "define i1 @blsmsk_is_p2_or_z_fail(i32 %xx, i32 %yy) {\n %x = or i32 %xx, %yy\n %xm1 = add i32 %x, -1\n %y = xor i32 %x, %xm1\n %r = icmp ugt i32 %x, %y\n ret i1 %r\n}\n"}, {"test_name": "blsmsk_is_p2_or_z_uge_xy_fail", "test_body": "define i1 @blsmsk_is_p2_or_z_uge_xy_fail(i8 %xx, i8 %yy) {\n %x = or i8 %xx, %yy\n %xm1 = add i8 %x, -1\n %y = xor i8 %x, %xm1\n %r = icmp uge i8 %x, %y\n ret i1 %r\n}\n"}, {"test_name": "is_pow2or0_ctpop_logical_extra_uses", "test_body": "declare void @use(i32)\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndeclare void @use_i1(i1)\n\ndefine i1 @is_pow2or0_ctpop_logical_extra_uses(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n call void @use(i32 %t0)\n %cmp = icmp eq i32 %t0, 1\n call void @use_i1(i1 %cmp)\n %iszero = icmp eq i32 %x, 0\n call void @use_i1(i1 %iszero)\n %r = select i1 %iszero, i1 true, i1 %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "isnot_pow2_ctpop_commute_vec", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <2 x i8> @llvm.ctpop.v2i8(<2 x i8>) #0\n\ndefine <2 x i1> @isnot_pow2_ctpop_commute_vec(<2 x i8> %x) {\n %t0 = tail call <2 x i8> @llvm.ctpop.v2i8(<2 x i8> %x)\n %cmp = icmp ugt <2 x i8> %t0, splat (i8 1)\n %iszero = icmp eq <2 x i8> %x, zeroinitializer\n %r = or <2 x i1> %cmp, %iszero\n ret <2 x i1> %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "blsmsk_isnt_p2_or_z_fail_wrong_add", "test_body": "define i1 @blsmsk_isnt_p2_or_z_fail_wrong_add(i32 %x, i32 %z) {\n %xm1 = add i32 %z, -1\n %y = xor i32 %x, %xm1\n %r = icmp ult i32 %y, %x\n ret i1 %r\n}\n"}, {"test_name": "is_pow2_ctpop_wrong_pred2", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2_ctpop_wrong_pred2(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ult i32 %t0, 2\n %cmp2 = icmp sgt i32 %x, 0\n %r = and i1 %cmp2, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "is_pow2or0_ctpop_swap_cmp", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2or0_ctpop_swap_cmp(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp eq i32 %t0, 1\n %iszero = icmp eq i32 %x, 0\n %r = or i1 %cmp, %iszero\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "is_pow2or0_ctpop_commute_vec_wrong_pred3", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <2 x i8> @llvm.ctpop.v2i8(<2 x i8>) #0\n\ndefine <2 x i1> @is_pow2or0_ctpop_commute_vec_wrong_pred3(<2 x i8> %x) {\n %t0 = tail call <2 x i8> @llvm.ctpop.v2i8(<2 x i8> %x)\n %cmp = icmp eq <2 x i8> %t0, splat (i8 1)\n %iszero = icmp eq <2 x i8> %x, zeroinitializer\n %r = and <2 x i1> %cmp, %iszero\n ret <2 x i1> %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "is_pow2_decrement_op_logical", "test_body": "define i1 @is_pow2_decrement_op_logical(i8 %x) {\n %dec = add i8 %x, -1\n %and = and i8 %dec, %x\n %cmp = icmp eq i8 %and, 0\n %notzero = icmp ne i8 %x, 0\n %r = select i1 %cmp, i1 %notzero, i1 false\n ret i1 %r\n}\n"}, {"test_name": "isnot_pow2or0_negate_op_vec", "test_body": "define <2 x i1> @isnot_pow2or0_negate_op_vec(<2 x i32> %x) {\n %neg = sub <2 x i32> zeroinitializer, %x\n %and = and <2 x i32> %neg, %x\n %cmp = icmp ne <2 x i32> %and, %x\n ret <2 x i1> %cmp\n}\n"}, {"test_name": "is_pow2or0_ctpop_commute_vec", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <2 x i8> @llvm.ctpop.v2i8(<2 x i8>) #0\n\ndefine <2 x i1> @is_pow2or0_ctpop_commute_vec(<2 x i8> %x) {\n %t0 = tail call <2 x i8> @llvm.ctpop.v2i8(<2 x i8> %x)\n %cmp = icmp eq <2 x i8> %t0, splat (i8 1)\n %iszero = icmp eq <2 x i8> %x, zeroinitializer\n %r = or <2 x i1> %iszero, %cmp\n ret <2 x i1> %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "is_pow2_negate_op_logical", "test_body": "define i1 @is_pow2_negate_op_logical(i32 %x) {\n %neg = sub i32 0, %x\n %and = and i32 %neg, %x\n %cmp = icmp eq i32 %and, %x\n %notzero = icmp ne i32 %x, 0\n %r = select i1 %notzero, i1 %cmp, i1 false\n ret i1 %r\n}\n"}, {"test_name": "isnot_pow2nor0_ctpop", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2nor0_ctpop(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ne i32 %t0, 1\n %notzero = icmp ne i32 %x, 0\n %r = and i1 %notzero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "blsmsk_isnt_p2_or_z_ult_xy_fail", "test_body": "define i1 @blsmsk_isnt_p2_or_z_ult_xy_fail(i8 %xx, i8 %yy) {\n %x = or i8 %xx, %yy\n %xm1 = add i8 %x, -1\n %y = xor i8 %x, %xm1\n %r = icmp ult i8 %x, %y\n ret i1 %r\n}\n"}, {"test_name": "isnot_pow2nor0_wrong_pred3_ctpop_commute_vec", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <2 x i8> @llvm.ctpop.v2i8(<2 x i8>) #0\n\ndefine <2 x i1> @isnot_pow2nor0_wrong_pred3_ctpop_commute_vec(<2 x i8> %x) {\n %t0 = tail call <2 x i8> @llvm.ctpop.v2i8(<2 x i8> %x)\n %cmp = icmp ne <2 x i8> %t0, splat (i8 1)\n %notzero = icmp ne <2 x i8> %x, zeroinitializer\n %r = or <2 x i1> %cmp, %notzero\n ret <2 x i1> %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "is_pow2or0_negate_op_vec", "test_body": "define <2 x i1> @is_pow2or0_negate_op_vec(<2 x i32> %x) {\n %neg = sub <2 x i32> zeroinitializer, %x\n %and = and <2 x i32> %neg, %x\n %cmp = icmp eq <2 x i32> %and, %x\n ret <2 x i1> %cmp\n}\n"}, {"test_name": "isnot_pow2or0_negate_op", "test_body": "define i1 @isnot_pow2or0_negate_op(i32 %x) {\n %neg = sub i32 0, %x\n %and = and i32 %neg, %x\n %cmp = icmp ne i32 %and, %x\n ret i1 %cmp\n}\n"}, {"test_name": "not_pow2_or_z_known_bits_fail_wrong_cmp", "test_body": "define <2 x i1> @not_pow2_or_z_known_bits_fail_wrong_cmp(<2 x i32> %xin) {\n %x = or <2 x i32> %xin, splat (i32 64)\n %cnt = call <2 x i32> @llvm.ctpop.v2i32(<2 x i32> %x)\n %r = icmp ugt <2 x i32> %cnt, splat (i32 2)\n ret <2 x i1> %r\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <2 x i32> @llvm.ctpop.v2i32(<2 x i32>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "is_pow2_ctpop_wrong_cmp_op2", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2_ctpop_wrong_cmp_op2(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ult i32 %t0, 2\n %notzero = icmp ne i32 %x, 1\n %r = and i1 %notzero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "is_pow2_ctpop_logical", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2_ctpop_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ult i32 %t0, 2\n %notzero = icmp ne i32 %x, 0\n %r = select i1 %notzero, i1 %cmp, i1 false\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "isnot_pow2_decrement_op_logical", "test_body": "define i1 @isnot_pow2_decrement_op_logical(i8 %x) {\n %dec = add i8 %x, -1\n %and = and i8 %dec, %x\n %cmp = icmp ne i8 %and, 0\n %iszero = icmp eq i8 %x, 0\n %r = select i1 %iszero, i1 true, i1 %cmp\n ret i1 %r\n}\n"}, {"test_name": "isnot_pow2_negate_op_logical", "test_body": "define i1 @isnot_pow2_negate_op_logical(i32 %x) {\n %neg = sub i32 0, %x\n %and = and i32 %neg, %x\n %cmp = icmp ne i32 %and, %x\n %iszero = icmp eq i32 %x, 0\n %r = select i1 %cmp, i1 true, i1 %iszero\n ret i1 %r\n}\n"}, {"test_name": "is_pow2or0_ctpop", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2or0_ctpop(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp eq i32 %t0, 1\n %iszero = icmp eq i32 %x, 0\n %r = or i1 %iszero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "blsmsk_is_p2_or_z_uge_yx", "test_body": "define i1 @blsmsk_is_p2_or_z_uge_yx(i8 %xx, i8 %yy) {\n %x = or i8 %xx, %yy\n %xm1 = add i8 %x, -1\n %y = xor i8 %x, %xm1\n %r = icmp uge i8 %y, %x\n ret i1 %r\n}\n"}, {"test_name": "has_single_bit_inv", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @has_single_bit_inv(i32 %x) {\nentry:\n %cmp1 = icmp eq i32 %x, 0\n %popcnt = call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 %x)\n %cmp2 = icmp ugt i32 %popcnt, 1\n %sel = select i1 %cmp1, i1 true, i1 %cmp2\n ret i1 %sel\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "is_pow2or0_negate_op", "test_body": "define i1 @is_pow2or0_negate_op(i32 %x) {\n %neg = sub i32 0, %x\n %and = and i32 %neg, %x\n %cmp = icmp eq i32 %and, %x\n ret i1 %cmp\n}\n"}, {"test_name": "blsmsk_isnt_p2_or_z_ugt_yx_fail", "test_body": "define i1 @blsmsk_isnt_p2_or_z_ugt_yx_fail(i8 %xx, i8 %yy) {\n %x = or i8 %xx, %yy\n %xm1 = add i8 %x, -1\n %y = xor i8 %x, %xm1\n %r = icmp ugt i8 %y, %x\n ret i1 %r\n}\n"}, {"test_name": "blsmsk_isnt_p2_or_z_fail", "test_body": "define i1 @blsmsk_isnt_p2_or_z_fail(i32 %x) {\n %xm1 = add i32 %x, -1\n %y = xor i32 %x, %xm1\n %r = icmp ule i32 %y, %x\n ret i1 %r\n}\n"}, {"test_name": "is_pow2_decrement_op_vec", "test_body": "define <2 x i1> @is_pow2_decrement_op_vec(<2 x i8> %x) {\n %dec = add <2 x i8> %x, splat (i8 -1)\n %and = and <2 x i8> %dec, %x\n %cmp = icmp eq <2 x i8> %and, zeroinitializer\n %notzero = icmp ne <2 x i8> %x, zeroinitializer\n %r = and <2 x i1> %notzero, %cmp\n ret <2 x i1> %r\n}\n"}, {"test_name": "isnot_pow2nor0_ctpop_extra_uses", "test_body": "declare void @use(i32)\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndeclare void @use_i1(i1)\n\ndefine i1 @isnot_pow2nor0_ctpop_extra_uses(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n call void @use(i32 %t0)\n %cmp = icmp ne i32 %t0, 1\n call void @use_i1(i1 %cmp)\n %notzero = icmp ne i32 %x, 0\n call void @use_i1(i1 %notzero)\n %r = and i1 %notzero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "isnot_pow2nor0_ctpop_wrong_pred1", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2nor0_ctpop_wrong_pred1(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp eq i32 %t0, 1\n %notzero = icmp ne i32 %x, 0\n %r = and i1 %notzero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "isnot_pow2_ctpop", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2_ctpop(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ugt i32 %t0, 1\n %iszero = icmp eq i32 %x, 0\n %r = or i1 %iszero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "blsmsk_isnt_p2_or_z_fail_multiuse", "test_body": "declare void @use.i32(i32)\n\ndefine i1 @blsmsk_isnt_p2_or_z_fail_multiuse(i32 %x) {\n %xm1 = add i32 %x, -1\n %y = xor i32 %x, %xm1\n call void @use.i32(i32 %y)\n %r = icmp ult i32 %y, %x\n ret i1 %r\n}\n"}, {"test_name": "is_pow2or0_ctpop_wrong_pred2_logical", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2or0_ctpop_wrong_pred2_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ne i32 %t0, 1\n %iszero = icmp ne i32 %x, 0\n %r = select i1 %iszero, i1 true, i1 %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "is_pow2_ctpop_extra_uses", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndeclare void @use_i1(i1)\n\ndefine i1 @is_pow2_ctpop_extra_uses(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ult i32 %t0, 2\n call void @use_i1(i1 %cmp)\n %notzero = icmp ne i32 %x, 0\n call void @use_i1(i1 %notzero)\n %r = and i1 %notzero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "blsmsk_isnt_p2_or_z_ult_yx", "test_body": "define i1 @blsmsk_isnt_p2_or_z_ult_yx(i8 %xx, i8 %yy) {\n %x = or i8 %xx, %yy\n %xm1 = add i8 %x, -1\n %y = xor i8 %x, %xm1\n %r = icmp ult i8 %y, %x\n ret i1 %r\n}\n"}, {"test_name": "is_pow2or0_ctpop_wrong_cmp_op1_logical", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2or0_ctpop_wrong_cmp_op1_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp eq i32 %t0, 3\n %iszero = icmp eq i32 %x, 0\n %r = select i1 %iszero, i1 true, i1 %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "blsmsk_isnt_p2_or_z_fail_bad_xor", "test_body": "define i1 @blsmsk_isnt_p2_or_z_fail_bad_xor(i32 %x, i32 %z) {\n %xm1 = add i32 %x, -1\n %y = xor i32 %z, %xm1\n %r = icmp ult i32 %y, %x\n ret i1 %r\n}\n"}, {"test_name": "is_pow2or0_negate_op_extra_use2", "test_body": "declare void @use(i32)\n\ndefine i1 @is_pow2or0_negate_op_extra_use2(i32 %x) {\n %neg = sub i32 0, %x\n %and = and i32 %neg, %x\n call void @use(i32 %and)\n %cmp = icmp eq i32 %and, %x\n ret i1 %cmp\n}\n"}, {"test_name": "isnot_pow2_negate_op", "test_body": "define i1 @isnot_pow2_negate_op(i32 %x) {\n %neg = sub i32 0, %x\n %and = and i32 %neg, %x\n %cmp = icmp ne i32 %and, %x\n %iszero = icmp eq i32 %x, 0\n %r = or i1 %cmp, %iszero\n ret i1 %r\n}\n"}, {"test_name": "is_pow2or0_negate_op_extra_use1", "test_body": "declare void @use(i32)\n\ndefine i1 @is_pow2or0_negate_op_extra_use1(i32 %x) {\n %neg = sub i32 0, %x\n call void @use(i32 %neg)\n %and = and i32 %neg, %x\n %cmp = icmp eq i32 %and, %x\n ret i1 %cmp\n}\n"}, {"test_name": "isnot_pow2_ctpop_wrong_cmp_op1_logical", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2_ctpop_wrong_cmp_op1_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ugt i32 %t0, 2\n %iszero = icmp eq i32 %x, 0\n %r = select i1 %iszero, i1 true, i1 %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "isnot_pow2_ctpop_wrong_cmp_op2_logical", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2_ctpop_wrong_cmp_op2_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ugt i32 %t0, 1\n %iszero = icmp eq i32 %x, 1\n %r = select i1 %iszero, i1 true, i1 %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "is_pow2_ctpop_wrong_cmp_op1", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2_ctpop_wrong_cmp_op1(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ult i32 %t0, 3\n %notzero = icmp ne i32 %x, 0\n %r = and i1 %notzero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "is_pow2or0_ctpop_commute_vec_wrong_cmp_op1", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <2 x i8> @llvm.ctpop.v2i8(<2 x i8>) #0\n\ndefine <2 x i1> @is_pow2or0_ctpop_commute_vec_wrong_cmp_op1(<2 x i8> %x) {\n %t0 = tail call <2 x i8> @llvm.ctpop.v2i8(<2 x i8> %x)\n %cmp = icmp eq <2 x i8> %t0, \n %iszero = icmp eq <2 x i8> %x, zeroinitializer\n %r = or <2 x i1> %cmp, %iszero\n ret <2 x i1> %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "isnot_pow2_ctpop_wrong_pred2_logical", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2_ctpop_wrong_pred2_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ugt i32 %t0, 1\n %cmp2 = icmp slt i32 %x, 0\n %r = select i1 %cmp2, i1 true, i1 %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "is_pow2_ctpop_extra_uses_logical", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndeclare void @use_i1(i1)\n\ndefine i1 @is_pow2_ctpop_extra_uses_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ult i32 %t0, 2\n call void @use_i1(i1 %cmp)\n %notzero = icmp ne i32 %x, 0\n call void @use_i1(i1 %notzero)\n %r = select i1 %notzero, i1 %cmp, i1 false\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "isnot_pow2or0_negate_op_commute3", "test_body": "define i1 @isnot_pow2or0_negate_op_commute3(i32 %p) {\n %x = urem i32 42, %p\n %neg = sub i32 0, %x\n %and = and i32 %x, %neg\n %cmp = icmp ne i32 %x, %and\n ret i1 %cmp\n}\n"}, {"test_name": "is_pow2_ctpop_wrong_cmp_op2_logical", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2_ctpop_wrong_cmp_op2_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ult i32 %t0, 2\n %notzero = icmp ne i32 %x, 1\n %r = select i1 %notzero, i1 %cmp, i1 false\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "is_pow2_non_zero_eq_1", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #1\n\ndefine i1 @is_pow2_non_zero_eq_1(i32 %x) {\n %notzero = icmp ne i32 %x, 0\n call void @llvm.assume(i1 %notzero)\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp eq i32 %t0, 1\n ret i1 %cmp\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\nattributes #1 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n"}, {"test_name": "isnot_pow2nor0_ctpop_logical_extra_uses", "test_body": "declare void @use(i32)\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndeclare void @use_i1(i1)\n\ndefine i1 @isnot_pow2nor0_ctpop_logical_extra_uses(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n call void @use(i32 %t0)\n %cmp = icmp ne i32 %t0, 1\n call void @use_i1(i1 %cmp)\n %notzero = icmp ne i32 %x, 0\n call void @use_i1(i1 %notzero)\n %r = select i1 %notzero, i1 %cmp, i1 false\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "is_pow2or0_ctpop_wrong_pred2", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2or0_ctpop_wrong_pred2(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ne i32 %t0, 1\n %iszero = icmp ne i32 %x, 0\n %r = or i1 %iszero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "isnot_pow2_ctpop_wrong_cmp_op2", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2_ctpop_wrong_cmp_op2(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ugt i32 %t0, 1\n %iszero = icmp eq i32 %x, 1\n %r = or i1 %iszero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "is_pow2_ctpop_wrong_pred1", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2_ctpop_wrong_pred1(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ugt i32 %t0, 2\n %notzero = icmp ne i32 %x, 0\n %r = and i1 %notzero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "isnot_pow2_ctpop_extra_uses_logical", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndeclare void @use_i1(i1)\n\ndefine i1 @isnot_pow2_ctpop_extra_uses_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ugt i32 %t0, 1\n call void @use_i1(i1 %cmp)\n %iszero = icmp eq i32 %x, 0\n call void @use_i1(i1 %iszero)\n %r = select i1 %iszero, i1 true, i1 %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "is_pow2or0_ctpop_extra_uses", "test_body": "declare void @use(i32)\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndeclare void @use_i1(i1)\n\ndefine i1 @is_pow2or0_ctpop_extra_uses(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n call void @use(i32 %t0)\n %cmp = icmp eq i32 %t0, 1\n call void @use_i1(i1 %cmp)\n %iszero = icmp eq i32 %x, 0\n call void @use_i1(i1 %iszero)\n %r = or i1 %iszero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "is_pow2_non_zero_ult_2", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #1\n\ndefine i1 @is_pow2_non_zero_ult_2(i32 %x) {\n %notzero = icmp ne i32 %x, 0\n call void @llvm.assume(i1 %notzero)\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ult i32 %t0, 2\n ret i1 %cmp\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\nattributes #1 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n"}, {"test_name": "is_pow2_ctpop_commute_vec", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <2 x i8> @llvm.ctpop.v2i8(<2 x i8>) #0\n\ndefine <2 x i1> @is_pow2_ctpop_commute_vec(<2 x i8> %x) {\n %t0 = tail call <2 x i8> @llvm.ctpop.v2i8(<2 x i8> %x)\n %cmp = icmp ult <2 x i8> %t0, splat (i8 2)\n %notzero = icmp ne <2 x i8> %x, zeroinitializer\n %r = and <2 x i1> %cmp, %notzero\n ret <2 x i1> %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "isnot_pow2_decrement_op", "test_body": "define i1 @isnot_pow2_decrement_op(i8 %x) {\n %dec = add i8 %x, -1\n %and = and i8 %dec, %x\n %cmp = icmp ne i8 %and, 0\n %iszero = icmp eq i8 %x, 0\n %r = or i1 %iszero, %cmp\n ret i1 %r\n}\n"}, {"test_name": "isnot_pow2nor0_ctpop_wrong_cmp_op1_logical", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2nor0_ctpop_wrong_cmp_op1_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ne i32 %t0, 5\n %notzero = icmp ne i32 %x, 0\n %r = select i1 %notzero, i1 %cmp, i1 false\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "is_pow2_ctpop_wrong_pred1_logical", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2_ctpop_wrong_pred1_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ugt i32 %t0, 2\n %notzero = icmp ne i32 %x, 0\n %r = select i1 %notzero, i1 %cmp, i1 false\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "isnot_pow2or0_decrement_op_vec", "test_body": "define <2 x i1> @isnot_pow2or0_decrement_op_vec(<2 x i8> %x) {\n %dec = add <2 x i8> %x, splat (i8 -1)\n %and = and <2 x i8> %dec, %x\n %cmp = icmp ne <2 x i8> %and, zeroinitializer\n ret <2 x i1> %cmp\n}\n"}, {"test_name": "is_pow2_ctpop_wrong_pred2_logical", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2_ctpop_wrong_pred2_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ult i32 %t0, 2\n %cmp2 = icmp sgt i32 %x, 0\n %r = select i1 %cmp2, i1 %cmp, i1 false\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "blsmsk_isnt_p2_or_z_ugt_xy", "test_body": "define i1 @blsmsk_isnt_p2_or_z_ugt_xy(i8 %xx, i8 %yy) {\n %x = or i8 %xx, %yy\n %xm1 = add i8 %x, -1\n %y = xor i8 %x, %xm1\n %r = icmp ugt i8 %x, %y\n ret i1 %r\n}\n"}, {"test_name": "isnot_pow2nor0_ctpop_commute_vec_wrong_cmp_op1", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <2 x i8> @llvm.ctpop.v2i8(<2 x i8>) #0\n\ndefine <2 x i1> @isnot_pow2nor0_ctpop_commute_vec_wrong_cmp_op1(<2 x i8> %x) {\n %t0 = tail call <2 x i8> @llvm.ctpop.v2i8(<2 x i8> %x)\n %cmp = icmp ne <2 x i8> %t0, \n %notzero = icmp ne <2 x i8> %x, zeroinitializer\n %r = and <2 x i1> %cmp, %notzero\n ret <2 x i1> %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "isnot_pow2nor0_ctpop_wrong_pred2_logical", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2nor0_ctpop_wrong_pred2_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp eq i32 %t0, 1\n %notzero = icmp eq i32 %x, 0\n %r = select i1 %notzero, i1 %cmp, i1 false\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "is_pow2or0_negate_op_commute1", "test_body": "define i1 @is_pow2or0_negate_op_commute1(i32 %p) {\n %x = srem i32 42, %p\n %neg = sub i32 0, %x\n %and = and i32 %x, %neg\n %cmp = icmp eq i32 %and, %x\n ret i1 %cmp\n}\n"}, {"test_name": "is_pow2_or_z_known_bits", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2_or_z_known_bits(i32 %xin) {\n %x = or i32 %xin, -2147483648\n %cnt = call i32 @llvm.ctpop.i32(i32 %x)\n %r = icmp ult i32 %cnt, 2\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "is_pow2or0_decrement_op_vec", "test_body": "define <2 x i1> @is_pow2or0_decrement_op_vec(<2 x i8> %x) {\n %dec = add <2 x i8> %x, splat (i8 -1)\n %and = and <2 x i8> %dec, %x\n %cmp = icmp eq <2 x i8> %and, zeroinitializer\n ret <2 x i1> %cmp\n}\n"}, {"test_name": "is_pow2_decrement_op", "test_body": "define i1 @is_pow2_decrement_op(i8 %x) {\n %dec = add i8 %x, -1\n %and = and i8 %dec, %x\n %cmp = icmp eq i8 %and, 0\n %notzero = icmp ne i8 %x, 0\n %r = and i1 %cmp, %notzero\n ret i1 %r\n}\n"}, {"test_name": "isnot_pow2_ctpop_wrong_pred2", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2_ctpop_wrong_pred2(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ugt i32 %t0, 1\n %cmp2 = icmp slt i32 %x, 0\n %r = or i1 %cmp2, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "isnot_pow2_ctpop_logical", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2_ctpop_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ugt i32 %t0, 1\n %iszero = icmp eq i32 %x, 0\n %r = select i1 %iszero, i1 true, i1 %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "isnot_pow2or0_negate_op_commute2", "test_body": "define i1 @isnot_pow2or0_negate_op_commute2(i32 %p) {\n %x = urem i32 42, %p\n %neg = sub i32 0, %x\n %and = and i32 %neg, %x\n %cmp = icmp ne i32 %x, %and\n ret i1 %cmp\n}\n"}, {"test_name": "blsmsk_is_p2_or_z_fail_bad_cmp", "test_body": "define i1 @blsmsk_is_p2_or_z_fail_bad_cmp(i32 %x, i32 %z) {\n %xm1 = add i32 %x, -1\n %y = xor i32 %x, %xm1\n %r = icmp uge i32 %y, %z\n ret i1 %r\n}\n"}, {"test_name": "isnot_pow2_decrement_op_vec", "test_body": "define <2 x i1> @isnot_pow2_decrement_op_vec(<2 x i8> %x) {\n %dec = add <2 x i8> %x, splat (i8 -1)\n %and = and <2 x i8> %dec, %x\n %cmp = icmp ne <2 x i8> %and, zeroinitializer\n %iszero = icmp eq <2 x i8> %x, zeroinitializer\n %r = or <2 x i1> %cmp, %iszero\n ret <2 x i1> %r\n}\n"}, {"test_name": "is_pow2or0_ctpop_wrong_cmp_op1", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2or0_ctpop_wrong_cmp_op1(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp eq i32 %t0, 2\n %iszero = icmp eq i32 %x, 0\n %r = or i1 %iszero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "blsmsk_is_p2_or_z_ule_yx_fail", "test_body": "define i1 @blsmsk_is_p2_or_z_ule_yx_fail(i8 %xx, i8 %yy) {\n %x = or i8 %xx, %yy\n %xm1 = add i8 %x, -1\n %y = xor i8 %x, %xm1\n %r = icmp ule i8 %y, %x\n ret i1 %r\n}\n"}, {"test_name": "not_pow2_or_z_known_bits", "test_body": "define <2 x i1> @not_pow2_or_z_known_bits(<2 x i32> %xin) {\n %x = or <2 x i32> %xin, splat (i32 64)\n %cnt = call <2 x i32> @llvm.ctpop.v2i32(<2 x i32> %x)\n %r = icmp ugt <2 x i32> %cnt, splat (i32 1)\n ret <2 x i1> %r\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <2 x i32> @llvm.ctpop.v2i32(<2 x i32>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "isnot_pow2_negate_op_vec", "test_body": "define <2 x i1> @isnot_pow2_negate_op_vec(<2 x i32> %x) {\n %neg = sub <2 x i32> zeroinitializer, %x\n %and = and <2 x i32> %neg, %x\n %cmp = icmp ne <2 x i32> %and, %x\n %iszero = icmp eq <2 x i32> %x, zeroinitializer\n %r = or <2 x i1> %iszero, %cmp\n ret <2 x i1> %r\n}\n"}, {"test_name": "is_pow2or0_ctpop_logical", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2or0_ctpop_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp eq i32 %t0, 1\n %iszero = icmp eq i32 %x, 0\n %r = select i1 %iszero, i1 true, i1 %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "isnot_pow2_ctpop_extra_uses", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndeclare void @use_i1(i1)\n\ndefine i1 @isnot_pow2_ctpop_extra_uses(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ugt i32 %t0, 1\n call void @use_i1(i1 %cmp)\n %iszero = icmp eq i32 %x, 0\n call void @use_i1(i1 %iszero)\n %r = or i1 %iszero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "is_power2_or_zero_inv_with_range", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_power2_or_zero_inv_with_range(i32 %x) {\n %ctpop = call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ne i32 %ctpop, 1\n %notzero = icmp ne i32 %x, 0\n %res = select i1 %notzero, i1 %cmp, i1 false\n ret i1 %res\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "isnot_pow2nor0_ctpop_wrong_pred2", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2nor0_ctpop_wrong_pred2(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp eq i32 %t0, 1\n %notzero = icmp eq i32 %x, 0\n %r = and i1 %notzero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "has_single_bit", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @has_single_bit(i32 %x) {\nentry:\n %cmp1 = icmp ne i32 %x, 0\n %popcnt = call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 %x)\n %cmp2 = icmp ult i32 %popcnt, 2\n %sel = select i1 %cmp1, i1 %cmp2, i1 false\n ret i1 %sel\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "is_pow2_fail_pr63327", "test_body": "define i1 @is_pow2_fail_pr63327(i32 %x) {\n %nx = sub i32 0, %x\n %x_and_nx = and i32 %x, %nx\n %r = icmp sge i32 %x_and_nx, %x\n ret i1 %r\n}\n"}, {"test_name": "is_pow2_ctpop", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2_ctpop(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ult i32 %t0, 2\n %notzero = icmp ne i32 %x, 0\n %r = and i1 %notzero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "is_pow2_nz_known_bits_fail_multiuse", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndeclare void @use.i32(i32)\n\ndefine i1 @is_pow2_nz_known_bits_fail_multiuse(i32 %xin) {\n %x = or i32 %xin, 64\n %cnt = call i32 @llvm.ctpop.i32(i32 %x)\n call void @use.i32(i32 %cnt)\n %r = icmp eq i32 %cnt, 1\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "blsmsk_isnt_p2_or_z", "test_body": "define i1 @blsmsk_isnt_p2_or_z(i32 %x) {\n %xm1 = add i32 %x, -1\n %y = xor i32 %x, %xm1\n %r = icmp ult i32 %y, %x\n ret i1 %r\n}\n"}, {"test_name": "isnot_pow2or0_decrement_op", "test_body": "define i1 @isnot_pow2or0_decrement_op(i8 %x) {\n %dec = add i8 %x, -1\n %and = and i8 %dec, %x\n %cmp = icmp ne i8 %and, 0\n ret i1 %cmp\n}\n"}, {"test_name": "not_pow2_nz_known_bits_fail_not_p2_test", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @not_pow2_nz_known_bits_fail_not_p2_test(i32 %xin) {\n %x = or i32 %xin, 1\n %cnt = call i32 @llvm.ctpop.i32(i32 %x)\n %r = icmp ne i32 %cnt, 2\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "isnot_pow2_ctpop_wrong_cmp_op1", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2_ctpop_wrong_cmp_op1(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ugt i32 %t0, 2\n %iszero = icmp eq i32 %x, 0\n %r = or i1 %iszero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "blsmsk_is_p2_or_z_ule_xy", "test_body": "define i1 @blsmsk_is_p2_or_z_ule_xy(i8 %xx, i8 %yy) {\n %x = or i8 %xx, %yy\n %xm1 = add i8 %x, -1\n %y = xor i8 %x, %xm1\n %r = icmp ule i8 %x, %y\n ret i1 %r\n}\n"}, {"test_name": "is_pow2_non_zero_ugt_1", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #1\n\ndefine i1 @is_pow2_non_zero_ugt_1(i32 %x) {\n %notzero = icmp ne i32 %x, 0\n call void @llvm.assume(i1 %notzero)\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ugt i32 %t0, 1\n ret i1 %cmp\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\nattributes #1 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n"}, {"test_name": "isnot_pow2nor0_ctpop_swap_cmp", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2nor0_ctpop_swap_cmp(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ne i32 %t0, 1\n %notzero = icmp ne i32 %x, 0\n %r = and i1 %cmp, %notzero\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "isnot_pow2nor0_ctpop_logical", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2nor0_ctpop_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ne i32 %t0, 1\n %notzero = icmp ne i32 %x, 0\n %r = select i1 %notzero, i1 %cmp, i1 false\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}, {"test_name": "isnot_pow2nor0_ctpop_wrong_cmp_op1", "test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2nor0_ctpop_wrong_cmp_op1(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ne i32 %t0, 4\n %notzero = icmp ne i32 %x, 0\n %r = and i1 %notzero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}]}], "issue": {"title": "[InstCombine] `range` attribute should be dropped in `foldIsPowerOf2OrZero`", "body": "Reproducer: https://alive2.llvm.org/ce/z/u62KKP (Please use latest alive2 with https://github.com/AliveToolkit/alive2/pull/1097)\r\n```\r\ndefine i1 @src(i32 %x) {\r\n %t0 = tail call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 %x)\r\n %cmp = icmp ne i32 %t0, 1\r\n %notzero = icmp ne i32 %x, 0\r\n %r = select i1 %notzero, i1 %cmp, i1 false\r\n ret i1 %r\r\n}\r\n\r\ndefine i1 @tgt(i32 %x) {\r\n %t0 = tail call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 %x)\r\n %r = icmp ugt i32 %t0, 1\r\n ret i1 %r\r\n}\r\n```\r\n```\r\n----------------------------------------\r\ndefine i1 @src(i32 %x) {\r\n#0:\r\n %t0 = ctpop i32 %x\r\n %#range_0_%t0 = !range i32 %t0, i32 1, i32 33\r\n %cmp = icmp ne i32 %#range_0_%t0, 1\r\n %notzero = icmp ne i32 %x, 0\r\n %r = select i1 %notzero, i1 %cmp, i1 0\r\n ret i1 %r\r\n}\r\n=>\r\ndefine i1 @tgt(i32 %x) {\r\n#0:\r\n %t0 = ctpop i32 %x\r\n %#range_0_%t0 = !range i32 %t0, i32 1, i32 33\r\n %r = icmp ugt i32 %#range_0_%t0, 1\r\n ret i1 %r\r\n}\r\nTransformation doesn't verify!\r\n\r\nERROR: Target is more poisonous than source\r\n\r\nExample:\r\ni32 %x = #x00000000 (0)\r\n\r\nSource:\r\ni32 %t0 = #x00000000 (0)\r\ni32 %#range_0_%t0 = poison\r\ni1 %cmp = poison\r\ni1 %notzero = #x0 (0)\r\ni1 %r = #x0 (0)\r\n\r\nTarget:\r\ni32 %t0 = #x00000000 (0)\r\ni32 %#range_0_%t0 = poison\r\ni1 %r = poison\r\nSource value: #x0 (0)\r\nTarget value: poison\r\n```", "author": "dtcxzyw", "labels": ["miscompilation", "llvm:instcombine"], "comments": []}, "verified": true} {"bug_id": "95520", "issue_url": "https://github.com/llvm/llvm-project/issues/95520", "bug_type": "crash", "base_commit": "e7acb3792b8ba971bda2c9564ed26c2a60a2ddbc", "knowledge_cutoff": "2024-06-14T09:26:34Z", "lit_test_dir": ["llvm/test/Transforms/LoopVectorize"], "hints": {"fix_commit": "40a72f8cc414726a8be234a260650fd62354da21", "components": ["LoopVectorize"], "bug_location_lineno": {"llvm/lib/Transforms/Vectorize/VPlan.cpp": [[231, 236]], "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": [[577, 583]]}, "bug_location_funcname": {"llvm/lib/Transforms/Vectorize/VPlan.cpp": ["VPTransformState::get"], "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": ["VPInstruction::generatePerPart"]}}, "patch": "commit 40a72f8cc414726a8be234a260650fd62354da21\nAuthor: Florian Hahn \nDate: Fri Jun 14 22:16:51 2024 +0100\n\n [VPlan] Support extracting any lane of uniform value.\n \n If the value we are extracting a lane from is uniform, only the first\n lane will be set. Return lane 0 for any requested lane.\n \n This fixes a crash when trying to extract the last lane for a\n first-order recurrence resume value.\n \n Fixes https://github.com/llvm/llvm-project/issues/95520.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp\nindex f17be451e684..348a2be5072b 100644\n--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp\n+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp\n@@ -231,6 +231,11 @@ Value *VPTransformState::get(VPValue *Def, const VPIteration &Instance) {\n return Data\n .PerPartScalars[Def][Instance.Part][Instance.Lane.mapToCacheIndex(VF)];\n }\n+ if (!Instance.Lane.isFirstLane() &&\n+ vputils::isUniformAfterVectorization(Def) &&\n+ hasScalarValue(Def, {Instance.Part, VPLane::getFirstLane()})) {\n+ return Data.PerPartScalars[Def][Instance.Part][0];\n+ }\n \n assert(hasVectorValue(Def, Instance.Part));\n auto *VecPart = Data.PerPartOutput[Def][Instance.Part];\ndiff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp\nindex 7a482455473e..a3ff6395bb39 100644\n--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp\n+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp\n@@ -577,7 +577,8 @@ Value *VPInstruction::generatePerPart(VPTransformState &State, unsigned Part) {\n // When loop is unrolled without vectorizing, retrieve UF - Offset.\n Res = State.get(getOperand(0), State.UF - Offset);\n }\n- Res->setName(Name);\n+ if (isa(Res))\n+ Res->setName(Name);\n return Res;\n }\n case VPInstruction::LogicalAnd: {\n", "tests": [{"file": "llvm/test/Transforms/LoopVectorize/AArch64/reduction-recurrence-costs-sve.ll", "commands": ["opt -p loop-vectorize -S %s", "opt -p loop-vectorize -prefer-predicate-over-epilogue=predicate-else-scalar-epilogue -S %s"], "tests": [{"test_name": "chained_recurrences", "test_body": "target datalayout = \"e-m:o-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"arm64-apple-macosx14.0.0\"\n\ndefine i32 @chained_recurrences(i32 %x, i64 %y, ptr %src.1, i32 %z, ptr %src.2) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %0 = phi i32 [ 0, %entry ], [ %3, %loop ]\n %1 = phi i32 [ 0, %entry ], [ %0, %loop ]\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %sum.red = phi i32 [ 0, %entry ], [ %red.2, %loop ]\n %2 = add i64 %y, 1\n %gep.1 = getelementptr i32, ptr %src.1, i64 %2\n %3 = load i32, ptr %gep.1, align 4\n %or3 = or i32 %1, %x\n %iv.next = add i64 %iv, 1\n %shr = lshr i32 %x, 1\n %4 = shl i32 %or3, 1\n %5 = or i32 %4, 2\n %shl19 = shl i32 %x, 1\n %6 = or i32 %shr, %shl19\n %7 = or i32 %6, %5\n %8 = or i32 %7, %x\n %or20 = or i32 %z, %x\n %not = and i32 %or20, 1\n %and = xor i32 %not, 1\n %idx.ext.1 = zext i32 %and to i64\n %gep.2 = getelementptr i32, ptr %src.2, i64 %idx.ext.1\n %9 = load i32, ptr %gep.2, align 4\n %shr24 = lshr i32 %8, 1\n %idx.ext.2 = zext i32 %shr24 to i64\n %gep.3 = getelementptr i32, ptr %src.2, i64 %idx.ext.2\n %10 = load i32, ptr %gep.3, align 4\n %red.1 = or i32 %9, %sum.red\n %red.2 = or i32 %red.1, %10\n %ec = icmp eq i64 %iv, %y\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i32 %red.2\n}\n\nattributes #0 = { \"target-features\"=\"+sve\" }\n"}]}, {"file": "llvm/test/Transforms/LoopVectorize/first-order-recurrence-chains.ll", "commands": ["opt -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -S %s"], "tests": [{"test_name": "test_resinking_required", "test_body": "define double @test_resinking_required(ptr %p, ptr noalias %a, ptr noalias %b) {\nEntry:\n br label %Loop\n\nLoop: ; preds = %Loop, %Entry\n %for.1 = phi double [ %l1, %Loop ], [ 0.000000e+00, %Entry ]\n %for.2 = phi double [ %l2, %Loop ], [ 0.000000e+00, %Entry ]\n %for.3 = phi double [ %for.2, %Loop ], [ 0.000000e+00, %Entry ]\n %iv = phi i64 [ %iv.next, %Loop ], [ 0, %Entry ]\n %USE_2_FORS = fdiv double %for.3, %for.1\n %div = fdiv double 0.000000e+00, %for.1\n %l1 = load double, ptr %a, align 8\n %iv.next = add nuw nsw i64 %iv, 1\n %l2 = load double, ptr %b, align 8\n store double %div, ptr %p, align 8\n %cond = icmp eq i64 %iv.next, 0\n br i1 %cond, label %End, label %Loop\n\nEnd: ; preds = %Loop\n %res.1 = fadd double %for.1, %for.2\n %res.2 = fadd double %res.1, %for.3\n ret double %res.2\n}\n"}]}, {"file": "llvm/test/Transforms/LoopVectorize/first-order-recurrence-complex.ll", "commands": ["opt -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -S %s"], "tests": [{"test_name": "instruction_with_2_FOR_operands_and_multiple_other_uses_chain", "test_body": "define void @instruction_with_2_FOR_operands_and_multiple_other_uses_chain(ptr noalias %dst.1, ptr noalias %dst.2, ptr noalias %dst.3, ptr noalias %for.ptr.1, ptr noalias %for.ptr.2) {\nbb:\n br label %loop\n\nloop: ; preds = %loop, %bb\n %for.1 = phi float [ 0.000000e+00, %bb ], [ %for.1.next, %loop ]\n %for.2 = phi float [ 0.000000e+00, %bb ], [ %for.2.next, %loop ]\n %iv = phi i64 [ 0, %bb ], [ %iv.next, %loop ]\n %for.1.use.1 = fmul fast float %for.1, 2.000000e+00\n %for.1.use.c = fmul fast float %for.1.use.1, 2.000000e+00\n %used.by.both = fmul fast float %for.1.use.c, %for.2\n %for.2.next = load float, ptr %for.ptr.2, align 4\n %for.1.use.3 = fadd fast float %for.1, 1.000000e+00\n %iv.next = add nuw nsw i64 %iv, 1\n %for.1.next = load float, ptr %for.ptr.1, align 4\n %gep.dst.1 = getelementptr inbounds float, ptr %dst.1, i64 %iv\n store float %used.by.both, ptr %gep.dst.1, align 4\n %gep.dst.2 = getelementptr inbounds float, ptr %dst.2, i64 %iv\n store float %for.1.use.1, ptr %gep.dst.2, align 4\n %gep.dst.3 = getelementptr inbounds float, ptr %dst.3, i64 %iv\n store float %for.1.use.3, ptr %gep.dst.3, align 4\n %ec = icmp slt i64 %iv, 1000\n br i1 %ec, label %loop, label %exit\n\nexit: ; preds = %loop\n ret void\n}\n"}, {"test_name": "instruction_with_2_FOR_operands_and_multiple_other_uses", "test_body": "define void @instruction_with_2_FOR_operands_and_multiple_other_uses(ptr noalias %dst.1, ptr noalias %dst.2, ptr noalias %dst.3, ptr noalias %for.ptr.1, ptr noalias %for.ptr.2) {\nbb:\n br label %loop\n\nloop: ; preds = %loop, %bb\n %for.1 = phi float [ 0.000000e+00, %bb ], [ %for.1.next, %loop ]\n %for.2 = phi float [ 0.000000e+00, %bb ], [ %for.2.next, %loop ]\n %iv = phi i64 [ 0, %bb ], [ %iv.next, %loop ]\n %for.1.use.1 = fmul fast float %for.1, 2.000000e+00\n %used.by.both = fmul fast float %for.1, %for.2\n %for.2.next = load float, ptr %for.ptr.2, align 4\n %for.1.use.3 = fadd fast float %for.1, 1.000000e+00\n %iv.next = add nuw nsw i64 %iv, 1\n %for.1.next = load float, ptr %for.ptr.1, align 4\n %gep.dst.1 = getelementptr inbounds float, ptr %dst.1, i64 %iv\n store float %used.by.both, ptr %gep.dst.1, align 4\n %gep.dst.2 = getelementptr inbounds float, ptr %dst.2, i64 %iv\n store float %for.1.use.1, ptr %gep.dst.2, align 4\n %gep.dst.3 = getelementptr inbounds float, ptr %dst.3, i64 %iv\n store float %for.1.use.3, ptr %gep.dst.3, align 4\n %ec = icmp slt i64 %iv, 1000\n br i1 %ec, label %loop, label %exit\n\nexit: ; preds = %loop\n ret void\n}\n"}, {"test_name": "instruction_with_2_FOR_operands", "test_body": "define void @instruction_with_2_FOR_operands(ptr noalias %A, ptr noalias %B, ptr noalias %C) {\nbb:\n br label %bb13\n\nbb13: ; preds = %bb13, %bb\n %tmp37 = phi float [ %tmp60, %bb13 ], [ 0.000000e+00, %bb ]\n %tmp27 = phi float [ %tmp49, %bb13 ], [ 1.000000e+00, %bb ]\n %iv = phi i64 [ %iv.next, %bb13 ], [ 0, %bb ]\n %tmp38 = fmul fast float %tmp37, %tmp27\n %iv.next = add nuw nsw i64 %iv, 1\n %gep = getelementptr inbounds float, ptr %C, i64 %iv\n %tmp49 = load float, ptr %A, align 4\n %tmp60 = load float, ptr %B, align 4\n store float %tmp38, ptr %gep, align 4\n %tmp12 = icmp slt i64 %iv, 1000\n br i1 %tmp12, label %bb13, label %bb74\n\nbb74: ; preds = %bb13\n ret void\n}\n"}]}, {"file": "llvm/test/Transforms/LoopVectorize/first-order-recurrence-multiply-recurrences.ll", "commands": [], "tests": [{"test_name": "test_pr54233_for_depend_on_each_other", "test_body": "define void @test_pr54233_for_depend_on_each_other(ptr noalias %a, ptr noalias %b) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %for.1 = phi i32 [ 0, %entry ], [ %for.1.next, %loop ]\n %for.2 = phi i32 [ 0, %entry ], [ %for.2.next, %loop ]\n %or = or i32 %for.2, 10\n %shl = shl i32 %for.2, %for.1\n %xor = xor i32 %shl, 255\n %and = and i32 %xor, %or\n %for.1.next = xor i32 12, %for.2\n %for.2.next = load i32, ptr %b, align 4\n %a.gep = getelementptr inbounds i32, ptr %a, i64 %iv\n store i32 %and, ptr %a.gep, align 4\n %iv.next = add nuw i64 %iv, 1\n %exitcond = icmp eq i64 %iv, 1000\n br i1 %exitcond, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n"}, {"test_name": "test_pr54223_sink_after_insertion_order", "test_body": "define void @test_pr54223_sink_after_insertion_order(ptr noalias %a, ptr noalias %b, ptr noalias %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %for.1 = phi float [ 0.000000e+00, %entry ], [ %for.1.next, %loop ]\n %for.2 = phi float [ 0.000000e+00, %entry ], [ %for.2.next, %loop ]\n %neg = fneg float %for.2\n %muladd = call float @llvm.fmuladd.f32(float %for.1, float %neg, float 0.000000e+00)\n %dst.gep = getelementptr inbounds float, ptr %dst, i64 %iv\n %iv.next = add nuw nsw i64 %iv, 1\n %for.1.next = load float, ptr %a, align 4\n %for.2.next = load float, ptr %b, align 4\n store float %muladd, ptr %dst.gep, align 4\n %exitcond.not = icmp eq i64 %iv.next, 10000\n br i1 %exitcond.not, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.fmuladd.f32(float, float, float) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"}]}, {"file": "llvm/test/Transforms/LoopVectorize/first-order-recurrence.ll", "commands": ["opt < %s -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=2 -force-widen-divrem-via-safe-divisor=0 -S", "opt < %s -passes=loop-vectorize -force-vector-width=1 -force-vector-interleave=2 -force-widen-divrem-via-safe-divisor=0 -S", "opt < %s -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -force-widen-divrem-via-safe-divisor=0 -S"], "tests": [{"test_name": "recurence_uniform_load", "test_body": "target datalayout = \"e-m:e-i64:64-i128:128-n32:64-S128\"\n\ndefine i32 @recurence_uniform_load(ptr %src, ptr noalias %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %phi = phi i64 [ 0, %entry ], [ %add, %loop ]\n %recur = phi i32 [ 0, %entry ], [ %load, %loop ]\n %add = add i64 %phi, 1\n %load = load i32, ptr %src, align 4\n %icmp = icmp ult i64 %phi, 1\n br i1 %icmp, label %loop, label %exit\n\nexit: ; preds = %loop\n ret i32 0\n}\n"}]}], "issue": {"title": "Assertion `hasVectorValue(Def, Instance.Part)' failed.", "body": "To reproduce run the following test opt with -passes loop-vectorize:\r\n```\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 i32 @wombat() gc \"statepoint-example\" {\r\nbb:\r\n br label %bb2\r\n\r\nbb1: ; preds = %bb2\r\n ret i32 0\r\n\r\nbb2: ; preds = %bb2, %bb\r\n %phi = phi i64 [ 0, %bb ], [ %add, %bb2 ]\r\n %phi3 = phi i32 [ 0, %bb ], [ %load, %bb2 ]\r\n %add = add i64 %phi, 1\r\n %load = load i32, ptr addrspace(1) null, align 4\r\n %icmp = icmp ult i64 %phi, 1\r\n br i1 %icmp, label %bb2, label %bb1\r\n}\r\n```\r\nReproducer: https://godbolt.org/z/cv7Tf3vba\r\n\r\nStack dump:\r\n```\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes loop-vectorize \r\n #0 0x0000000004e41688 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e41688)\r\n #1 0x0000000004e3eddc SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007ec2abe42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x00007ec2abe969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x00007ec2abe42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x00007ec2abe287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00007ec2abe2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x00007ec2abe39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x0000000003fecdce (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3fecdce)\r\n #9 0x0000000004008abe llvm::VPInstruction::generatePerPart(llvm::VPTransformState&, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4008abe)\r\n#10 0x000000000400ae5e llvm::VPInstruction::execute(llvm::VPTransformState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x400ae5e)\r\n#11 0x0000000003fe5fbf llvm::VPBasicBlock::executeRecipes(llvm::VPTransformState*, llvm::BasicBlock*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3fe5fbf)\r\n#12 0x0000000003fe9cb0 llvm::VPBasicBlock::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3fe9cb0)\r\n#13 0x0000000003feda3e llvm::VPlan::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3feda3e)\r\n#14 0x0000000003eda4e5 llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool, llvm::DenseMap, llvm::detail::DenseMapPair> const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3eda4e5)\r\n#15 0x0000000003eef18b llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3eef18b)\r\n#16 0x0000000003ef1a4d llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3ef1a4d)\r\n#17 0x0000000003ef2c5b llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3ef2c5b)\r\n#18 0x0000000002e0679e llvm::detail::PassModel>::run(llvm::Function&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2e0679e)\r\n#19 0x0000000004c49a6c llvm::PassManager>::run(llvm::Function&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4c49a6c)\r\n#20 0x0000000000dbabee llvm::detail::PassModel>, llvm::AnalysisManager>::run(llvm::Function&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xdbabee)\r\n#21 0x0000000004c483ae llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4c483ae)\r\n#22 0x0000000000dbc65e llvm::detail::PassModel>::run(llvm::Module&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xdbc65e)\r\n#23 0x0000000004c462bc llvm::PassManager>::run(llvm::Module&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4c462bc)\r\n#24 0x00000000008db912 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef, llvm::ArrayRef>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8db912)\r\n#25 0x00000000008ceabc optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8ceabc)\r\n#26 0x00007ec2abe29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#27 0x00007ec2abe29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#28 0x00000000008c5f0e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8c5f0e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```\r\n\r\n", "author": "TatyanaDoubts", "labels": ["vectorizers", "crash-on-valid"], "comments": [{"author": "dtcxzyw", "body": "cc @fhahn "}]}, "verified": true} +{"bug_id": "129236", "issue_url": "https://github.com/llvm/llvm-project/issues/129236", "bug_type": "crash", "base_commit": "fa5db05ca36a732bffb8128ff017c575ec6e1201", "knowledge_cutoff": "2025-02-28T12:37:14Z", "lit_test_dir": ["llvm/test/Transforms/LoopVectorize"], "hints": {"fix_commit": "f937b17e8570082d4710b6dca7a91b5c235c1c70", "components": ["LoopVectorize"], "bug_location_lineno": {"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [[6673, 6679]]}, "bug_location_funcname": {"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": ["LoopVectorizationCostModel::getInstructionCost"]}}, "patch": "commit f937b17e8570082d4710b6dca7a91b5c235c1c70\nAuthor: Florian Hahn \nDate: Sun Mar 2 10:55:42 2025 +0000\n\n [LV] Don't query SCEV for non-invariant values in cost model.\n \n This fixes a divergence between VPlan and legacy cost model, matching\n behavior further up in getInstructionCost as well.\n \n Fixes https://github.com/llvm/llvm-project/issues/129236.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\nindex c447fa484359..f3bdc95713af 100644\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n@@ -6673,7 +6673,8 @@ LoopVectorizationCostModel::getInstructionCost(Instruction *I,\n // Certain instructions can be cheaper to vectorize if they have a constant\n // second vector operand. One example of this are shifts on x86.\n Value *Op2 = I->getOperand(1);\n- if (!isa(Op2) && PSE.getSE()->isSCEVable(Op2->getType()) &&\n+ if (!isa(Op2) && TheLoop->isLoopInvariant(Op2) &&\n+ PSE.getSE()->isSCEVable(Op2->getType()) &&\n isa(PSE.getSCEV(Op2))) {\n Op2 = cast(PSE.getSCEV(Op2))->getValue();\n }\n", "tests": [{"file": "llvm/test/Transforms/LoopVectorize/X86/cost-model.ll", "commands": ["opt < %s -passes=loop-vectorize -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7-avx -S"], "tests": [{"test_name": "cost_ashr_with_op_known_invariant_via_scev", "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-apple-macosx10.8.0\"\n\ndefine i32 @cost_ashr_with_op_known_invariant_via_scev(i8 %a) {\nentry:\n %cmp.i = icmp eq i16 0, 0\n %conv.i = sext i16 0 to i32\n %conv5.i = sext i8 %a to i32\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i8 [ 100, %entry ], [ %iv.next, %loop.latch ]\n br i1 %cmp.i, label %then, label %else\n\nthen: ; preds = %else, %loop.header\n %p.1 = phi i32 [ %rem.i, %else ], [ 0, %loop.header ]\n %shr.i = ashr i32 %conv5.i, %p.1\n %tobool6.not.i = icmp eq i32 %shr.i, 0\n %sext.i = shl i32 %p.1, 24\n %0 = ashr exact i32 %sext.i, 24\n %1 = select i1 %tobool6.not.i, i32 %0, i32 0\n br label %loop.latch\n\nelse: ; preds = %loop.header\n %rem.i = urem i32 -1, %conv.i\n %cmp3.i = icmp sgt i32 %rem.i, 1\n br i1 %cmp3.i, label %loop.latch, label %then\n\nloop.latch: ; preds = %else, %then\n %p.2 = phi i32 [ 0, %else ], [ %1, %then ]\n %iv.next = add i8 %iv, -1\n %ec = icmp eq i8 %iv.next, 0\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret i32 %p.2\n}\n"}]}], "issue": {"title": "[clang] Crash at -O2: Assertion Assertion `(BestFactor.Width == LegacyVF.Width || PlanForEarlyExitLoop...' failed.", "body": "This code crashes at `-O2`:\n\n```c\nchar a;\nstruct b {\n short c;\n char d;\n long e;\n int f;\n} static g;\nint h;\nvoid i(struct b j) {\n char k;\n int l;\n for (; j.d; --j.d) {\n l = g.c == 0 ? 0 : 4294967295U % g.c;\n k = l >= 2 || a >> l ? 0 : l;\n h = k;\n }\n}\nvoid m() { i(g); }\n```\n\nCompiler Explorer: https://godbolt.org/z/WG85qYnc6\n\nBisected to https://github.com/llvm/llvm-project/commit/30f3752e54fa7cd595a434a985efbe9a7abe9b65, which was committed by @fhahn \n\nCrash:\n\n```console\nclang: /root/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7589: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || PlanForEarlyExitLoop || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop) || planContainsAdditionalSimplifications(getPlanFor(LegacyVF.Width), CostCtx, OrigLoop)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\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 -O2 -Wall -Wextra \n1.\t parser at end of file\n2.\tOptimizer\n3.\tRunning pass \"function(float2int,lower-constant-intrinsics,loop(loop-rotate,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize,infer-alignment,loop-load-elim,instcombine,simplifycfg,slp-vectorizer,vector-combine,instcombine,loop-unroll,transform-warning,sroa,infer-alignment,instcombine,loop-mssa(licm),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg)\" on module \"\"\n4.\tRunning pass \"loop-vectorize\" on function \"i\"\n #0 0x0000000003e76828 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e76828)\n #1 0x0000000003e744e4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e744e4)\n #2 0x0000000003dc0e18 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0\n #3 0x00007e3b78e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #4 0x00007e3b78e969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #5 0x00007e3b78e42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #6 0x00007e3b78e287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #7 0x00007e3b78e2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #8 0x00007e3b78e39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #9 0x00000000059b6042 llvm::LoopVectorizationPlanner::computeBestVF() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x59b6042)\n#10 0x00000000059cd46c llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x59cd46c)\n#11 0x00000000059cfb19 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x59cfb19)\n#12 0x00000000059d0193 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x59d0193)\n#13 0x0000000005546d4e llvm::detail::PassModel>::run(llvm::Function&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5546d4e)\n#14 0x000000000381d3f0 llvm::PassManager>::run(llvm::Function&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x381d3f0)\n#15 0x000000000119ab8e llvm::detail::PassModel>, llvm::AnalysisManager>::run(llvm::Function&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x119ab8e)\n#16 0x000000000381bd0b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x381bd0b)\n#17 0x0000000001199e3e llvm::detail::PassModel>::run(llvm::Module&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x1199e3e)\n#18 0x000000000381b710 llvm::PassManager>::run(llvm::Module&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x381b710)\n#19 0x00000000041305e8 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr>&, std::unique_ptr>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\n#20 0x000000000413485e clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr, std::unique_ptr>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x413485e)\n#21 0x0000000004835d60 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4835d60)\n#22 0x000000000642100c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x642100c)\n#23 0x0000000004836168 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4836168)\n#24 0x0000000004afe6e5 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4afe6e5)\n#25 0x0000000004a81dce clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4a81dce)\n#26 0x0000000004bec53e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4bec53e)\n#27 0x0000000000d4401f cc1_main(llvm::ArrayRef, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd4401f)\n#28 0x0000000000d3b93a ExecuteCC1Tool(llvm::SmallVectorImpl&, llvm::ToolContext const&) driver.cpp:0:0\n#29 0x000000000487e099 void llvm::function_ref::callback_fn>, std::__cxx11::basic_string, std::allocator>*, bool*) const::'lambda'()>(long) Job.cpp:0:0\n#30 0x0000000003dc12c4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dc12c4)\n#31 0x000000000487e68f clang::driver::CC1Command::Execute(llvm::ArrayRef>, std::__cxx11::basic_string, std::allocator>*, bool*) const (.part.0) Job.cpp:0:0\n#32 0x00000000048412ad clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x48412ad)\n#33 0x000000000484232e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x484232e)\n#34 0x000000000484a2c5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x484a2c5)\n#35 0x0000000000d40e13 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd40e13)\n#36 0x0000000000c11aa4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc11aa4)\n#37 0x00007e3b78e29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#38 0x00007e3b78e29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#39 0x0000000000d3b3e5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd3b3e5)\n```", "author": "cardigan1008", "labels": ["regression", "vectorizers", "crash"], "comments": []}, "verified": true} {"bug_id": "79175", "issue_url": "https://github.com/llvm/llvm-project/issues/79175", "bug_type": "miscompilation", "base_commit": "e538486e90539096e7851d0deba4ea9ed94fced2", "knowledge_cutoff": "2024-01-23T17:34:28Z", "lit_test_dir": ["llvm/test/Transforms/JumpThreading"], "hints": {"fix_commit": "4f32f5d5720fbef06672714a62376f236a36aef5", "components": ["JumpThreading", "AliasAnalysis"], "bug_location_lineno": {"llvm/include/llvm/Analysis/AliasAnalysis.h": [[287, 292], [668, 673]], "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": [[43, 62]], "llvm/lib/Analysis/BasicAliasAnalysis.cpp": [[89, 95], [1063, 1068], [1556, 1561], [1735, 1741]], "llvm/lib/Transforms/Scalar/JumpThreading.cpp": [[1261, 1266]]}, "bug_location_funcname": {"llvm/include/llvm/Analysis/AliasAnalysis.h": ["AAQueryInfo", "enableCrossIterationMode"], "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": ["BasicAAResult"], "llvm/lib/Analysis/BasicAliasAnalysis.cpp": ["BasicAAResult::aliasCheck", "BasicAAResult::aliasGEP", "BasicAAResult::invalidate", "BasicAAResult::isValueEqualInPotentialCycles", "BasicAAResult::subtractDecomposedGEPs"], "llvm/lib/Transforms/Scalar/JumpThreading.cpp": ["JumpThreadingPass::simplifyPartiallyRedundantLoad"]}}, "patch": "commit 4f32f5d5720fbef06672714a62376f236a36aef5\nAuthor: Nikita Popov \nDate: Wed Jan 31 15:23:53 2024 +0100\n\n [AA][JumpThreading] Don't use DomTree for AA in JumpThreading (#79294)\n \n JumpThreading may perform AA queries while the dominator tree is not up\n to date, which may result in miscompilations.\n \n Fix this by adding a new AAQI option to disable the use of the dominator\n tree in BasicAA.\n \n Fixes https://github.com/llvm/llvm-project/issues/79175.\n\ndiff --git a/llvm/include/llvm/Analysis/AliasAnalysis.h b/llvm/include/llvm/Analysis/AliasAnalysis.h\nindex d6f732d35fd4..e8e4f491be5a 100644\n--- a/llvm/include/llvm/Analysis/AliasAnalysis.h\n+++ b/llvm/include/llvm/Analysis/AliasAnalysis.h\n@@ -287,6 +287,10 @@ public:\n /// store %l, ...\n bool MayBeCrossIteration = false;\n \n+ /// Whether alias analysis is allowed to use the dominator tree, for use by\n+ /// passes that lazily update the DT while performing AA queries.\n+ bool UseDominatorTree = true;\n+\n AAQueryInfo(AAResults &AAR, CaptureInfo *CI) : AAR(AAR), CI(CI) {}\n };\n \n@@ -668,6 +672,9 @@ public:\n void enableCrossIterationMode() {\n AAQI.MayBeCrossIteration = true;\n }\n+\n+ /// Disable the use of the dominator tree during alias analysis queries.\n+ void disableDominatorTree() { AAQI.UseDominatorTree = false; }\n };\n \n /// Temporary typedef for legacy code that uses a generic \\c AliasAnalysis\ndiff --git a/llvm/include/llvm/Analysis/BasicAliasAnalysis.h b/llvm/include/llvm/Analysis/BasicAliasAnalysis.h\nindex afc1811239f2..7eca82729430 100644\n--- a/llvm/include/llvm/Analysis/BasicAliasAnalysis.h\n+++ b/llvm/include/llvm/Analysis/BasicAliasAnalysis.h\n@@ -43,20 +43,26 @@ class BasicAAResult : public AAResultBase {\n const Function &F;\n const TargetLibraryInfo &TLI;\n AssumptionCache &AC;\n- DominatorTree *DT;\n+ /// Use getDT() instead of accessing this member directly, in order to\n+ /// respect the AAQI.UseDominatorTree option.\n+ DominatorTree *DT_;\n+\n+ DominatorTree *getDT(const AAQueryInfo &AAQI) const {\n+ return AAQI.UseDominatorTree ? DT_ : nullptr;\n+ }\n \n public:\n BasicAAResult(const DataLayout &DL, const Function &F,\n const TargetLibraryInfo &TLI, AssumptionCache &AC,\n DominatorTree *DT = nullptr)\n- : DL(DL), F(F), TLI(TLI), AC(AC), DT(DT) {}\n+ : DL(DL), F(F), TLI(TLI), AC(AC), DT_(DT) {}\n \n BasicAAResult(const BasicAAResult &Arg)\n : AAResultBase(Arg), DL(Arg.DL), F(Arg.F), TLI(Arg.TLI), AC(Arg.AC),\n- DT(Arg.DT) {}\n+ DT_(Arg.DT_) {}\n BasicAAResult(BasicAAResult &&Arg)\n : AAResultBase(std::move(Arg)), DL(Arg.DL), F(Arg.F), TLI(Arg.TLI),\n- AC(Arg.AC), DT(Arg.DT) {}\n+ AC(Arg.AC), DT_(Arg.DT_) {}\n \n /// Handle invalidation events in the new pass manager.\n bool invalidate(Function &Fn, const PreservedAnalyses &PA,\ndiff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp\nindex 3178e2d27816..1028b52a7912 100644\n--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp\n+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp\n@@ -89,7 +89,7 @@ bool BasicAAResult::invalidate(Function &Fn, const PreservedAnalyses &PA,\n // may be created without handles to some analyses and in that case don't\n // depend on them.\n if (Inv.invalidate(Fn, PA) ||\n- (DT && Inv.invalidate(Fn, PA)))\n+ (DT_ && Inv.invalidate(Fn, PA)))\n return true;\n \n // Otherwise this analysis result remains valid.\n@@ -1063,6 +1063,7 @@ AliasResult BasicAAResult::aliasGEP(\n : AliasResult::MayAlias;\n }\n \n+ DominatorTree *DT = getDT(AAQI);\n DecomposedGEP DecompGEP1 = DecomposeGEPExpression(GEP1, DL, &AC, DT);\n DecomposedGEP DecompGEP2 = DecomposeGEPExpression(V2, DL, &AC, DT);\n \n@@ -1556,6 +1557,7 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, LocationSize V1Size,\n const Value *HintO1 = getUnderlyingObject(Hint1);\n const Value *HintO2 = getUnderlyingObject(Hint2);\n \n+ DominatorTree *DT = getDT(AAQI);\n auto ValidAssumeForPtrContext = [&](const Value *Ptr) {\n if (const Instruction *PtrI = dyn_cast(Ptr)) {\n return isValidAssumeForContext(Assume, PtrI, DT,\n@@ -1735,7 +1737,7 @@ bool BasicAAResult::isValueEqualInPotentialCycles(const Value *V,\n if (!Inst || Inst->getParent()->isEntryBlock())\n return true;\n \n- return isNotInCycle(Inst, DT, /*LI*/ nullptr);\n+ return isNotInCycle(Inst, getDT(AAQI), /*LI*/ nullptr);\n }\n \n /// Computes the symbolic difference between two de-composed GEPs.\ndiff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp\nindex b7cf02489631..bb33a5da288c 100644\n--- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp\n+++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp\n@@ -1261,6 +1261,8 @@ bool JumpThreadingPass::simplifyPartiallyRedundantLoad(LoadInst *LoadI) {\n BasicBlock::iterator BBIt(LoadI);\n bool IsLoadCSE;\n BatchAAResults BatchAA(*AA);\n+ // The dominator tree is updated lazily and may not be valid at this point.\n+ BatchAA.disableDominatorTree();\n if (Value *AvailableVal = FindAvailableLoadedValue(\n LoadI, LoadBB, BBIt, DefMaxInstsToScan, &BatchAA, &IsLoadCSE)) {\n // If the value of the load is locally available within the block, just use\n", "tests": [{"file": "llvm/test/Transforms/JumpThreading/pr79175.ll", "commands": ["opt -S -passes=jump-threading < %s"], "tests": [{"test_name": "test", "test_body": "@f = external global i32\n\ndefine i32 @test(i64 %idx, i32 %val) {\nentry:\n %cmp = icmp slt i64 %idx, 1\n br i1 %cmp, label %for.body, label %return\n\nfor.body: ; preds = %entry\n %f = load i32, ptr @f, align 4\n %cmp1 = icmp eq i32 %f, 0\n br i1 %cmp1, label %cond.end, label %cond.false\n\ncond.false: ; preds = %for.body\n br label %cond.end\n\ncond.end: ; preds = %cond.false, %for.body\n %phi = phi i32 [ %val, %cond.false ], [ 1, %for.body ]\n %cmp.i = icmp sgt i32 %phi, 0\n %sel = select i1 %cmp.i, i32 0, i32 %phi\n %f.idx = getelementptr inbounds i32, ptr @f, i64 %idx\n store i32 %sel, ptr %f.idx, align 4\n %f.reload = load i32, ptr @f, align 4\n %cmp3 = icmp slt i32 %f.reload, 1\n br i1 %cmp3, label %return2, label %return\n\nreturn: ; preds = %cond.end, %entry\n ret i32 0\n\nreturn2: ; preds = %cond.end\n ret i32 1\n}\n"}]}], "issue": {"title": "WRONG code, likely JumpThreadingPass", "body": "[wrong0.tar.gz](https://github.com/llvm/llvm-project/files/14027750/wrong0.tar.gz)\r\n(reduced c test case, should print 0)\r\n\r\nrunline:\r\nclang -O3 -march=arch13 wrong0.i -o a.out -w -mllvm -available-load-scan-limit=12\r\n\r\nThe function n() below is called two times in the reduced test case. The first time f[0] has a value of 0 at the start of the function, and a value of 1 at the end. The second time n() is called, f[0] has a value of 1 at the top, while it is then set to 0 by k().\r\n```\r\nlong k(long l, int m); // returns 0 \r\n\r\nconst int *n() {\r\n for (; C <= 0;) {\r\n A = (f[0] == 0 ? 1 : A % f[0]);\r\n f[C] = k(A, 0);\r\n g = &f[0];\r\n f[C] = 1 > *g;\r\n if (f[C])\r\n return &e;\r\n break;\r\n }\r\n return 0;\r\n}\r\n```\r\nThis is the transformation of jump threading:\r\n\r\n```\r\n > *** IR Dump After JumpThreadingPass on n ***\r\n > ; Function Attrs: nounwind\r\ndefine dso_local ptr @n() local_unnamed_addr #1 { define dso_local ptr @n() local_unnamed_addr #1 {\r\nentry: entry:\r\n %0 = load i64, ptr @C, align 8, !tbaa !4 %0 = load i64, ptr @C, align 8, !tbaa !4\r\n %cmp = icmp slt i64 %0, 1 %cmp = icmp slt i64 %0, 1\r\n br i1 %cmp, label %for.body, label %for.end br i1 %cmp, label %for.body, label %for.end\r\n\r\nfor.body: ; preds = %entry for.body: ; preds = %entry\r\n %1 = load i32, ptr @f, align 4, !tbaa !8 %1 = load i32, ptr @f, align 4, !tbaa !8\r\n %cmp1 = icmp eq i32 %1, 0 %cmp1 = icmp eq i32 %1, 0\r\n br i1 %cmp1, label %cond.end, label %cond.false | br i1 %cmp1, label %cond.end.thread, label %cond.end\r\n\r\ncond.false: ; preds = %for.body | cond.end.thread: ; preds = %for.body\r\n > store i64 1, ptr @A, align 8, !tbaa !4\r\n > br label %3\r\n >\r\n > cond.end: ; preds = %for.body\r\n %2 = load i64, ptr @A, align 8, !tbaa !4 %2 = load i64, ptr @A, align 8, !tbaa !4\r\n %conv = sext i32 %1 to i64 %conv = sext i32 %1 to i64\r\n %rem = srem i64 %2, %conv %rem = srem i64 %2, %conv\r\n br label %cond.end | store i64 %rem, ptr @A, align 8, !tbaa !4\r\n > %cmp.i = icmp sgt i64 %rem, 0\r\n > %cond.fr = freeze i1 %cmp.i\r\n > br i1 %cond.fr, label %3, label %4\r\n >\r\n > 3: ; preds = %cond.end.\r\n > %.pr = load i32, ptr @f, align 4, !tbaa !8\r\n > br label %4\r\n\r\ncond.end: ; preds = %for.body, | 4: ; preds = %cond.end,\r\n %cond = phi i64 [ %rem, %cond.false ], [ 1, %for.body ] | %5 = phi i32 [ %1, %cond.end ], [ %.pr, %3 ]\r\n store i64 %cond, ptr @A, align 8, !tbaa !4 | %6 = phi i64 [ 0, %3 ], [ %rem, %cond.end ]\r\n %cmp.i = icmp sgt i64 %cond, 0 | %conv2 = trunc i64 %6 to i32\r\n %cond.i = select i1 %cmp.i, i64 0, i64 %cond <\r\n %conv2 = trunc i64 %cond.i to i32 <\r\n %arrayidx = getelementptr inbounds [1 x i32], ptr @f, i64 0, i64 %0 %arrayidx = getelementptr inbounds [1 x i32], ptr @f, i64 0, i64 %0\r\n store i32 %conv2, ptr %arrayidx, align 4, !tbaa !8 store i32 %conv2, ptr %arrayidx, align 4, !tbaa !8\r\n store ptr @f, ptr @g, align 8, !tbaa !10 store ptr @f, ptr @g, align 8, !tbaa !10\r\n %3 = load i32, ptr @f, align 4, !tbaa !8 | %cmp3 = icmp slt i32 %5, 1\r\n %cmp3 = icmp slt i32 %3, 1 <\r\n %conv4 = zext i1 %cmp3 to i32 %conv4 = zext i1 %cmp3 to i32\r\n store i32 %conv4, ptr %arrayidx, align 4, !tbaa !8 store i32 %conv4, ptr %arrayidx, align 4, !tbaa !8\r\n br i1 %cmp3, label %return, label %for.end br i1 %cmp3, label %return, label %for.end\r\n\r\nfor.end: ; preds = %cond.end, | for.end: ; preds = %4, %entry\r\n br label %return br label %return\r\n\r\nreturn: ; preds = %cond.end, | return: ; preds = %4, %for.e\r\n %retval.0 = phi ptr [ null, %for.end ], [ @e, %cond.end ] | %retval.0 = phi ptr [ null, %for.end ], [ @e, %4 ]\r\n ret ptr %retval.0 ret ptr %retval.0\r\n} }\r\n~\r\n\r\n```\r\n\r\nBefore (left), `@f `is reloaded for the final icmp in cond.end (%3), which is necessary as the store to %conv2 just above goes to the same address. However, to the right JumpThreading has changed the final icmp to use the %5 value, which does not reflect the stored value of %conv2. This seems wrong and maybe JT has missed the fact that %arrayidx aliases `@f`?\r\n\r\n@jmorse @MatzeB @nikic \r\n", "author": "JonPsson1", "labels": ["miscompilation", "llvm:analysis", "llvm:transforms"], "comments": [{"author": "jmorse", "body": "Here's a godbolt link seemingly showing the same thing: https://godbolt.org/z/dMPaP7161 . I can't replicate this at 6a7abea47 with just `opt --passes=jump-threading`, but can if it's part of clang and inspected with `print-after-all`."}, {"author": "jmorse", "body": "Ah -- because it's sensitive to the `-available-load-scan-limit=12`, which defaults to six and needs to be at least ten for this problem to appear. Stepping through bits of opt, the AA trace believes something that's wrong:\r\n\r\n```\r\nStart %arrayidx = getelementptr inbounds [1 x i32], ptr @f, i64 0, i64 %0 @ LocationSize::precise(4), @f = dso_local global [1 x i32] zeroinitializer, align 4 @ LocationSize::precise(4)\r\n Start @f = dso_local global [1 x i32] zeroinitializer, align 4 @ LocationSize::beforeOrAfterPointer, @f = dso_local global [1 x i32] zeroinitializer, align 4 @ LocationSize::beforeOrAfterPointer\r\n End @f = dso_local global [1 x i32] zeroinitializer, align 4 @ LocationSize::beforeOrAfterPointer, @f = dso_local global [1 x i32] zeroinitializer, align 4 @ LocationSize::beforeOrAfterPointer = MustAlias\r\nEnd %arrayidx = getelementptr inbounds [1 x i32], ptr @f, i64 0, i64 %0 @ LocationSize::precise(4), @f = dso_local global [1 x i32] zeroinitializer, align 4 @ LocationSize::precise(4) = NoAlias\r\n```\r\n\r\nWhich I think is saying that the GEP is believed to not-alias the \"f\" variable, wheras it might alias depending on the value of %0. Stepping through other things during the alias query, I see `isKnownNonNullFromDominatingCondition` returning true for %0, i.e. the load from \"C\". I would imagine this means there's something wrong with the dominator tree that makes this code think it's only executing on a path where %0 is always-zero. (EDIT: actually it means always-non-zero).\r\n\r\n(However this isn't my normal wheelhouse, so that might not be true!)."}, {"author": "nikic", "body": "That sounds about right to me. JumpThreading performs lazy DT updates, so it's not legal to use DT during the transform.\r\n\r\nBasicAA in principle already supports working without DT, but it may be a bit tricky to avoid the DT use just in JumpThreading, given how this is all wired up in the pass manager."}, {"author": "nikic", "body": "Somewhat reduced test case:\r\n```llvm\r\n; RUN: opt -S -passes=jump-threading < %s\r\n@f = external global i32\r\n\r\ndefine void @test(i64 %idx, i32 %val) {\r\nentry:\r\n %cmp = icmp slt i64 %idx, 1\r\n br i1 %cmp, label %for.body, label %return\r\n\r\nfor.body:\r\n %f = load i32, ptr @f, align 4\r\n %cmp1 = icmp eq i32 %f, 0\r\n br i1 %cmp1, label %cond.end, label %cond.false\r\n\r\ncond.false:\r\n br label %cond.end\r\n\r\ncond.end:\r\n %phi = phi i32 [ %val, %cond.false ], [ 1, %for.body ]\r\n %cmp.i = icmp sgt i32 %phi, 0\r\n %sel = select i1 %cmp.i, i32 0, i32 %phi\r\n %f.idx = getelementptr inbounds i32, ptr @f, i64 %idx\r\n store i32 %sel, ptr %f.idx, align 4\r\n %f.reload = load i32, ptr @f, align 4\r\n %cmp3 = icmp slt i32 %f.reload, 1\r\n br i1 %cmp3, label %return, label %return\r\n\r\nreturn:\r\n ret void\r\n}\r\n```"}, {"author": "EugeneZelenko", "body": "Not merged yet."}, {"author": "tstellar", "body": "PR has been created, we will track the status there."}]}, "verified": true} {"bug_id": "91178", "issue_url": "https://github.com/llvm/llvm-project/issues/91178", "bug_type": "miscompilation", "base_commit": "7098cd215b95286794d9e0c822e8323ad0509750", "knowledge_cutoff": "2024-05-06T09:44:48Z", "lit_test_dir": ["llvm/test/Transforms/InstCombine", "llvm/test/Transforms/PGOProfile"], "hints": {"fix_commit": "d085b42cbbefe79a41113abcd2b1e1f2a203acef", "components": ["InstructionSimplify"], "bug_location_lineno": {"llvm/lib/Analysis/InstructionSimplify.cpp": [[4312, 4317]]}, "bug_location_funcname": {"llvm/lib/Analysis/InstructionSimplify.cpp": ["simplifyWithOpReplaced"]}}, "patch": "commit d085b42cbbefe79a41113abcd2b1e1f2a203acef\nAuthor: Yingwei Zheng \nDate: Wed May 8 10:04:09 2024 +0800\n\n [InstSimplify] Do not simplify freeze in `simplifyWithOpReplaced` (#91215)\n \n See the LangRef:\n > All uses of a value returned by the same ‘freeze’ instruction are\n guaranteed to always observe the same value, while different ‘freeze’\n instructions may yield different values.\n \n It is incorrect to replace freezes with the simplified value.\n \n Proof:\n https://alive2.llvm.org/ce/z/3Dn9Cd\n https://alive2.llvm.org/ce/z/Qyh5h6\n \n Fixes https://github.com/llvm/llvm-project/issues/91178\n\ndiff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp\nindex 4061dae83c10..37a7259a5cd0 100644\n--- a/llvm/lib/Analysis/InstructionSimplify.cpp\n+++ b/llvm/lib/Analysis/InstructionSimplify.cpp\n@@ -4312,6 +4312,10 @@ static Value *simplifyWithOpReplaced(Value *V, Value *Op, Value *RepOp,\n if (match(I, m_Intrinsic()))\n return nullptr;\n \n+ // Don't simplify freeze.\n+ if (isa(I))\n+ return nullptr;\n+\n // Replace Op with RepOp in instruction operands.\n SmallVector NewOps;\n bool AnyReplaced = false;\n", "tests": [{"file": "llvm/test/Transforms/InstCombine/icmp.ll", "commands": ["opt < %s -passes=instcombine -S"], "tests": [{"test_name": "icmp_freeze_sext", "test_body": "target datalayout = \"e-p:64:64:64-p1:16:16:16-p2:32:32:32-p3: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\"\n\ndefine i1 @icmp_freeze_sext(i16 %x, i16 %y) {\n %cmp1 = icmp uge i16 %x, %y\n %ext = sext i1 %cmp1 to i16\n %ext.fr = freeze i16 %ext\n %cmp2 = icmp uge i16 %ext.fr, %y\n ret i1 %cmp2\n}\n"}]}, {"file": "llvm/test/Transforms/InstCombine/select.ll", "commands": ["opt < %s -passes=instcombine -S"], "tests": [{"test_name": "test_replace_freeze_oneuse", "test_body": "target datalayout = \"e-p:64:64-p1:16:16-p2:32:32:32-p3:64:64:64\"\n\ndefine i8 @test_replace_freeze_oneuse(i1 %x, i8 %y) {\n %ext = zext i1 %x to i8\n %shl = shl nuw i8 %ext, %y\n %shl.fr = freeze i8 %shl\n %sel = select i1 %x, i8 0, i8 %shl.fr\n ret i8 %sel\n}\n"}, {"test_name": "sequence_select_with_same_cond_extra_use", "test_body": "target datalayout = \"e-p:64:64-p1:16:16-p2:32:32:32-p3:64:64:64\"\n\ndeclare void @use32(i32)\n\ndefine i32 @sequence_select_with_same_cond_extra_use(i1 %c1, i1 %c2) {\n %s1 = select i1 %c1, i32 23, i32 45\n call void @use32(i32 %s1)\n %s2 = select i1 %c2, i32 666, i32 %s1\n %s3 = select i1 %c1, i32 789, i32 %s2\n ret i32 %s3\n}\n"}, {"test_name": "test_replace_freeze_multiuse", "test_body": "target datalayout = \"e-p:64:64-p1:16:16-p2:32:32:32-p3:64:64:64\"\n\ndefine i8 @test_replace_freeze_multiuse(i1 %x, i8 %y) {\n %ext = zext i1 %x to i8\n %shl = shl nuw i8 %ext, %y\n %shl.fr = freeze i8 %shl\n %sel = select i1 %x, i8 0, i8 %shl.fr\n %add = add i8 %shl.fr, %sel\n ret i8 %add\n}\n"}]}], "issue": {"title": "[InstCombine] Miscompilation which simplifies a use of a multi-use freeze", "body": "Reduced test case: https://alive2.llvm.org/ce/z/_JyUGw\r\n```\r\ndefine i8 @func78(i1 %0, i8 %1) {\r\n %3 = zext i1 %0 to i8\r\n %4 = shl i8 %3, %1\r\n %5 = freeze i8 %4\r\n %6 = select i1 %0, i8 0, i8 %5\r\n %7 = call i8 @llvm.fshr.i8(i8 0, i8 %5, i8 %6)\r\n ret i8 %7\r\n}\r\n```\r\n\r\n```\r\n----------------------------------------\r\ndefine i8 @func78(i1 %#0, i8 %#1) {\r\n#2:\r\n %#3 = zext i1 %#0 to i8\r\n %#4 = shl i8 %#3, %#1\r\n %#5 = freeze i8 %#4\r\n %#6 = select i1 %#0, i8 0, i8 %#5\r\n %#7 = fshr i8 0, i8 %#5, i8 %#6\r\n ret i8 %#7\r\n}\r\n=>\r\ndefine i8 @func78(i1 %#0, i8 %#1) nofree noundef willreturn memory(none) {\r\n#2:\r\n %#3 = zext i1 %#0 to i8\r\n %#4 = shl nuw i8 %#3, %#1\r\n %#5 = freeze i8 %#4\r\n ret i8 %#5\r\n}\r\nTransformation doesn't verify!\r\n\r\nERROR: Value mismatch\r\n\r\nExample:\r\ni1 %#0 = #x0 (0)\r\ni8 %#1 = #x08 (8)\r\n\r\nSource:\r\ni8 %#3 = #x00 (0)\r\ni8 %#4 = poison\r\ni8 %#5 = #x00 (0)\r\ni8 %#6 = #x00 (0)\r\ni8 %#7 = #x00 (0)\r\n\r\nTarget:\r\ni8 %#3 = #x00 (0)\r\ni8 %#4 = poison\r\ni8 %#5 = #x9d (157, -99)\r\nSource value: #x00 (0)\r\nTarget value: #x9d (157, -99)\r\n\r\nSummary:\r\n 0 correct transformations\r\n 1 incorrect transformations\r\n 0 failed-to-prove transformations\r\n 0 Alive2 errors\r\n```", "author": "dtcxzyw", "labels": ["miscompilation", "llvm:instcombine"], "comments": []}, "verified": true} {"bug_id": "121584", "issue_url": "https://github.com/llvm/llvm-project/issues/121584", "bug_type": "miscompilation", "base_commit": "4a7c0b8afe6bf616cd6bb4f13b5b706a43c10e74", "knowledge_cutoff": "2025-01-03T17:05:45Z", "lit_test_dir": ["llvm/test/Transforms/InstCombine"], "hints": {"fix_commit": "24c2ba07ce65a5bf7d1113e05c517169d950b663", "components": ["InstCombine"], "bug_location_lineno": {"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": [[2066, 2079], [2095, 2101], [2108, 2114], [2131, 2137]]}, "bug_location_funcname": {"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": ["simplifyIRemMulShl"]}}, "patch": "commit 24c2ba07ce65a5bf7d1113e05c517169d950b663\nAuthor: Yingwei Zheng \nDate: Sun Jan 5 01:20:54 2025 +0800\n\n [InstCombine] Drop NSW when converting `shl X, BW - 1` back into mul (#121633)\n \n `X < bool {\n+ auto MatchShiftOrMulXC = [](Value *Op, Value *&V, APInt &C,\n+ bool &PreserveNSW) -> bool {\n const APInt *Tmp = nullptr;\n if ((!V && match(Op, m_Mul(m_Value(V), m_APInt(Tmp)))) ||\n (V && match(Op, m_Mul(m_Specific(V), m_APInt(Tmp)))))\n C = *Tmp;\n else if ((!V && match(Op, m_Shl(m_Value(V), m_APInt(Tmp)))) ||\n- (V && match(Op, m_Shl(m_Specific(V), m_APInt(Tmp)))))\n+ (V && match(Op, m_Shl(m_Specific(V), m_APInt(Tmp))))) {\n C = APInt(Tmp->getBitWidth(), 1) << *Tmp;\n+ // We cannot preserve NSW when shifting by BW - 1.\n+ PreserveNSW = Tmp->ult(Tmp->getBitWidth() - 1);\n+ }\n if (Tmp != nullptr)\n return true;\n \n@@ -2095,7 +2099,9 @@ static Instruction *simplifyIRemMulShl(BinaryOperator &I,\n return false;\n };\n \n- if (MatchShiftOrMulXC(Op0, X, Y) && MatchShiftOrMulXC(Op1, X, Z)) {\n+ bool Op0PreserveNSW = true, Op1PreserveNSW = true;\n+ if (MatchShiftOrMulXC(Op0, X, Y, Op0PreserveNSW) &&\n+ MatchShiftOrMulXC(Op1, X, Z, Op1PreserveNSW)) {\n // pass\n } else if (MatchShiftCX(Op0, Y, X) && MatchShiftCX(Op1, Z, X)) {\n ShiftByX = true;\n@@ -2108,7 +2114,7 @@ static Instruction *simplifyIRemMulShl(BinaryOperator &I,\n OverflowingBinaryOperator *BO0 = cast(Op0);\n // TODO: We may be able to deduce more about nsw/nuw of BO0/BO1 based on Y >=\n // Z or Z >= Y.\n- bool BO0HasNSW = BO0->hasNoSignedWrap();\n+ bool BO0HasNSW = Op0PreserveNSW && BO0->hasNoSignedWrap();\n bool BO0HasNUW = BO0->hasNoUnsignedWrap();\n bool BO0NoWrap = IsSRem ? BO0HasNSW : BO0HasNUW;\n \n@@ -2131,7 +2137,7 @@ static Instruction *simplifyIRemMulShl(BinaryOperator &I,\n };\n \n OverflowingBinaryOperator *BO1 = cast(Op1);\n- bool BO1HasNSW = BO1->hasNoSignedWrap();\n+ bool BO1HasNSW = Op1PreserveNSW && BO1->hasNoSignedWrap();\n bool BO1HasNUW = BO1->hasNoUnsignedWrap();\n bool BO1NoWrap = IsSRem ? BO1HasNSW : BO1HasNUW;\n // (rem (mul X, Y), (mul nuw/nsw X, Z))\n", "tests": [{"file": "llvm/test/Transforms/InstCombine/rem-mul-shl.ll", "commands": ["opt < %s -passes=instcombine -S"], "tests": [{"test_name": "srem_XY_XZ_with_CY_gt_CZ_no_nuw_out", "test_body": "define <2 x i8> @srem_XY_XZ_with_CY_gt_CZ_no_nuw_out(<2 x i8> %X) {\n %BO0 = mul nsw <2 x i8> %X, splat (i8 10)\n %BO1 = shl nuw nsw <2 x i8> %X, splat (i8 3)\n %r = srem <2 x i8> %BO0, %BO1\n ret <2 x i8> %r\n}\n"}, {"test_name": "srem_XY_XZ_with_CY_gt_CZ_drop_nsw_commuted", "test_body": "define i8 @srem_XY_XZ_with_CY_gt_CZ_drop_nsw_commuted(i8 noundef %X) {\n %BO0 = mul nsw i8 %X, 127\n %BO1 = shl nsw i8 %X, 7\n %r = srem i8 %BO0, %BO1\n ret i8 %r\n}\n"}, {"test_name": "srem_XY_XZ_with_CY_gt_CZ_drop_nsw", "test_body": "define i8 @srem_XY_XZ_with_CY_gt_CZ_drop_nsw(i8 noundef %X) {\n %BO0 = mul nsw i8 %X, 127\n %BO1 = shl nsw i8 %X, 7\n %r = srem i8 %BO1, %BO0\n ret i8 %r\n}\n"}, {"test_name": "srem_XY_XZ_with_CY_gt_CZ_fail_missing_flag1", "test_body": "define i8 @srem_XY_XZ_with_CY_gt_CZ_fail_missing_flag1(i8 %X) {\n %BO0 = mul nuw nsw i8 %X, 10\n %BO1 = mul nuw i8 %X, 6\n %r = srem i8 %BO0, %BO1\n ret i8 %r\n}\n"}]}], "issue": {"title": "[InstCombine] Miscompilation in `simplifyIRemMulShl`", "body": "Alive2: https://alive2.llvm.org/ce/z/rdeehL\n```\n\n----------------------------------------\ndefine i8 @srem_XY_XZ_with_CY_gt_CZ_no_nuw_out1(i8 noundef %X) {\n#0:\n %BO0 = mul nsw i8 noundef %X, 127\n %BO1 = shl nsw i8 noundef %X, 7\n %r = srem i8 %BO1, %BO0\n ret i8 %r\n}\n=>\ndefine i8 @srem_XY_XZ_with_CY_gt_CZ_no_nuw_out1(i8 noundef %X) {\n#0:\n %r = sub nsw i8 0, noundef %X\n ret i8 %r\n}\nTransformation doesn't verify!\n\nERROR: Value mismatch\n\nExample:\ni8 noundef %X = #xff (255, -1)\n\nSource:\ni8 %BO0 = #x81 (129, -127)\ni8 %BO1 = #x80 (128, -128)\ni8 %r = #xff (255, -1)\n\nTarget:\ni8 %r = #x01 (1)\nSource value: #xff (255, -1)\nTarget value: #x01 (1)\n\nSummary:\n 0 correct transformations\n 1 incorrect transformations\n 0 failed-to-prove transformations\n 0 Alive2 errors\n```", "author": "dtcxzyw", "labels": ["miscompilation", "llvm:instcombine"], "comments": []}, "verified": true}