[all-commits] [llvm/llvm-project] 73a351: [llvm][GVN] Propagate `trunc nuw to i1` equalities...

Yash Solanki via All-commits all-commits at lists.llvm.org
Sun Jun 8 09:58:37 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 73a351e7d42c1da46a915c7edb7e6697a9dea640
      https://github.com/llvm/llvm-project/commit/73a351e7d42c1da46a915c7edb7e6697a9dea640
  Author: Yash Solanki <67216443+yashnator at users.noreply.github.com>
  Date:   2025-06-08 (Sun, 08 Jun 2025)

  Changed paths:
    M llvm/lib/Transforms/Scalar/GVN.cpp
    A llvm/test/Transforms/GVN/trunc-nuw-equality.ll

  Log Message:
  -----------
  [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



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