[all-commits] [llvm/llvm-project] 949bbd: [InstCombine] Fold Minimum over Trailing/Leading B...

mskamp via All-commits all-commits at lists.llvm.org
Sat Jul 13 07:55:34 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 949bbdc923ce336942a506a125fb28dfdf662c3a
      https://github.com/llvm/llvm-project/commit/949bbdc923ce336942a506a125fb28dfdf662c3a
  Author: mskamp <marius.kamp at fau.de>
  Date:   2024-07-13 (Sat, 13 Jul 2024)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
    A llvm/test/Transforms/InstCombine/umin_cttz_ctlz.ll

  Log Message:
  -----------
  [InstCombine] Fold Minimum over Trailing/Leading Bits Counts (#90402)

The new transformation folds `umin(cttz(x), c)` to `cttz(x | (1 << c))`
and `umin(ctlz(x), c)` to `ctlz(x | ((1 << (bitwidth - 1)) >> c))`. The
transformation is only implemented for constant `c` to not increase the
number of instructions.
    
The idea of the transformation is to set the c-th lowest (for `cttz`) or
highest (for `ctlz`) bit in the operand. In this way, the `cttz` or
`ctlz` instruction always returns at most `c`.
    
Alive2 proofs: https://alive2.llvm.org/ce/z/y8Hdb8

Fixes #90000



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