Skip to content

Conversation

@zyw-bot
Copy link
Collaborator

@zyw-bot zyw-bot commented Oct 11, 2025

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

zyw-bot commented Oct 11, 2025

Diff mode

runner: ariselab-64c-docker
baseline: llvm/llvm-project@6a0e5b2
patch: llvm/llvm-project@main...fhahn:llvm-project:scev-guards-div-first
sha256: 86ce7170094634a6504e669b21761f49dee1bc947828686e002d8dc70d83daee
commit: 6d0c523

3 files changed, 665 insertions(+), 749 deletions(-)

Improvements:
Regressions:
  globalopt.NumDeleted 1056554 -> 1056553 -0.00%
  instcombine.NumCombined 121263712 -> 121263711 -0.00%

-4 duckdb/ub_duckdb_storage_compression.ll

@github-actions
Copy link
Contributor

The patch modifies a loop in the TemplatedValidityMask::GetValidityEntry function in LLVM IR, specifically improving control flow and eliminating unnecessary operations. The key changes are:

  1. Removal of redundant @llvm.umax.i64 intrinsic: The call to @llvm.umax.i64(%11, 1) is deleted. This was previously used to ensure a minimum value of 1 for loop iteration bounds, but the change shows this clamping is no longer necessary.

  2. Simplification of loop exit condition: The exit condition %exitcond57.not.i = icmp eq i64 %14, %umax.i is replaced with a direct comparison against %11: %exitcond57.not.i = icmp eq i64 %14, %11. This removes dependence on the now-eliminated umax.i, simplifying the logic.

  3. Merge of predecessor blocks into .preheader block: The .preheader block now has two predecessors: %_ZNK6duckdb21TemplatedValidityMaskImE16GetValidityEntryEm.exit.lr.ph.i and %.loopexit.us.i. This indicates a structural change where the loop has been transformed (likely loop versioning or unswitching), allowing the .preheader to directly merge control flow without an intermediate block.

  4. Updated PHI nodes in .preheader: The PHI nodes %.01544.us.i and %.03043.us.i now take their initial values directly from %_ZNK6duckdb21TemplatedValidityMaskImE16GetValidityEntryEm.exit.lr.ph.i instead of going through a separate preheader that computed umax. This streamlines initialization.

  5. Elimination of the .us.preheader block: The block _ZNK6...exit.us.preheader.i is removed as a dedicated entry point and folded into the main loop structure, reducing control-flow overhead.

Overall, the transformation simplifies the loop by removing redundant maximum computation, tightening the control flow, and reducing the number of basic blocks and phi nodes. This likely results from improved loop optimization, such as better loop unswitching or dead code elimination, leading to more efficient and cleaner IR.

model: qwen-plus-latest
CompletionUsage(completion_tokens=483, prompt_tokens=1170, total_tokens=1653, completion_tokens_details=None, prompt_tokens_details=None)

fhahn added a commit to fhahn/llvm-project that referenced this pull request Oct 11, 2025
At the moment, the effectivness of guards that contain divisibility
information (A % B == 0 ) depends on the order of the conditions.

This patch makes using divisibility information independent of the
order, by collecting and applying the divisibility information
separately.

We first collect all conditions in a vector, then collect the
divisibility information from all guards.

When processing other guards, we apply divisibility info collected
earlier.

After all guards have been processed, we add the divisibility info,
rewriting the existing rewrite. This ensures we apply the divisibility
info to the largest rewrite expression.

This helps to improve results in a few cases, one in
dtcxzyw/llvm-opt-benchmark#2921 and another one
in a different large C/C++ based IR corpus.
fhahn added a commit to fhahn/llvm-project that referenced this pull request Oct 14, 2025
At the moment, the effectivness of guards that contain divisibility
information (A % B == 0 ) depends on the order of the conditions.

This patch makes using divisibility information independent of the
order, by collecting and applying the divisibility information
separately.

We first collect all conditions in a vector, then collect the
divisibility information from all guards.

When processing other guards, we apply divisibility info collected
earlier.

After all guards have been processed, we add the divisibility info,
rewriting the existing rewrite. This ensures we apply the divisibility
info to the largest rewrite expression.

This helps to improve results in a few cases, one in
dtcxzyw/llvm-opt-benchmark#2921 and another one
in a different large C/C++ based IR corpus.
fhahn added a commit to fhahn/llvm-project that referenced this pull request Oct 15, 2025
At the moment, the effectivness of guards that contain divisibility
information (A % B == 0 ) depends on the order of the conditions.

This patch makes using divisibility information independent of the
order, by collecting and applying the divisibility information
separately.

We first collect all conditions in a vector, then collect the
divisibility information from all guards.

When processing other guards, we apply divisibility info collected
earlier.

After all guards have been processed, we add the divisibility info,
rewriting the existing rewrite. This ensures we apply the divisibility
info to the largest rewrite expression.

This helps to improve results in a few cases, one in
dtcxzyw/llvm-opt-benchmark#2921 and another one
in a different large C/C++ based IR corpus.
fhahn added a commit to fhahn/llvm-project that referenced this pull request Oct 20, 2025
At the moment, the effectivness of guards that contain divisibility
information (A % B == 0 ) depends on the order of the conditions.

This patch makes using divisibility information independent of the
order, by collecting and applying the divisibility information
separately.

We first collect all conditions in a vector, then collect the
divisibility information from all guards.

When processing other guards, we apply divisibility info collected
earlier.

After all guards have been processed, we add the divisibility info,
rewriting the existing rewrite. This ensures we apply the divisibility
info to the largest rewrite expression.

This helps to improve results in a few cases, one in
dtcxzyw/llvm-opt-benchmark#2921 and another one
in a different large C/C++ based IR corpus.
fhahn added a commit to fhahn/llvm-project that referenced this pull request Oct 20, 2025
At the moment, the effectivness of guards that contain divisibility
information (A % B == 0 ) depends on the order of the conditions.

This patch makes using divisibility information independent of the
order, by collecting and applying the divisibility information
separately.

We first collect all conditions in a vector, then collect the
divisibility information from all guards.

When processing other guards, we apply divisibility info collected
earlier.

After all guards have been processed, we add the divisibility info,
rewriting the existing rewrite. This ensures we apply the divisibility
info to the largest rewrite expression.

This helps to improve results in a few cases, one in
dtcxzyw/llvm-opt-benchmark#2921 and another one
in a different large C/C++ based IR corpus.
fhahn added a commit to fhahn/llvm-project that referenced this pull request Oct 24, 2025
At the moment, the effectivness of guards that contain divisibility
information (A % B == 0 ) depends on the order of the conditions.

This patch makes using divisibility information independent of the
order, by collecting and applying the divisibility information
separately.

We first collect all conditions in a vector, then collect the
divisibility information from all guards.

When processing other guards, we apply divisibility info collected
earlier.

After all guards have been processed, we add the divisibility info,
rewriting the existing rewrite. This ensures we apply the divisibility
info to the largest rewrite expression.

This helps to improve results in a few cases, one in
dtcxzyw/llvm-opt-benchmark#2921 and another one
in a different large C/C++ based IR corpus.
fhahn added a commit to fhahn/llvm-project that referenced this pull request Oct 27, 2025
At the moment, the effectivness of guards that contain divisibility
information (A % B == 0 ) depends on the order of the conditions.

This patch makes using divisibility information independent of the
order, by collecting and applying the divisibility information
separately.

We first collect all conditions in a vector, then collect the
divisibility information from all guards.

When processing other guards, we apply divisibility info collected
earlier.

After all guards have been processed, we add the divisibility info,
rewriting the existing rewrite. This ensures we apply the divisibility
info to the largest rewrite expression.

This helps to improve results in a few cases, one in
dtcxzyw/llvm-opt-benchmark#2921 and another one
in a different large C/C++ based IR corpus.
fhahn added a commit to fhahn/llvm-project that referenced this pull request Oct 31, 2025
At the moment, the effectivness of guards that contain divisibility
information (A % B == 0 ) depends on the order of the conditions.

This patch makes using divisibility information independent of the
order, by collecting and applying the divisibility information
separately.

We first collect all conditions in a vector, then collect the
divisibility information from all guards.

When processing other guards, we apply divisibility info collected
earlier.

After all guards have been processed, we add the divisibility info,
rewriting the existing rewrite. This ensures we apply the divisibility
info to the largest rewrite expression.

This helps to improve results in a few cases, one in
dtcxzyw/llvm-opt-benchmark#2921 and another one
in a different large C/C++ based IR corpus.
fhahn added a commit to fhahn/llvm-project that referenced this pull request Oct 31, 2025
At the moment, the effectivness of guards that contain divisibility
information (A % B == 0 ) depends on the order of the conditions.

This patch makes using divisibility information independent of the
order, by collecting and applying the divisibility information
separately.

We first collect all conditions in a vector, then collect the
divisibility information from all guards.

When processing other guards, we apply divisibility info collected
earlier.

After all guards have been processed, we add the divisibility info,
rewriting the existing rewrite. This ensures we apply the divisibility
info to the largest rewrite expression.

This helps to improve results in a few cases, one in
dtcxzyw/llvm-opt-benchmark#2921 and another one
in a different large C/C++ based IR corpus.
fhahn added a commit to llvm/llvm-project that referenced this pull request Nov 2, 2025
…#163021)

At the moment, the effectivness of guards that contain divisibility
information (A % B == 0 ) depends on the order of the conditions.

This patch makes using divisibility information independent of the
order, by collecting and applying the divisibility information
separately.

We first collect all conditions in a vector, then collect the
divisibility information from all guards.

When processing other guards, we apply divisibility info collected
earlier.

After all guards have been processed, we add the divisibility info,
rewriting the existing rewrite. This ensures we apply the divisibility
info to the largest rewrite expression.

This helps to improve results in a few cases, one in
dtcxzyw/llvm-opt-benchmark#2921 and another one
in a different large C/C++ based IR corpus.

PR: #163021
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Nov 2, 2025
…oop guards. (#163021)

At the moment, the effectivness of guards that contain divisibility
information (A % B == 0 ) depends on the order of the conditions.

This patch makes using divisibility information independent of the
order, by collecting and applying the divisibility information
separately.

We first collect all conditions in a vector, then collect the
divisibility information from all guards.

When processing other guards, we apply divisibility info collected
earlier.

After all guards have been processed, we add the divisibility info,
rewriting the existing rewrite. This ensures we apply the divisibility
info to the largest rewrite expression.

This helps to improve results in a few cases, one in
dtcxzyw/llvm-opt-benchmark#2921 and another one
in a different large C/C++ based IR corpus.

PR: llvm/llvm-project#163021
DEBADRIBASAK pushed a commit to DEBADRIBASAK/llvm-project that referenced this pull request Nov 3, 2025
…llvm#163021)

At the moment, the effectivness of guards that contain divisibility
information (A % B == 0 ) depends on the order of the conditions.

This patch makes using divisibility information independent of the
order, by collecting and applying the divisibility information
separately.

We first collect all conditions in a vector, then collect the
divisibility information from all guards.

When processing other guards, we apply divisibility info collected
earlier.

After all guards have been processed, we add the divisibility info,
rewriting the existing rewrite. This ensures we apply the divisibility
info to the largest rewrite expression.

This helps to improve results in a few cases, one in
dtcxzyw/llvm-opt-benchmark#2921 and another one
in a different large C/C++ based IR corpus.

PR: llvm#163021
fhahn added a commit to fhahn/llvm-project that referenced this pull request Nov 4, 2025
…llvm#163021)

At the moment, the effectivness of guards that contain divisibility
information (A % B == 0 ) depends on the order of the conditions.

This patch makes using divisibility information independent of the
order, by collecting and applying the divisibility information
separately.

We first collect all conditions in a vector, then collect the
divisibility information from all guards.

When processing other guards, we apply divisibility info collected
earlier.

After all guards have been processed, we add the divisibility info,
rewriting the existing rewrite. This ensures we apply the divisibility
info to the largest rewrite expression.

This helps to improve results in a few cases, one in
dtcxzyw/llvm-opt-benchmark#2921 and another one
in a different large C/C++ based IR corpus.

PR: llvm#163021
(cherry picked from commit d3fe1df)
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.

2 participants