[PATCH] D76655: [InstSimplify][SVE] Minor fix SimplifyGEPInst for scalable vector.

Huihui Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 23 17:26:47 PDT 2020


huihuiz created this revision.
huihuiz added reviewers: sdesmalen, efriedma, apazos.
huihuiz added a project: LLVM.
Herald added subscribers: psnobl, rkruppe, hiraditya, tschuett.

When checking if getelementptr is handling scalable vector or not. Check
SrcTy is not enough, also need to check for all operands.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76655

Files:
  llvm/lib/Analysis/InstructionSimplify.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
@@ -143,3 +143,12 @@
   %cmp = icmp eq <vscale x 16 x i8>* %x, null
   ret i1 %cmp
 }
+
+define <vscale x 16 x i8*> @getelementptr_src_ty_not_vscale(<vscale x 16 x i8*> %a, <vscale x 16 x i64> %offset) {
+; CHECK-LABEL: @getelementptr_src_ty_not_vscale(
+; CHECK-NEXT:    [[V:%.*]] = getelementptr i8, <vscale x 16 x i8*> [[A:%.*]], <vscale x 16 x i64> [[OFFSET:%.*]]
+; CHECK-NEXT:    ret <vscale x 16 x i8*> [[V]]
+;
+  %v = getelementptr i8, <vscale x 16 x i8*> %a, <vscale x 16 x i64> %offset
+  ret <vscale x 16 x i8*> %v
+}
Index: llvm/lib/Analysis/InstructionSimplify.cpp
===================================================================
--- llvm/lib/Analysis/InstructionSimplify.cpp
+++ llvm/lib/Analysis/InstructionSimplify.cpp
@@ -4080,8 +4080,15 @@
   if (isa<UndefValue>(Ops[0]))
     return UndefValue::get(GEPTy);
 
-  bool IsScalableVec =
-      SrcTy->isVectorTy() ? SrcTy->getVectorIsScalable() : false;
+  bool IsScalableVec = false;
+  if (SrcTy->isVectorTy() && SrcTy->getVectorIsScalable())
+    IsScalableVec = true;
+  else
+    for (auto Op : Ops)
+      if (Op->getType()->isVectorTy() && Op->getType()->getVectorIsScalable()) {
+        IsScalableVec = true;
+        break;
+      }
 
   if (Ops.size() == 2) {
     // getelementptr P, 0 -> P.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76655.252181.patch
Type: text/x-patch
Size: 1488 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200324/235ed207/attachment.bin>


More information about the llvm-commits mailing list