aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.h
diff options
context:
space:
mode:
authorTobias Stadler <mail@stadler-tobias.de>2025-06-24 14:15:27 +0100
committerGitHub <noreply@github.com>2025-06-24 14:15:27 +0100
commit9186df9b088f425182c58c7eee23645a77d7591c (patch)
treea1c70494539b8563b8256281697b1af0c7032ddc /clang/lib/CodeGen/CodeGenModule.h
parente04c938cc08a90ae60440ce22d072ebc69d67ee8 (diff)
downloadllvm-9186df9b088f425182c58c7eee23645a77d7591c.zip
llvm-9186df9b088f425182c58c7eee23645a77d7591c.tar.gz
llvm-9186df9b088f425182c58c7eee23645a77d7591c.tar.bz2
[InlineCost] Simplify extractvalue across callsite (#145054)
Motivation: When using libc++, `std::bitset<64>::count()` doesn't optimize to a single popcount instruction on AArch64, because we fail to inline the library code completely. Inlining fails, because the internal bit_iterator struct is passed as a [2 x i64] %arg value on AArch64. The value is built using insertvalue instructions and only one of the array entries is constant. If we know that this entry is constant, we can prove that half the function becomes dead. However, InlineCost only considers operands for simplification if they are Constants, which %arg is not. Without this simplification the function is too expensive to inline. Therefore, we had to teach InlineCost to support non-Constant simplified values (PR #145083). Now, we enable this for extractvalue, because we want to simplify the extractvalue with the insertvalues from the caller function. This is enough to get bitset::count fully optimized. There are similar opportunities we can explore for BinOps in the future (e.g. cmp eq %arg1, %arg2 when the caller passes the same value into both arguments), but we need to be careful here, because InstSimplify isn't completely safe to use with operands owned by different functions.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.h')
0 files changed, 0 insertions, 0 deletions