[PATCH] D74424: [ConstantFold][SVE] Fix constant fold for FoldReinterpretLoadFromConstPtr.

Huihui Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 11 10:42:08 PST 2020


huihuiz created this revision.
huihuiz added reviewers: sdesmalen, efriedma, apazos, huntergr, willlovett.
huihuiz added a project: LLVM.
Herald added subscribers: psnobl, rkruppe, hiraditya, tschuett.
huihuiz added a comment.

Current upstream crash with : include/llvm/Support/TypeSize.h:126: uint64_t llvm::TypeSize::getFixedSize() const: Assertion `!IsScalable && "Request for a fixed size on a scalable object"' failed.

test.ll

  define <vscale x 2 x double> @load() {
    %r = load <vscale x 2 x double>, <vscale x 2 x double>* getelementptr (<vscale x 2 x double>, <vscale x 2 x double>* null, i64 1)
    ret <vscale x 2 x double> %r
  }

run: opt -S -constprop test.ll -o -


Do not try to fold scalable vector load as an int32/64 load. Size of scalable
vector can not be determined at compile-time.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74424

Files:
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/test/Analysis/ConstantFolding/vscale.ll


Index: llvm/test/Analysis/ConstantFolding/vscale.ll
===================================================================
--- llvm/test/Analysis/ConstantFolding/vscale.ll
+++ llvm/test/Analysis/ConstantFolding/vscale.ll
@@ -185,6 +185,20 @@
   %i2 = shufflevector <vscale x 4 x i32> %i, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
   ret <vscale x 4 x i32> %i2
 }
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Memory Access and Addressing Operations
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+define <vscale x 2 x double> @load() {
+; CHECK-LABEL: @load(
+; CHECK-NEXT:    [[R:%.*]] = load <vscale x 2 x double>, <vscale x 2 x double>* getelementptr (<vscale x 2 x double>, <vscale x 2 x double>* null, i64 1)
+; CHECK-NEXT:    ret <vscale x 2 x double> [[R]]
+;
+  %r = load <vscale x 2 x double>, <vscale x 2 x double>* getelementptr (<vscale x 2 x double>, <vscale x 2 x double>* null, i64 1)
+  ret <vscale x 2 x double> %r
+}
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Conversion Operations
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Index: llvm/lib/Analysis/ConstantFolding.cpp
===================================================================
--- llvm/lib/Analysis/ConstantFolding.cpp
+++ llvm/lib/Analysis/ConstantFolding.cpp
@@ -519,7 +519,7 @@
       MapTy = Type::getInt32Ty(C->getContext());
     else if (LoadTy->isDoubleTy())
       MapTy = Type::getInt64Ty(C->getContext());
-    else if (LoadTy->isVectorTy()) {
+    else if (LoadTy->isVectorTy() && !LoadTy->getVectorIsScalable()) {
       MapTy = PointerType::getIntNTy(C->getContext(),
                                      DL.getTypeSizeInBits(LoadTy));
     } else


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74424.243914.patch
Type: text/x-patch
Size: 1821 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200211/1b671fd1/attachment.bin>


More information about the llvm-commits mailing list