Skip to content

Commit 1bf0c99

Browse files
committed
[ValueTracking][SVE] Fix isGEPKnownNonNull for scalable vector.
Summary: DataLayout::getTypeAllocSize() return TypeSize. For cases where the scalable property doesn't matter, we should explicitly call getKnownMinSize() to avoid implicit type conversion to uint64_t, which is not valid for scalable vector type. Reviewers: sdesmalen, efriedma, apazos, reames Reviewed By: efriedma Subscribers: tschuett, hiraditya, rkruppe, psnobl, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D76260
1 parent b6bcf72 commit 1bf0c99

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2084,7 +2084,7 @@ static bool isGEPKnownNonNull(const GEPOperator *GEP, unsigned Depth,
20842084
}
20852085

20862086
// If we have a zero-sized type, the index doesn't matter. Keep looping.
2087-
if (Q.DL.getTypeAllocSize(GTI.getIndexedType()) == 0)
2087+
if (Q.DL.getTypeAllocSize(GTI.getIndexedType()).getKnownMinSize() == 0)
20882088
continue;
20892089

20902090
// Fast path the constant operand case both for efficiency and so we don't

llvm/test/Transforms/InstSimplify/vscale.ll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,13 @@ define <vscale x 4 x i32>* @getelementptr_not_constant_foldable(i64 %x) {
133133
%ptr = getelementptr <vscale x 4 x i32>, <vscale x 4 x i32>* null, i64 %x
134134
ret <vscale x 4 x i32>* %ptr
135135
}
136+
137+
; Check GEP's result is known to be non-null.
138+
define i1 @getelementptr_check_non_null(<vscale x 16 x i8>* %ptr) {
139+
; CHECK-LABEL: @getelementptr_check_non_null(
140+
; CHECK-NEXT: ret i1 false
141+
;
142+
%x = getelementptr inbounds <vscale x 16 x i8>, <vscale x 16 x i8>* %ptr, i32 1
143+
%cmp = icmp eq <vscale x 16 x i8>* %x, null
144+
ret i1 %cmp
145+
}

0 commit comments

Comments
 (0)