[PATCH] D76260: [ValueTracking][SVE] Fix isGEPKnownNonNull for scalable vector.

Huihui Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 16 16:57:37 PDT 2020


huihuiz created this revision.
huihuiz added reviewers: sdesmalen, efriedma, apazos, reames.
huihuiz added a project: LLVM.
Herald added subscribers: psnobl, rkruppe, hiraditya, tschuett.
huihuiz updated this revision to Diff 250655.
huihuiz added a comment.

minor update test name


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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76260

Files:
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/test/Transforms/InstSimplify/vscale.ll


Index: llvm/test/Transforms/InstSimplify/vscale.ll
===================================================================
--- llvm/test/Transforms/InstSimplify/vscale.ll
+++ llvm/test/Transforms/InstSimplify/vscale.ll
@@ -133,3 +133,13 @@
   %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: @gep13(
+; 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
+}
Index: llvm/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/lib/Analysis/ValueTracking.cpp
+++ llvm/lib/Analysis/ValueTracking.cpp
@@ -2084,7 +2084,7 @@
     }
 
     // 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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76260.250655.patch
Type: text/x-patch
Size: 1207 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200316/a66cc009/attachment.bin>


More information about the llvm-commits mailing list