Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LoopVectorize assertion failure #58722

Closed
nikic opened this issue Nov 1, 2022 · 5 comments · Fixed by llvm/llvm-project-release-prs#215
Closed

LoopVectorize assertion failure #58722

nikic opened this issue Nov 1, 2022 · 5 comments · Fixed by llvm/llvm-project-release-prs#215
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] release:backport release:merged vectorizers

Comments

@nikic
Copy link
Contributor

nikic commented Nov 1, 2022

; RUN: opt -S -loop-vectorize < %s
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64-unknown-linux-gnu"

define void @test(ptr %start, ptr %end) {
entry:
  br label %loop

loop:
  %ptr = phi ptr [ %start, %entry ], [ %ptr.next, %loop.latch ]
  %cmp = icmp eq ptr %ptr, %end
  br i1 %cmp, label %exit, label %loop.latch

loop.latch:
  %ptr.next = getelementptr inbounds i64, ptr %ptr, i64 1
  %v1 = load i32, ptr %ptr, align 4
  %gep = getelementptr inbounds i8, ptr %ptr, i64 4
  %v2 = load i24, ptr %gep, align 4
  br label %loop

exit:
  ret void
}

Asserts:

opt: /home/npopov/repos/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:2919: llvm::Value* llvm::InnerLoopVectorizer::createBitOrPointerCast(llvm::Value*, llvm::VectorType*, const llvm::DataLayout&): Assertion `(DL.getTypeSizeInBits(SrcElemTy) == DL.getTypeSizeInBits(DstElemTy)) && "Vector elements must have same size"' failed.
[...]
 #8 0x000000000610034b llvm::InnerLoopVectorizer::createBitOrPointerCast(llvm::Value*, llvm::VectorType*, llvm::DataLayout const&) (build/bin/opt+0x610034b)
 #9 0x000000000611a2ec llvm::InnerLoopVectorizer::vectorizeInterleaveGroup(llvm::InterleaveGroup<llvm::Instruction> const*, llvm::ArrayRef<llvm::VPValue*>, llvm::VPTransformState&, llvm::VPValue*, llvm::ArrayRef<llvm::VPValue*>, llvm::VPValue*) (build/bin/opt+0x611a2ec)
#10 0x000000000611a7a6 llvm::VPInterleaveRecipe::execute(llvm::VPTransformState&) (build/bin/opt+0x611a7a6)
#11 0x000000000620ca79 llvm::VPBasicBlock::execute(llvm::VPTransformState*) (build/bin/opt+0x620ca79)
#12 0x0000000006208c4f llvm::VPRegionBlock::execute(llvm::VPTransformState*) (build/bin/opt+0x6208c4f)
#13 0x000000000620b13d llvm::VPlan::execute(llvm::VPTransformState*) (build/bin/opt+0x620b13d)
#14 0x000000000613f247 llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool) (build/bin/opt+0x613f247)
#15 0x000000000615087f llvm::LoopVectorizePass::processLoop(llvm::Loop*) (build/bin/opt+0x615087f)
#16 0x000000000615161d llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo&, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AAResults&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) (build/bin/opt+0x615161d)
#17 0x0000000006151d6b llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (build/bin/opt+0x6151d6b)
#18 0x0000000006241eed llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) PassBuilder.cpp:0:0
#19 0x00000000036dcc2c llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) AMDGPUTargetMachine.cpp:0:0
#20 0x00000000055d9a17 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (build/bin/opt+0x55d9a17)

cc @fhahn

@nikic
Copy link
Contributor Author

nikic commented Nov 7, 2022

Presumably we're missing a check for matching type sizes somewhere, but I'm not really clear on where ... possibly somewhere in InterleavedAccessInfo?

@fhahn
Copy link
Contributor

fhahn commented Nov 7, 2022

yeah, let me take a look

@nikic
Copy link
Contributor Author

nikic commented Nov 13, 2022

/cherry-pick 758699c

@nikic nikic moved this from Needs Fix to Needs Pull Request in LLVM Release Status Nov 13, 2022
@llvmbot
Copy link
Member

llvmbot commented Nov 13, 2022

/branch llvm/llvm-project-release-prs/issue58722

@llvmbot
Copy link
Member

llvmbot commented Nov 13, 2022

/pull-request llvm/llvm-project-release-prs#215

@nikic nikic moved this from Needs Pull Request to Needs Review in LLVM Release Status Nov 13, 2022
tstellar pushed a commit that referenced this issue Nov 15, 2022
Currently, codegen doesn't support cases where the type size doesn't
match the alloc size. Skip them for now.

Fixes #58722.

(cherry picked from commit 758699c)
@tstellar tstellar moved this from Needs Review to Done in LLVM Release Status Nov 16, 2022
fhahn added a commit to fhahn/llvm-project that referenced this issue Dec 6, 2022
Currently, codegen doesn't support cases where the type size doesn't
match the alloc size. Skip them for now.

Fixes llvm#58722.

(cherry picked from commit 758699c)
fhahn added a commit to fhahn/llvm-project that referenced this issue Dec 6, 2022
Currently, codegen doesn't support cases where the type size doesn't
match the alloc size. Skip them for now.

Fixes llvm#58722.

(cherry picked from commit 758699c)
fhahn added a commit to swiftlang/llvm-project that referenced this issue Dec 6, 2022
Currently, codegen doesn't support cases where the type size doesn't
match the alloc size. Skip them for now.

Fixes llvm#58722.

(cherry picked from commit 758699c)
fhahn added a commit to swiftlang/llvm-project that referenced this issue Dec 6, 2022
Currently, codegen doesn't support cases where the type size doesn't
match the alloc size. Skip them for now.

Fixes llvm#58722.

(cherry picked from commit 758699c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] release:backport release:merged vectorizers
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants