[all-commits] [llvm/llvm-project] 1eed46: [AArch64] Eliminate Common Subexpression of CSEL b...

Marius Kamp via All-commits all-commits at lists.llvm.org
Sat Jan 11 08:26:33 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1eed46960c217f9480865702f06fb730c7521e61
      https://github.com/llvm/llvm-project/commit/1eed46960c217f9480865702f06fb730c7521e61
  Author: Marius Kamp <msk at posteo.org>
  Date:   2025-01-11 (Sat, 11 Jan 2025)

  Changed paths:
    M llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
    A llvm/test/CodeGen/AArch64/csel-cmp-cse.ll

  Log Message:
  -----------
  [AArch64] Eliminate Common Subexpression of CSEL by Reassociation (#121350)

If we have a CSEL instruction that depends on the flags set by a
(SUBS x c) instruction and the true and/or false expression is
(add (add x y) -c), we can reassociate the latter expression to
(add (SUBS x c) y) and save one instruction.

Proof for the basic transformation: https://alive2.llvm.org/ce/z/-337Pb

We can extend this transformation for slightly different constants. For
example, if we have (add (add x y) -(c-1)) and a the comparison x <u c,
we can transform the comparison to x <=u c-1 to eliminate the comparison
instruction, too. Similarly, we can transform (x == 0) to (x <u 1).

Proofs for the transformations that alter the constants:
https://alive2.llvm.org/ce/z/3nVqgR

Fixes #119606.



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