llvm-project
73a351e7 - [llvm][GVN] Propagate `trunc nuw to i1` equalities (#143273)

Commit
93 days ago
[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
Author
Parents
Loading