[all-commits] [llvm/llvm-project] 6c8381: [ConstraintElim] Add facts for SREM. (#213453)

Florian Hahn via All-commits all-commits at lists.llvm.org
Sun Aug 2 02:42:50 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6c838170ac5d612902dcf9858aed2f26a7fbd8e2
      https://github.com/llvm/llvm-project/commit/6c838170ac5d612902dcf9858aed2f26a7fbd8e2
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2026-08-02 (Sun, 02 Aug 2026)

  Changed paths:
    M llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
    M llvm/test/Transforms/ConstraintElimination/ne-tightening.ll
    M llvm/test/Transforms/ConstraintElimination/srem.ll

  Log Message:
  -----------
  [ConstraintElim] Add facts for SREM. (#213453)

Add facts for SRem, if operands are known to be non-negative.

Add signed bounds for `srem x, n`:

  * `x s>= 0`  =>  result s>= 0  and  result s<= x
  * `n s>  0`  =>  result s<=  n

Alive2 Proofs: https://alive2.llvm.org/ce/z/e-zoAP

Compile-time is in the noise

https://llvm-compile-time-tracker.com/compare.php?from=60f965b1f62c0c77bcdb2997ea9bb6603aa0d002&to=ebc652af5700d569884e27812d33735d604990a1&stat=instructions:u

InstCombine already has a similar fold, but with more limited reasoning.
It does not trigger any changes on
https://github.com/dtcxzyw/llvm-opt-benchmark-nightly/pull/841

It simplifies a few times on other C/C++ workloads, including ffmpeg and
OpenColorIO.

Extracted end-to-end examples simplified with the change:
https://clang.godbolt.org/z/1co6rvjKs

This is part of an effort to improve ConstraintElimination support for
IR generated by the Swift compiler, where such patterns are more common
due to a number of signed runtime checks.

PR: https://github.com/llvm/llvm-project/pull/213453



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