[llvm] [ValueTracking] Compute known bits of and/or recurrences from start and step (PR #226164)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 24 06:37:32 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
@llvm/pr-subscribers-backend-amdgpu
Author: Konstantin Bogdanov (thevar1able)
<details>
<summary>Changes</summary>
For simple phi recurrences of the form `%iv = %iv op %step` we currently only derive trailing zero bits for and/or, in a case shared with add/sub/mul. This moves and/or into their own case and propagates full known bits:
* or: bits that are zero in both the start value and the step stay zero, and bits that are one in the start value stay one.
* and: bits that are zero in the start value stay zero, and bits that are one in both the start value and the step stay one.
The step only applies from the second iteration on, so every fact must also hold for the start value alone. This subsumes the trailing-zeros rule for these operations. The nsw handling of the add/sub/mul case never applied to them.
The two AMDGPU tests are adjusted to use an opaque start value for their recurrences, so that the improved known bits don't fold away the patterns they were written to test.
The first commit precommits the InstCombine tests.
Split out of #<!-- -->222334. This overlaps with #<!-- -->225775.
---
Full diff: https://github.com/llvm/llvm-project/pull/226164.diff
4 Files Affected:
- (modified) llvm/lib/Analysis/ValueTracking.cpp (+22-2)
- (modified) llvm/test/CodeGen/AMDGPU/GlobalISel/is-safe-to-sink-bug.ll (+10-11)
- (modified) llvm/test/CodeGen/AMDGPU/absdiff.ll (+2-3)
- (modified) llvm/test/Transforms/InstCombine/recurrence.ll (+166)
``````````diff
The server is unavailable at this time. Please wait a few minutes before you try again.
``````````
</details>
https://github.com/llvm/llvm-project/pull/226164
More information about the llvm-commits
mailing list