[PATCH] D76655: [InstSimplify][SVE] Minor fix SimplifyGEPInst for scalable vector.
Huihui Zhang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 14 15:45:52 PDT 2020
huihuiz updated this revision to Diff 257524.
huihuiz edited the summary of this revision.
huihuiz added a comment.
My initial thought was wrong.
Spent sometime look again, we are nearly impossible to generate incorrect result without the code fixes in this patch.
But comparing a scalable size with a fixed size still doesn't make sense.
E.g., We are comparing scalable type size %offset to a fixed size 'IdxWidth' returned by DataLayout::getIndexSizeInBits
define <vscale x 1 x i8*> @gep(i8* %a, <vscale x 1 x i32> %offset) {
%v = getelementptr i8, i8* %a, <vscale x 1 x i32> %offset
ret <vscale x 1 x i8*> %v
}
Please help take a look, let me know what you think?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76655/new/
https://reviews.llvm.org/D76655
Files:
llvm/lib/Analysis/InstructionSimplify.cpp
Index: llvm/lib/Analysis/InstructionSimplify.cpp
===================================================================
--- llvm/lib/Analysis/InstructionSimplify.cpp
+++ llvm/lib/Analysis/InstructionSimplify.cpp
@@ -4094,7 +4094,7 @@
if (!IsScalableVec && Ty->isSized()) {
Value *P;
uint64_t C;
- uint64_t TyAllocSize = Q.DL.getTypeAllocSize(Ty);
+ uint64_t TyAllocSize = Q.DL.getTypeAllocSize(Ty).getFixedSize();
// getelementptr P, N -> P if P points to a type of zero size.
if (TyAllocSize == 0 && Ops[0]->getType() == GEPTy)
return Ops[0];
@@ -4139,12 +4139,15 @@
}
}
- if (!IsScalableVec && Q.DL.getTypeAllocSize(LastType) == 1 &&
+ if (!IsScalableVec && Q.DL.getTypeAllocSize(LastType).getFixedSize() == 1 &&
all_of(Ops.slice(1).drop_back(1),
[](Value *Idx) { return match(Idx, m_Zero()); })) {
unsigned IdxWidth =
Q.DL.getIndexSizeInBits(Ops[0]->getType()->getPointerAddressSpace());
- if (Q.DL.getTypeSizeInBits(Ops.back()->getType()) == IdxWidth) {
+ // Skip if offset type size is not a compile-time constant.
+ TypeSize OffsetTypeSize = Q.DL.getTypeSizeInBits(Ops.back()->getType());
+ if (!OffsetTypeSize.isScalable() &&
+ OffsetTypeSize.getFixedSize() == IdxWidth) {
APInt BasePtrOffset(IdxWidth, 0);
Value *StrippedBasePtr =
Ops[0]->stripAndAccumulateInBoundsConstantOffsets(Q.DL,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76655.257524.patch
Type: text/x-patch
Size: 1435 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200414/7876a3e1/attachment.bin>
More information about the llvm-commits
mailing list