[PATCH] D114155: [LoopAccessAnalysis][SVE] Bail out for scalable vectors

Peter Waller via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 18 05:34:47 PST 2021


peterwaller-arm created this revision.
peterwaller-arm added reviewers: efriedma, paulwalker-arm, sdesmalen, david-arm, bsmith, MattDevereau.
Herald added subscribers: psnobl, hiraditya, tschuett.
peterwaller-arm requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The supplied test case, reduced from real world code, crashes with a
'Invalid size request on a scalable vector.' error.

Since it's similar in spirit to an existing LAA test, rename the file to
generalize it to both.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114155

Files:
  llvm/lib/Analysis/LoopAccessAnalysis.cpp
  llvm/test/Analysis/LoopAccessAnalysis/gep-induction-operand-typesize-warning.ll
  llvm/test/Analysis/LoopAccessAnalysis/scalable-vector-regression-tests.ll


Index: llvm/test/Analysis/LoopAccessAnalysis/scalable-vector-regression-tests.ll
===================================================================
--- /dev/null
+++ llvm/test/Analysis/LoopAccessAnalysis/scalable-vector-regression-tests.ll
@@ -0,0 +1,35 @@
+; RUN: opt -loop-load-elim -mtriple=aarch64 -mattr=+sve < %s
+
+; Regression tests verifying "assumption that TypeSize is not scalable" and "Invalid size request on a scalable vector." are not produced by -load-loop-elim.
+
+define void @regression_test_get_gep_induction_operand_typesize_warning(i64 %n, <vscale x 4 x i32>* %a) {
+entry:
+  br label %loop.body
+
+loop.body:
+  %0 = phi i64 [ 0, %entry ], [ %1, %loop.body ]
+  %idx = getelementptr <vscale x 4 x i32>, <vscale x 4 x i32>* %a, i64 %0
+  store <vscale x 4 x i32> zeroinitializer, <vscale x 4 x i32>* %idx
+  %1 = add i64 %0, 1
+  %2 = icmp eq i64 %1, %n
+  br i1 %2, label %loop.end, label %loop.body
+
+loop.end:
+  ret void
+}
+
+define i1 @regression_test_scalable_loop_access_typesize() {
+  br i1 false, label %2, label %1
+1:
+  ret i1 false
+2:
+  %3 = phi i8* [ %6, %2 ], [ null, %0 ]
+  %4 = bitcast i8* %3 to <vscale x 16 x i8>*
+  %5 = load <vscale x 16 x i8>, <vscale x 16 x i8>* %4, align 16
+  store <vscale x 16 x i8> zeroinitializer, <vscale x 16 x i8>* %4, align 16
+  %6 = getelementptr inbounds i8, i8* %3, i64 1
+  br i1 true, label %1, label %2
+}
+
+declare <vscale x 16 x i8> @llvm.masked.load.nxv16i8.p0nxv16i8(<vscale x 16 x i8>*, i32 immarg, <vscale x 16 x i1>, <vscale x 16 x i8>)
+declare void @llvm.masked.store.nxv16i8.p0nxv16i8(<vscale x 16 x i8>, <vscale x 16 x i8>*, i32 immarg, <vscale x 16 x i1>)
Index: llvm/test/Analysis/LoopAccessAnalysis/gep-induction-operand-typesize-warning.ll
===================================================================
--- llvm/test/Analysis/LoopAccessAnalysis/gep-induction-operand-typesize-warning.ll
+++ /dev/null
@@ -1,21 +0,0 @@
-; RUN: opt -loop-load-elim -mtriple=aarch64--linux-gnu -mattr=+sve < %s
-
-; This regression test is verifying that a GEP instruction performed on a
-; scalable vector does not produce a 'assumption that TypeSize is not scalable'
-; warning in the llvm::getGEPInductionOperand function.
-
-define void @get_gep_induction_operand_typesize_warning(i64 %n, <vscale x 4 x i32>* %a) {
-entry:
-  br label %loop.body
-
-loop.body:
-  %0 = phi i64 [ 0, %entry ], [ %1, %loop.body ]
-  %idx = getelementptr <vscale x 4 x i32>, <vscale x 4 x i32>* %a, i64 %0
-  store <vscale x 4 x i32> zeroinitializer, <vscale x 4 x i32>* %idx
-  %1 = add i64 %0, 1
-  %2 = icmp eq i64 %1, %n
-  br i1 %2, label %loop.end, label %loop.body
-
-loop.end:
-  ret void
-}
Index: llvm/lib/Analysis/LoopAccessAnalysis.cpp
===================================================================
--- llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -1101,7 +1101,12 @@
   }
 
   auto &DL = Lp->getHeader()->getModule()->getDataLayout();
-  int64_t Size = DL.getTypeAllocSize(AccessTy);
+  TypeSize AllocSize = DL.getTypeAllocSize(AccessTy);
+  if (AllocSize.isScalable()) {
+    // Scalable types not yet supported - give up.
+    return 0;
+  }
+  int64_t Size = AllocSize.getFixedSize();
   const APInt &APStepVal = C->getAPInt();
 
   // Huge step value - give up.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114155.388168.patch
Type: text/x-patch
Size: 3300 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211118/0588f2bf/attachment.bin>


More information about the llvm-commits mailing list