[PATCH] D90171: [SVE] Fix TypeSize warning in RuntimePointerChecking::insert

Joe Ellis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 26 10:24:20 PDT 2020


joechrisellis created this revision.
joechrisellis added reviewers: peterwaller-arm, DavidTruby, fpetrogalli.
Herald added subscribers: llvm-commits, psnobl, hiraditya, tschuett.
Herald added a reviewer: efriedma.
Herald added a project: LLVM.
joechrisellis requested review of this revision.

The TypeSize warning would occur because RuntimePointerChecking::insert
was not scalable vector aware. The fix is to use
ScalarEvolution::getSizeOfExpr to grab the size of types.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90171

Files:
  llvm/lib/Analysis/LoopAccessAnalysis.cpp
  llvm/test/Analysis/LoopAccessAnalysis/runtime-pointer-checking-insert-typesize.ll


Index: llvm/test/Analysis/LoopAccessAnalysis/runtime-pointer-checking-insert-typesize.ll
===================================================================
--- /dev/null
+++ llvm/test/Analysis/LoopAccessAnalysis/runtime-pointer-checking-insert-typesize.ll
@@ -0,0 +1,27 @@
+; RUN: opt -loop-load-elim -mtriple=aarch64-linux-gnu -mattr=+sve < %s >/dev/null 2>%t
+; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t
+
+; This regression test is defending against a TypeSize warning 'assumption that
+; TypeSize is not scalable'. This warning cropped up in
+; RuntimePointerChecking::insert when performing loop load elimination because
+; this function was previously unaware of scalable types.
+
+; If this check fails please read test/CodeGen/AArch64/README for instructions on how to resolve it.
+; WARN-NOT: warning: {{.*}}TypeSize is not scalable
+
+define void @runtime_pointer_checking_insert_typesize(<vscale x 4 x i32>* %a,
+                                                      <vscale x 4 x i32>* %b) {
+entry:
+  br label %loop.body
+loop.body:
+  %0 = phi i64 [ 0, %entry ], [%1, %loop.body]
+  %idx_a = getelementptr <vscale x 4 x i32>, <vscale x 4 x i32>* %a, i64 %0
+  %idx_b = getelementptr <vscale x 4 x i32>, <vscale x 4 x i32>* %b, i64 %0
+  %tmp = load <vscale x 4 x i32>, <vscale x 4 x i32>* %idx_a
+  store <vscale x 4 x i32> %tmp, <vscale x 4 x i32>* %idx_b
+  %1 = add i64 %0, 2
+  %2 = icmp eq i64 %1, 1024
+  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
@@ -228,9 +228,9 @@
     }
     // Add the size of the pointed element to ScEnd.
     auto &DL = Lp->getHeader()->getModule()->getDataLayout();
-    unsigned EltSize =
-        DL.getTypeStoreSizeInBits(Ptr->getType()->getPointerElementType()) / 8;
-    const SCEV *EltSizeSCEV = SE->getConstant(ScEnd->getType(), EltSize);
+    Type *IntIdxTy = DL.getIndexType(Ptr->getType());
+    const SCEV *EltSizeSCEV =
+        SE->getSizeOfExpr(IntIdxTy, Ptr->getType()->getPointerElementType());
     ScEnd = SE->getAddExpr(ScEnd, EltSizeSCEV);
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90171.300718.patch
Type: text/x-patch
Size: 2262 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201026/a8b8c9cd/attachment.bin>


More information about the llvm-commits mailing list