[PATCH] D49162: [Inliner] Teach inliner to merge 'min-legal-vector-width' function attribute
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 24 10:28:28 PDT 2018
craig.topper updated this revision to Diff 157074.
craig.topper added a comment.
Improve comment.
As I mentioned on IRC always_inline doesn't go through inline cost analysis including attribute compatibility checking. So this patch is the minimum necessary to make intrinsics propagate their vector width to the function they get inlined into.
https://reviews.llvm.org/D49162
Files:
include/llvm/IR/Attributes.td
lib/IR/Attributes.cpp
Index: lib/IR/Attributes.cpp
===================================================================
--- lib/IR/Attributes.cpp
+++ lib/IR/Attributes.cpp
@@ -1682,6 +1682,33 @@
}
}
+/// If the inlined function defines a min legal vector width, then ensure
+/// the calling function has the same or larger min legal vector width. This
+/// function is called after the inlining decision has been made so we have to
+/// merge the attribute this way. Heuristics that would use
+/// min-legal-vector-width to determine inline compatibility would need to be
+/// handled as part of inline cost analysis.
+static void
+adjustMinLegalVectorWidth(Function &Caller, const Function &Callee) {
+ if (Callee.hasFnAttribute("min-legal-vector-width")) {
+ uint64_t CalleeVectorWidth;
+ Callee.getFnAttribute("min-legal-vector-width")
+ .getValueAsString()
+ .getAsInteger(0, CalleeVectorWidth);
+ if (Caller.hasFnAttribute("min-legal-vector-width")) {
+ uint64_t CallerVectorWidth;
+ Caller.getFnAttribute("min-legal-vector-width")
+ .getValueAsString()
+ .getAsInteger(0, CallerVectorWidth);
+ if (CallerVectorWidth < CalleeVectorWidth) {
+ Caller.addFnAttr(Callee.getFnAttribute("min-legal-vector-width"));
+ }
+ } else {
+ Caller.addFnAttr(Callee.getFnAttribute("min-legal-vector-width"));
+ }
+ }
+}
+
#define GET_ATTR_COMPAT_FUNC
#include "AttributesCompatFunc.inc"
Index: include/llvm/IR/Attributes.td
===================================================================
--- include/llvm/IR/Attributes.td
+++ include/llvm/IR/Attributes.td
@@ -235,3 +235,4 @@
def : MergeRule<"adjustCallerSSPLevel">;
def : MergeRule<"adjustCallerStackProbes">;
def : MergeRule<"adjustCallerStackProbeSize">;
+def : MergeRule<"adjustMinLegalVectorWidth">;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49162.157074.patch
Type: text/x-patch
Size: 1827 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180724/5d172c17/attachment.bin>
More information about the llvm-commits
mailing list