[PATCH] D87139: [SVE][CodeGen] Fix InlineFunction for scalable vectors

David Sherwood via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 11 00:35:13 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG1e1770a07ec0: [SVE][CodeGen] Fix InlineFunction for scalable vectors (authored by david-arm).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87139/new/

https://reviews.llvm.org/D87139

Files:
  llvm/lib/Transforms/Utils/InlineFunction.cpp
  llvm/test/Transforms/Inline/AArch64/sve-alloca-merge.ll


Index: llvm/test/Transforms/Inline/AArch64/sve-alloca-merge.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/Inline/AArch64/sve-alloca-merge.ll
@@ -0,0 +1,29 @@
+; RUN: opt -mtriple=aarch64--linux-gnu -mattr=+sve < %s -inline -S | FileCheck %s
+
+define void @bar(<vscale x 2 x i64>* %a) {
+entry:
+  %b = alloca <vscale x 2 x i64>, align 16
+  store <vscale x 2 x i64> zeroinitializer, <vscale x 2 x i64>* %b, align 16
+  %c = load <vscale x 2 x i64>, <vscale x 2 x i64>* %a, align 16
+  %d = load <vscale x 2 x i64>, <vscale x 2 x i64>* %b, align 16
+  %e = add <vscale x 2 x i64> %c, %d
+  %f = add <vscale x 2 x i64> %e, %c
+  store <vscale x 2 x i64> %f, <vscale x 2 x i64>* %a, align 16
+  ret void
+}
+
+define i64 @foo() {
+; CHECK-LABEL: @foo(
+; CHECK: %0 = bitcast <vscale x 2 x i64>* %{{.*}} to i8*
+; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %0)
+; CHECK: %1 = bitcast <vscale x 2 x i64>* %{{.*}} to i8*
+; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %1)
+entry:
+  %a = alloca <vscale x 2 x i64>, align 16
+  store <vscale x 2 x i64> zeroinitializer, <vscale x 2 x i64>* %a, align 16
+  %a1 = bitcast <vscale x 2 x i64>* %a to i64*
+  store i64 1, i64* %a1, align 8
+  call void @bar(<vscale x 2 x i64>* %a)
+  %el = load i64, i64* %a1
+  ret i64 %el
+}
Index: llvm/lib/Transforms/Utils/InlineFunction.cpp
===================================================================
--- llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -2061,7 +2061,7 @@
           dyn_cast<ConstantInt>(AI->getArraySize())) {
         auto &DL = Caller->getParent()->getDataLayout();
         Type *AllocaType = AI->getAllocatedType();
-        uint64_t AllocaTypeSize = DL.getTypeAllocSize(AllocaType);
+        TypeSize AllocaTypeSize = DL.getTypeAllocSize(AllocaType);
         uint64_t AllocaArraySize = AIArraySize->getLimitedValue();
 
         // Don't add markers for zero-sized allocas.
@@ -2070,9 +2070,10 @@
 
         // Check that array size doesn't saturate uint64_t and doesn't
         // overflow when it's multiplied by type size.
-        if (AllocaArraySize != std::numeric_limits<uint64_t>::max() &&
+        if (!AllocaTypeSize.isScalable() &&
+            AllocaArraySize != std::numeric_limits<uint64_t>::max() &&
             std::numeric_limits<uint64_t>::max() / AllocaArraySize >=
-                AllocaTypeSize) {
+                AllocaTypeSize.getFixedSize()) {
           AllocaSize = ConstantInt::get(Type::getInt64Ty(AI->getContext()),
                                         AllocaArraySize * AllocaTypeSize);
         }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87139.291148.patch
Type: text/x-patch
Size: 2690 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200911/bcd18095/attachment.bin>


More information about the llvm-commits mailing list