1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 12:12:47 +01:00

[InstCombine] GEPOperator::accumulateConstantOffset does not support scalable vectors

Avoid transforming:

 %0 = bitcast i8* %base to <vscale x 16 x i8>*
 %1 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %0, i64 1

into:

 %0 = getelementptr i8, i8* %base, i64 16
 %1 = bitcast i8* %0 to <vscale x 16 x i8>*

Reviewers: efriedma, ctetreau

Reviewed By: efriedma

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D76236
This commit is contained in:
Sander de Smalen 2020-03-18 12:46:42 +00:00
parent 3b659043e4
commit 11d1f1de44
2 changed files with 26 additions and 0 deletions

View File

@ -45,6 +45,11 @@ bool GEPOperator::accumulateConstantOffset(const DataLayout &DL,
if (OpC->isZero())
continue;
// Scalable vectors have are multiplied by a runtime constant.
if (auto *VecTy = dyn_cast<VectorType>(GTI.getIndexedType()))
if (VecTy->isScalable())
return false;
// Handle a struct index, which adds its field offset to the pointer.
if (StructType *STy = GTI.getStructTypeOrNull()) {
unsigned ElementIdx = OpC->getZExtValue();

View File

@ -134,3 +134,24 @@ define i32 addrspace(3)* @inbounds_bitcast_vec_to_array_addrspace_matching_alloc
%gep = getelementptr inbounds [4 x i32], [4 x i32] addrspace(3)* %asc, i64 %y, i64 %z
ret i32 addrspace(3)* %gep
}
; Negative test - avoid doing bitcast on i8*, because '16' should be scaled by 'vscale'.
define i8* @test_accumulate_constant_offset_vscale_nonzero(<vscale x 16 x i1> %pg, i8* %base) {
; CHECK-LABEL: @test_accumulate_constant_offset_vscale_nonzero
; CHECK-NEXT: %bc = bitcast i8* %base to <vscale x 16 x i8>*
; CHECK-NEXT: %gep = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %bc, i64 1, i64 4
; CHECK-NEXT: ret i8* %gep
%bc = bitcast i8* %base to <vscale x 16 x i8>*
%gep = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %bc, i64 1, i64 4
ret i8* %gep
}
define i8* @test_accumulate_constant_offset_vscale_zero(<vscale x 16 x i1> %pg, i8* %base) {
; CHECK-LABEL: @test_accumulate_constant_offset_vscale_zero
; CHECK-NEXT: %[[RES:.*]] = getelementptr i8, i8* %base, i64 4
; CHECK-NEXT: ret i8* %[[RES]]
%bc = bitcast i8* %base to <vscale x 16 x i8>*
%gep = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %bc, i64 0, i64 4
ret i8* %gep
}