Yash Solanki 73a351e7d4
[llvm][GVN] Propagate trunc nuw to i1 equalities (#143273)
This patch adds to GVN's `propagateEquality()` to reason about equality
constraints through `trunc nuw iN to i1`.

Given:
  %tr = trunc nuw iN %v to i1

We can deduce that if `%tr == true`, then `%v == 1`, and if `%tr ==
false`, then `%v == 0`. This is valid because `nuw` guarantees that
truncation didn't lose unsigned bits, so `%v` must have been either 0 or
1.

The patch adds logic to propagate this information via the GVN worklist.
This enables further simplification opportunities downstream, such as
folding redundant stores or conditionals that depend on `%v`.

Includes a test case in `GVN/trunc-nuw-equality.ll`.

Resolves #142744
2025-06-08 18:58:16 +02:00
..
2023-06-27 16:53:50 -07:00
2023-06-09 15:41:32 +01:00
2023-06-30 15:52:40 +01:00