Skip to content

Commit

Permalink
Allow CodeGen_LLVM::codegen_buffer_pointer to support vectors. (#7049)
Browse files Browse the repository at this point in the history
This is useful for scatter/gather in the vector predication intrinsics work.
  • Loading branch information
Zalman Stern authored Sep 26, 2022
1 parent a817414 commit 59353ab
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/CodeGen_LLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1881,7 +1881,13 @@ Value *CodeGen_LLVM::codegen_buffer_pointer(Value *base_address, Halide::Type ty
// Promote index to 64-bit on targets that use 64-bit pointers.
llvm::DataLayout d(module.get());
if (d.getPointerSize() == 8) {
index = builder->CreateIntCast(index, i64_t, true);
llvm::Type *index_type = index->getType();
llvm::Type *desired_index_type = i64_t;
if (isa<VectorType>(index_type)) {
desired_index_type = VectorType::get(desired_index_type,
dyn_cast<VectorType>(index_type)->getElementCount());
}
index = builder->CreateIntCast(index, desired_index_type, true);
}

return CreateInBoundsGEP(builder, load_type, base_address, index);
Expand Down

0 comments on commit 59353ab

Please sign in to comment.