[llvm] 1bf0c99 - [ValueTracking][SVE] Fix isGEPKnownNonNull for scalable vector.
Huihui Zhang via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 17 11:31:47 PDT 2020
Author: Huihui Zhang
Date: 2020-03-17T11:31:30-07:00
New Revision: 1bf0c9937583c344639f4c255cfed8478deecdb4
URL: https://github.com/llvm/llvm-project/commit/1bf0c9937583c344639f4c255cfed8478deecdb4
DIFF: https://github.com/llvm/llvm-project/commit/1bf0c9937583c344639f4c255cfed8478deecdb4.diff
LOG: [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
Added:
Modified:
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Transforms/InstSimplify/vscale.ll
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 1a2253050152..d4f4e6e06ab6 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -2084,7 +2084,7 @@ static bool isGEPKnownNonNull(const GEPOperator *GEP, unsigned Depth,
}
// If we have a zero-sized type, the index doesn't matter. Keep looping.
- if (Q.DL.getTypeAllocSize(GTI.getIndexedType()) == 0)
+ if (Q.DL.getTypeAllocSize(GTI.getIndexedType()).getKnownMinSize() == 0)
continue;
// Fast path the constant operand case both for efficiency and so we don't
diff --git a/llvm/test/Transforms/InstSimplify/vscale.ll b/llvm/test/Transforms/InstSimplify/vscale.ll
index d112128042c2..608a093a40aa 100644
--- a/llvm/test/Transforms/InstSimplify/vscale.ll
+++ b/llvm/test/Transforms/InstSimplify/vscale.ll
@@ -133,3 +133,13 @@ define <vscale x 4 x i32>* @getelementptr_not_constant_foldable(i64 %x) {
%ptr = getelementptr <vscale x 4 x i32>, <vscale x 4 x i32>* null, i64 %x
ret <vscale x 4 x i32>* %ptr
}
+
+; Check GEP's result is known to be non-null.
+define i1 @getelementptr_check_non_null(<vscale x 16 x i8>* %ptr) {
+; CHECK-LABEL: @getelementptr_check_non_null(
+; CHECK-NEXT: ret i1 false
+;
+ %x = getelementptr inbounds <vscale x 16 x i8>, <vscale x 16 x i8>* %ptr, i32 1
+ %cmp = icmp eq <vscale x 16 x i8>* %x, null
+ ret i1 %cmp
+}
More information about the llvm-commits
mailing list