[all-commits] [llvm/llvm-project] 51fc70: [InstCombine] Fold comparisons of x & -x with 0 an...

Hadong Lee via All-commits all-commits at lists.llvm.org
Sat Aug 8 11:11:34 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 51fc70599559b2f04bef0d7adc47ecf16343b44c
      https://github.com/llvm/llvm-project/commit/51fc70599559b2f04bef0d7adc47ecf16343b44c
  Author: Hadong Lee <hdchris765 at snu.ac.kr>
  Date:   2026-08-08 (Sat, 08 Aug 2026)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
    M llvm/test/Transforms/InstCombine/and-or-icmps.ll
    M llvm/test/Transforms/InstCombine/ctpop-pow2.ll
    A llvm/test/Transforms/InstCombine/icmp-lowbit.ll

  Log Message:
  -----------
  [InstCombine] Fold comparisons of x & -x with 0 and 1 (#213709)

This folds equality comparisons of `x & -x` with zero and one:

- `(x & -x) == 0` to `x == 0`
- `(x & -x) != 0` to `x != 0`
- `(x & -x) == 1` to `trunc x to i1`
- `(x & -x) != 1` to `!(trunc x to i1)`

The fold supports scalar, fixed-vector, and scalable-vector integer
types wider than `i1`. The `!= 1` fold is limited
to one-use `and` instructions to avoid increasing the instruction count.

Alive2: https://alive2.llvm.org/ce/z/Zwy2hW

Fixes #213708



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