Skip to content

Conversation

@zyw-bot
Copy link
Collaborator

@zyw-bot zyw-bot commented Sep 10, 2025

Link: llvm/llvm-project#157865
Requested by: @XChy

@github-actions github-actions bot mentioned this pull request Sep 10, 2025
@zyw-bot
Copy link
Collaborator Author

zyw-bot commented Sep 10, 2025

Diff mode

runner: ariselab-64c-docker
baseline: llvm/llvm-project@b7e31e7
patch: llvm/llvm-project#157865
sha256: f53a051156046b61bdc722f6935c5e1b938d7edad4e4578b862dc6dd803b93f5
commit: 8007070

3 files changed, 5 insertions(+), 5 deletions(-)

Improvements:
Regressions:
  instcombine.NumCombined 125678718 -> 125657478 -0.02%
  correlated-value-propagation.NumNNeg 99658 -> 99656 -0.00%

4 4 bench/abseil-cpp/optimized/crc.ll
1 1 bench/rocksdb/optimized/xxhash.ll

@github-actions
Copy link
Contributor

The patch introduces a single, consistent change across multiple LLVM IR files: the addition of the nneg (non-negative) attribute to zext (zero-extend) instructions.

Summary of Changes:

  1. Addition of nneg flag to zext operations:
    In several locations across crc.ll (Abseil CRC implementation) and xxhash.ll (RocksDB XXH3 hash implementation), zext i32 %value to i64 is updated to zext nneg i32 %value to i64. This indicates that the input value is guaranteed to be non-negative, allowing the optimizer to make stronger assumptions about the value range.

  2. Multiple instances in loop exit blocks:
    In crc.ll, four instances of this change occur in different preheader blocks (_exit.preheader, exit62.preheader, etc.), all involving values derived from an OR operation with 1 (or disjoint ..., 1). Since the input %i is OR’d with 1, it ensures the result is at least 1 (i.e., positive), justifying the nneg property.

  3. One instance in XXH3 hash computation:
    In xxhash.ll, one zext is similarly updated in the ROCKSDB_XXH3_128bits function. The extended value (%101) comes from a bitwise XOR but is used in a context where its non-negativity can be proven, enabling the nneg annotation.

  4. Optimization-enabling semantic hint:
    The nneg attribute does not change runtime behavior but informs LLVM’s optimizer that the extended value is ≥0. This can improve optimization outcomes, such as eliminating redundant checks or enabling better constant propagation and range analysis.

  5. Pattern consistency across benchmarks:
    The changes reflect a broader pattern of inserting range-knowledge attributes into performance-critical hashing code, likely resulting from profile-guided optimization or manual IR refinement to expose optimization opportunities.

These modifications are low-level, correctness-preserving annotations that enhance optimization potential by expressing known value properties. They do not alter control flow or data computation but help the backend generate more efficient machine code.

model: qwen-plus-latest
CompletionUsage(completion_tokens=474, prompt_tokens=1260, total_tokens=1734, completion_tokens_details=None, prompt_tokens_details=None)

@dtcxzyw dtcxzyw closed this Sep 10, 2025
@dtcxzyw dtcxzyw deleted the test-run17616829732 branch September 10, 2025 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants