aboutsummaryrefslogtreecommitdiff
path: root/polly
diff options
context:
space:
mode:
authorNick Desaulniers <ndesaulniers@google.com>2021-10-08 15:17:54 -0700
committerTom Stellard <tstellar@redhat.com>2022-01-11 21:12:29 -0800
commit52a400d8e4c46876fae5d732c92df254a9ceae8f (patch)
tree4f754a965d0a04ea3ebe4192df45789f045eb7fb /polly
parenteaeb7dcf32495155b5d430d2a650a211c9b230af (diff)
downloadllvm-52a400d8e4c46876fae5d732c92df254a9ceae8f.zip
llvm-52a400d8e4c46876fae5d732c92df254a9ceae8f.tar.gz
llvm-52a400d8e4c46876fae5d732c92df254a9ceae8f.tar.bz2
[InlineCost] model calls to llvm.is.constant* more carefully
llvm.is.constant* intrinsics are evaluated to 0 or 1 integral values. A common use case for llvm.is.constant comes from the higher level __builtin_constant_p. A common usage pattern of __builtin_constant_p in the Linux kernel is: void foo (int bar) { if (__builtin_constant_p(bar)) { // lots of code that will fold away to a constant. } else { // a little bit of code, usually a libcall. } } A minor issue in InlineCost calculations is when `bar` is _not_ Constant and still will not be after inlining, we don't discount the true branch and the inline cost of `foo` ends up being the cost of both branches together, rather than just the false branch. This leads to code like the above where inlining will not help prove bar Constant, but it still would be beneficial to inline foo, because the "true" branch is irrelevant from a cost perspective. For example, IPSCCP can sink a passed constant argument to foo: const int x = 42; void bar (void) { foo(x); } This improves our inlining decisions, and fixes a few head scratching cases were the disassembly shows a relatively small `foo` not inlined into a lone caller. We could further improve this modeling by tracking whether the argument to llvm.is.constant* is a parameter of the function, and if inlining would allow that parameter to become Constant. This idea is noted in a FIXME comment. Link: https://github.com/ClangBuiltLinux/linux/issues/1302 Reviewed By: kazu Differential Revision: https://reviews.llvm.org/D111272 (cherry picked from commit 9697f93587f46300814f1c6c68af347441d6e05d)
Diffstat (limited to 'polly')
0 files changed, 0 insertions, 0 deletions