[PATCH] D75892: [InstSimplify][SVE] Fix SimplifyGEPInst for scalable vector.
Huihui Zhang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 9 22:38:44 PDT 2020
huihuiz created this revision.
huihuiz added reviewers: sdesmalen, efriedma, spatel, apazos.
huihuiz added a project: LLVM.
Herald added subscribers: psnobl, rkruppe, hiraditya, tschuett.
huihuiz added a comment.
take test.ll, run: opt -S -instsimplify test.ll -o -
define <vscale x 4 x <vscale x 4 x i32>*> @getelementptr_2() {
%ptr = getelementptr <vscale x 4 x i32>, <vscale x 4 x i32>* null, <vscale x 4 x i64> undef
ret <vscale x 4 x <vscale x 4 x i32>*> %ptr
}
current upstream crash at: llvm/include/llvm/Support/TypeSize.h:126: uint64_t llvm::TypeSize::getFixedSize() const: Assertion `!IsScalable && "Request for a fixed size on a scalable object"' failed.
This patch depends on D74386 <https://reviews.llvm.org/D74386>, otherwise we get another crash at: llvm/lib/IR/Value.cpp:408: void llvm::Value::doRAUW(llvm::Value *, llvm::Value::ReplaceMetadataUses): Assertion `New->getType() == getType() && "replaceAllUses of value with new value of different type!"' failed.
Skip folds that rely on DataLayout::getTypeAllocSize(). For scalable
vector, only minimal type alloc size is known at compile-time.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D75892
Files:
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstSimplify/vscale.ll
Index: llvm/test/Transforms/InstSimplify/vscale.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/InstSimplify/vscale.ll
@@ -0,0 +1,23 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -instsimplify -verify < %s | FileCheck %s
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Memory Access and Addressing Operations
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+define <vscale x 4 x i32*> @getelementptr_1() {
+; CHECK-LABEL: @getelementptr_1(
+; CHECK-NEXT: ret <vscale x 4 x i32*> zeroinitializer
+;
+ %ptr = getelementptr i32, <vscale x 4 x i32*> zeroinitializer, <vscale x 4 x i64> undef
+ ret <vscale x 4 x i32*> %ptr
+}
+
+define <vscale x 4 x <vscale x 4 x i32>*> @getelementptr_2() {
+; CHECK-LABEL: @getelementptr_2(
+; CHECK-NEXT: ret <vscale x 4 x <vscale x 4 x i32>*> zeroinitializer
+;
+ %ptr = getelementptr <vscale x 4 x i32>, <vscale x 4 x i32>* null, <vscale x 4 x i64> undef
+ ret <vscale x 4 x <vscale x 4 x i32>*> %ptr
+}
+
Index: llvm/lib/Analysis/InstructionSimplify.cpp
===================================================================
--- llvm/lib/Analysis/InstructionSimplify.cpp
+++ llvm/lib/Analysis/InstructionSimplify.cpp
@@ -4081,13 +4081,16 @@
if (isa<UndefValue>(Ops[0]))
return UndefValue::get(GEPTy);
+ bool IsScalableVec =
+ SrcTy->isVectorTy() ? SrcTy->getVectorIsScalable() : false;
+
if (Ops.size() == 2) {
// getelementptr P, 0 -> P.
if (match(Ops[1], m_Zero()) && Ops[0]->getType() == GEPTy)
return Ops[0];
Type *Ty = SrcTy;
- if (Ty->isSized()) {
+ if (!IsScalableVec && Ty->isSized()) {
Value *P;
uint64_t C;
uint64_t TyAllocSize = Q.DL.getTypeAllocSize(Ty);
@@ -4135,7 +4138,7 @@
}
}
- if (Q.DL.getTypeAllocSize(LastType) == 1 &&
+ if (!IsScalableVec && Q.DL.getTypeAllocSize(LastType) == 1 &&
all_of(Ops.slice(1).drop_back(1),
[](Value *Idx) { return match(Idx, m_Zero()); })) {
unsigned IdxWidth =
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75892.249276.patch
Type: text/x-patch
Size: 2144 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200310/8779c769/attachment.bin>
More information about the llvm-commits
mailing list