[llvm] [FuncSpec] Handle ssa_copy intrinsic calls in InstCostVisitor (PR #114247)
Hari Limaye via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 31 04:00:24 PDT 2024
================
@@ -0,0 +1,79 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --include-generated-funcs --version 5
+; RUN: opt -passes="ipsccp<func-spec>" -funcspec-min-function-size=1 \
+; RUN: -funcspec-for-literal-constant=true \
+; RUN: -funcspec-min-codesize-savings=50 \
+; RUN: -funcspec-min-latency-savings=0 \
+; RUN: -S < %s | FileCheck %s
+
+; Verify that we are able to estimate the codesize savings by looking through
+; calls to ssa_copy intrinsics, which are inserted by PredicateInfo when IPSCCP
----------------
hazzlim wrote:
The ssa.copy intrinsics are added during IPSCCP when it invokes PredicateInfo:
https://github.com/llvm/llvm-project/blob/22081dc40ba8b13e70df71bb7350126658e8cc70/llvm/lib/Transforms/IPO/SCCP.cpp#L130
I think that this test is a reasonable test case, as its a realistic-ish example of where the intrinsics would be added. Additionally, we cannot insert them ourselves into the test IR - the SCCPSolver asserts() that it has PredicateInfo available for every ssa.copy call in the IR of a function (i.e. it expects that all ssa.copy intrinsics were added by the call to `addPredicateInfo`:
https://github.com/llvm/llvm-project/blob/d924a9ba03a05b417676e84f6c81aac44f907f71/llvm/lib/Transforms/Utils/SCCPSolver.cpp#L1852-L1855
I'm not sure that there's another way to test this, even in a unit-test - unless you have any ideas?
https://github.com/llvm/llvm-project/pull/114247
More information about the llvm-commits
mailing list