[PATCH] D90146: [SVE] Fix TypeSize warning in llvm::getGEPInductionOperand
Joe Ellis via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 26 04:36:11 PDT 2020
joechrisellis created this revision.
joechrisellis added reviewers: fpetrogalli, peterwaller-arm, DavidTruby.
Herald added subscribers: llvm-commits, psnobl, hiraditya, tschuett.
Herald added a reviewer: efriedma.
Herald added a project: LLVM.
joechrisellis requested review of this revision.
We do not need to use the implicit cast here. We can instead can rely on
a comparison between two TypeSize objects instead. This algorithm will
work fine with scalable vectors.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D90146
Files:
llvm/lib/Analysis/VectorUtils.cpp
llvm/test/Analysis/LoopAccessAnalysis/gep-induction-operand-typesize-warning.ll
Index: llvm/test/Analysis/LoopAccessAnalysis/gep-induction-operand-typesize-warning.ll
===================================================================
--- /dev/null
+++ llvm/test/Analysis/LoopAccessAnalysis/gep-induction-operand-typesize-warning.ll
@@ -0,0 +1,25 @@
+; RUN: opt -loop-load-elim -mtriple=aarch64--linux-gnu -mattr=+sve < %s 2>%t
+; RUN: FileCheck --check-prefix=WARN --allow-empty %s < %t
+
+; This regression test is verifying that a GEP instruction performed on a
+; scalable vector does not produce a 'assumption that TypeSize is not scalable'
+; warning in the llvm::getGEPInductionOperand function.
+
+; If this check fails please read test/CodeGen/AArch64/README for instructions on how to resolve it.
+; WARN-NOT: warning: {{.*}}TypeSize is not scalable
+
+define void @get_gep_induction_operand_typesize_warning(i64 %n, <vscale x 4 x i32>* %a) {
+entry:
+ br label %loop.body
+
+loop.body:
+ %0 = phi i64 [ 0, %entry ], [ %1, %loop.body ]
+ %idx = getelementptr <vscale x 4 x i32>, <vscale x 4 x i32>* %a, i64 %0
+ store <vscale x 4 x i32> zeroinitializer, <vscale x 4 x i32>* %idx
+ %1 = add i64 %0, 1
+ %2 = icmp eq i64 %1, %n
+ br i1 %2, label %loop.end, label %loop.body
+
+loop.end:
+ ret void
+}
Index: llvm/lib/Analysis/VectorUtils.cpp
===================================================================
--- llvm/lib/Analysis/VectorUtils.cpp
+++ llvm/lib/Analysis/VectorUtils.cpp
@@ -136,7 +136,7 @@
unsigned llvm::getGEPInductionOperand(const GetElementPtrInst *Gep) {
const DataLayout &DL = Gep->getModule()->getDataLayout();
unsigned LastOperand = Gep->getNumOperands() - 1;
- unsigned GEPAllocSize = DL.getTypeAllocSize(Gep->getResultElementType());
+ TypeSize GEPAllocSize = DL.getTypeAllocSize(Gep->getResultElementType());
// Walk backwards and try to peel off zeros.
while (LastOperand > 1 && match(Gep->getOperand(LastOperand), m_Zero())) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90146.300637.patch
Type: text/x-patch
Size: 1909 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201026/4284b800/attachment.bin>
More information about the llvm-commits
mailing list