[all-commits] [llvm/llvm-project] 922faf: [GlobalISel] Micro-optimize getConstantVRegValWith...

Pierre van Houtryve via All-commits all-commits at lists.llvm.org
Mon May 13 23:26:23 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 922fafaff83319e33e8a890a692df073d3ce55c9
      https://github.com/llvm/llvm-project/commit/922fafaff83319e33e8a890a692df073d3ce55c9
  Author: Pierre van Houtryve <pierre.vanhoutryve at amd.com>
  Date:   2024-05-14 (Tue, 14 May 2024)

  Changed paths:
    M llvm/lib/CodeGen/GlobalISel/Utils.cpp

  Log Message:
  -----------
  [GlobalISel] Micro-optimize getConstantVRegValWithLookThrough (#91969)

I was benchmarking the MatchTable when I found that
`getConstantVRegValWithLookThrough` took a non-negligible amount of
time, about 7.5% of all of
`AArch64PreLegalizerCombinerImpl::tryCombineAll`.

I decided to take a closer look to see if I could squeeze some
performance out of it, and I landed on a few changes that:
- Avoid copying APint unnecessarily, especially returning
std::optional<APInt> can be expensive when a out parameter also works.
- Avoid indirect call by using templated function pointers instead of
function_ref/std::function

Both of those changes seem to speedup this function by about 50%, but my
benchmarking (`perf record`) seems inconsistent (so take measurements
with a grain of salt), I saw as high as 4.5% and as low as 2% for this
function on the exact same input after the changes, but it never got
close again to 7% in a few runs so this looks like a stable improvement.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list