[all-commits] [llvm/llvm-project] 8bea51: [X86] Fold AND(Y, XOR(X, SUB(0, X))) to ANDN(Y, BL...

Marius Kamp via All-commits all-commits at lists.llvm.org
Tue Feb 25 09:11:23 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8bea51103000e4ac752ecd8ed1550c1c9d105a6b
      https://github.com/llvm/llvm-project/commit/8bea51103000e4ac752ecd8ed1550c1c9d105a6b
  Author: Marius Kamp <msk at posteo.org>
  Date:   2025-02-25 (Tue, 25 Feb 2025)

  Changed paths:
    M llvm/lib/Target/X86/X86ISelLowering.cpp
    A llvm/test/CodeGen/X86/andnot-blsmsk.ll

  Log Message:
  -----------
  [X86] Fold AND(Y, XOR(X, SUB(0, X))) to ANDN(Y, BLSMSK(X)) (#128348)

XOR(X, SUB(0, X)) corresponds to a bitwise-negated BLSMSK instruction
(i.e., x ^ (x - 1)). On its own, this transformation is probably not
really profitable but when the XOR operation is an operand of an AND
operation, we can use an ANDN instruction to reduce the number of
emitted instructions by one.
    
Fixes #103501.



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