[PATCH] D79524: [SVE] Fix incorrect usage of getNumElements() in InstCombineCalls

Christopher Tetreault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 6 15:20:02 PDT 2020


ctetreau created this revision.
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.
ctetreau added reviewers: sdesmalen, c-rhodes, david-arm.
ctetreau added a comment.

This test case also hits the call to getNumElements() at IR/Function.cpp:1184. However, there is an open diff D79416 <https://reviews.llvm.org/D79416> for this call site so I've left it unresolved in this patch.


Remove incorrect usage of getNumElements() from visitCallInst(). The
number of elements was being used to construct a DemandedElts bitfield.
This operation does not make sense for scalable vectors. Cast to
FixedVectorType

Identified by test case Clang :: CodeGen/aarch64-sve-intrinsics/acle_sve_mla.c


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79524

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp


Index: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1942,9 +1942,10 @@
     if (Changed) return II;
   }
 
-  // For vector result intrinsics, use the generic demanded vector support.
-  if (auto *IIVTy = dyn_cast<VectorType>(II->getType())) {
-    auto VWidth = IIVTy->getNumElements();
+  // For fixed width vector result intrinsics, use the generic demanded vector
+  // support.
+  if (auto *IIFVTy = dyn_cast<FixedVectorType>(II->getType())) {
+    auto VWidth = IIFVTy->getNumElements();
     APInt UndefElts(VWidth, 0);
     APInt AllOnesEltMask(APInt::getAllOnesValue(VWidth));
     if (Value *V = SimplifyDemandedVectorElts(II, AllOnesEltMask, UndefElts)) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79524.262486.patch
Type: text/x-patch
Size: 861 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200506/e441e104/attachment.bin>


More information about the llvm-commits mailing list