[all-commits] [llvm/llvm-project] be2723: [InstSimplify] Fold icmp of `X and/or C1` and `X a...

Yingwei Zheng via All-commits all-commits at lists.llvm.org
Mon Sep 18 06:33:03 PDT 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: be2723da5c5f2d7f7c3351813b749c0fcf631451
  Author: Yingwei Zheng <dtcxzyw2333 at gmail.com>
  Date:   2023-09-18 (Mon, 18 Sep 2023)

  Changed paths:
    M llvm/lib/Analysis/InstructionSimplify.cpp
    M llvm/test/Transforms/InstSimplify/compare.ll
    M llvm/test/Transforms/InstSimplify/maxmin_intrinsics.ll

  Log Message:
  [InstSimplify] Fold icmp of `X and/or C1` and `X and/or C2` into constant (#65905)

This patch simplifies the pattern `icmp X and/or C1, X and/or C2` when
one constant mask is the subset of the other.
If `C1 & C2 == C1`, `A = X and/or C1`, `B = X and/or C2`, we can do the
following folds:
`icmp ule A, B -> true`
`icmp ugt A, B -> false`
We can apply similar folds for signed predicates when `C1` and `C2` are
the same sign:
`icmp sle A, B -> true`
`icmp sgt A, B -> false`

Alive2: https://alive2.llvm.org/ce/z/Q4ekP5
Fixes #65833.

More information about the All-commits mailing list