[PATCH] D79475: [SVE] Fix getAlignmentInfo for scalable vectors

David Sherwood via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 6 02:39:41 PDT 2020


david-arm created this revision.
david-arm added reviewers: kmclaughlin, sdesmalen, ctetreau.
Herald added subscribers: llvm-commits, psnobl, rkruppe, hiraditya, kristof.beyls, tschuett.
Herald added a reviewer: rengolin.
Herald added a reviewer: efriedma.
Herald added a project: LLVM.

When calculating the natural alignment for scalable vectors it
is acceptable to calculate an allocation size based on the minimum
number of elements in the vector.

This code path is exercised by an existing test:

  CodeGen/AArch64/sve-intrinsics-int-arith.ll


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79475

Files:
  llvm/lib/IR/DataLayout.cpp


Index: llvm/lib/IR/DataLayout.cpp
===================================================================
--- llvm/lib/IR/DataLayout.cpp
+++ llvm/lib/IR/DataLayout.cpp
@@ -559,7 +559,10 @@
     // with what clang and llvm-gcc do.
     unsigned Alignment =
         getTypeAllocSize(cast<VectorType>(Ty)->getElementType());
-    Alignment *= cast<VectorType>(Ty)->getNumElements();
+    // We're only calculating a natural alignment, so it doesn't have to be
+    // based on the full size for scalable vectors. Using the minimum element
+    // count should be enough here.
+    Alignment *= cast<VectorType>(Ty)->getElementCount().Min;
     Alignment = PowerOf2Ceil(Alignment);
     return Align(Alignment);
    }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79475.262318.patch
Type: text/x-patch
Size: 711 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200506/45a46a1b/attachment.bin>


More information about the llvm-commits mailing list