[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 17:23:09 PST 2020
huihuiz updated this revision to Diff 244039.
huihuiz marked an inline comment as done.
huihuiz added a comment.
Thanks Sander for the review!
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74424/new/
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
@@ -501,6 +501,10 @@
Constant *FoldReinterpretLoadFromConstPtr(Constant *C, Type *LoadTy,
const DataLayout &DL) {
+ // Bail out early. Not expect to load from scalable global variable.
+ if (LoadTy->isVectorTy() && LoadTy->getVectorIsScalable())
+ return nullptr;
+
auto *PTy = cast<PointerType>(C->getType());
auto *IntType = dyn_cast<IntegerType>(LoadTy);
@@ -520,8 +524,8 @@
else if (LoadTy->isDoubleTy())
MapTy = Type::getInt64Ty(C->getContext());
else if (LoadTy->isVectorTy()) {
- MapTy = PointerType::getIntNTy(C->getContext(),
- DL.getTypeSizeInBits(LoadTy));
+ MapTy = PointerType::getIntNTy(
+ C->getContext(), DL.getTypeSizeInBits(LoadTy).getFixedSize());
} else
return nullptr;
@@ -561,7 +565,8 @@
return nullptr;
int64_t Offset = OffsetAI.getSExtValue();
- int64_t InitializerSize = DL.getTypeAllocSize(GV->getInitializer()->getType());
+ int64_t InitializerSize =
+ DL.getTypeAllocSize(GV->getInitializer()->getType()).getFixedSize();
// If we're not accessing anything in this constant, the result is undefined.
if (Offset <= -1 * static_cast<int64_t>(BytesLoaded))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74424.244039.patch
Type: text/x-patch
Size: 2670 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200212/0483d820/attachment.bin>
More information about the llvm-commits
mailing list