[PATCH] D127567: [CostModel] Fix the invalid cost for scalable vectors intrinsics
Allen zhong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 11 05:53:12 PDT 2022
Allen created this revision.
Allen added reviewers: sdesmalen, david-arm, dmgreen.
Herald added a subscriber: hiraditya.
Herald added a project: All.
Allen requested review of this revision.
Herald added subscribers: llvm-commits, alextsao1999.
Herald added a project: LLVM.
With the commit D97470 <https://reviews.llvm.org/D97470>, the cost of scalable vectors intrinsics may be invalid,
so make it expensive to avoid crash.
https://reviews.llvm.org/D127567
Files:
llvm/lib/Analysis/CodeMetrics.cpp
llvm/test/Analysis/CostModel/AArch64/intrinsic-cost-crash.ll
Index: llvm/test/Analysis/CostModel/AArch64/intrinsic-cost-crash.ll
===================================================================
--- /dev/null
+++ llvm/test/Analysis/CostModel/AArch64/intrinsic-cost-crash.ll
@@ -0,0 +1,14 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -disable-output -S -mtriple=aarch64--linux-gnu -mattr=+sve -O3 < %s 2>&1 | FileCheck %s
+
+define void @nodef_intrinsic() {
+entry:
+ br label %vector.body
+
+vector.body:
+ %next = call <vscale x 2 x i1> @llvm.nodef.nxv2i1(<vscale x 2 x i1> zeroinitializer)
+ br label %vector.body
+}
+
+declare <vscale x 2 x i1> @llvm.nodef.nxv2i1(<vscale x 2 x i1>)
+
Index: llvm/lib/Analysis/CodeMetrics.cpp
===================================================================
--- llvm/lib/Analysis/CodeMetrics.cpp
+++ llvm/lib/Analysis/CodeMetrics.cpp
@@ -175,8 +175,10 @@
if (const InvokeInst *InvI = dyn_cast<InvokeInst>(&I))
if (InvI->cannotDuplicate())
notDuplicatable = true;
-
- NumInsts += TTI.getUserCost(&I, TargetTransformInfo::TCK_CodeSize);
+ InstructionCost NumInstsProxy =
+ TTI.getUserCost(&I, TargetTransformInfo::TCK_CodeSize);
+ // Make it expensive if it is Invalid.
+ NumInsts += NumInstsProxy.isValid() ? *NumInstsProxy.getValue() : 10;
}
if (isa<ReturnInst>(BB->getTerminator()))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127567.436131.patch
Type: text/x-patch
Size: 1361 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220611/99919742/attachment.bin>
More information about the llvm-commits
mailing list