[all-commits] [llvm/llvm-project] 4a7175: [AggressiveInstCombine] Support alternate deBruijn...

Craig Topper via All-commits all-commits at lists.llvm.org
Fri Jul 10 12:56:10 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4a717571c2d313c6cf3a54b3d3da1fe52cbe5453
      https://github.com/llvm/llvm-project/commit/4a717571c2d313c6cf3a54b3d3da1fe52cbe5453
  Author: Craig Topper <craig.topper at sifive.com>
  Date:   2026-07-10 (Fri, 10 Jul 2026)

  Changed paths:
    M llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
    M llvm/test/Transforms/AggressiveInstCombine/X86/lower-table-based-log2-basics.ll

  Log Message:
  -----------
  [AggressiveInstCombine] Support alternate deBruijn log2 table that isolates the MSB before the multiply. (#208532)

The existing deBruijn log2 match expects the multiply input to be a mask
that has all bits below the most significant set bit to be 1.

There is an alternate form in some programs where this mask is modified
to isolate the MSB by doing (mask - (mask >> 1)). A cttz table is then
used instead of a log2 table.

This patch teaches tryToRecognizeTableBasedLog2 to match this form too.

I think there's still some additional work needed elsewhere to recognize
that the sub+select in the output can be done with not+and.

Fixes #207571

Assisted-by: Claude



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