You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 17, 2026. It is now read-only.
This LLVM IR diff reflects optimizations targeting loop trip count computation and control flow simplification in the polars_arrow::array::Array::null_count function (and related code). Here are the 5 major changes:
Elimination of redundant and i64 %x, 4294967295 masking:
Three instances of %wide.trip.count*.i.* = and i64 %val, 4294967295 (which masks the lower 32 bits) were removed — at lines 41906, 42085, 42892, and 43058. This indicates the trip count is already known to fit in 32 bits, making the mask unnecessary.
Replacement of 64-bit loop exit comparisons with 32-bit equivalents:
Loop exit conditions (%exitcond*.not.*) were changed from icmp eq i64 %indvars.iv.next*, %wide.trip.count* to icmp eq i32 %trip_limit, %trunc_next, where %trip_limit (e.g., %152, %218, %526, %578) is a pre-existing 32-bit value. This avoids 64-bit arithmetic and enables better optimization (e.g., induction variable elimination, smaller registers).
Simplification of loop phi nodes and critical edge handling:
Several phi nodes in loop exit blocks (e.g., %195, %.lcssa.i.us.pre-phi.i, %.sroa.0.3.lcssa.i) were updated to directly use truncated loop counters (%181, %557, %623) instead of redundant truncations computed in separate basic blocks (e.g., %199, %565). This removes dead code and merges control flow.
Removal of dead basic blocks and redundant truncations:
Blocks like .lr.ph.split.us.i.._crit_edge.loopexit.split.loop.exit35.i.loopexit_crit_edge.us.i and its trunc instruction %565 = trunc ... were deleted, as their logic was folded into predecessor blocks. Similarly, %262 = trunc ... was hoisted and reused, eliminating duplication.
Control flow cleanup in loop exit branches:
A branch target was updated from %default.unreachable269 → %default.unreachable277, and another branch was redirected from %.lr.ph.split.us.i.._crit_edge... to %._crit_edge... (line 42920), reflecting refined loop exit structure after merging paths. Also, an invoke continuation label was renamed from .cont292 → .cont302, suggesting minor CFG restructuring (likely due to inlining or exception-handling optimization).
Overall, these changes reflect aggressive loop canonicalization, induction variable narrowing, and dead code elimination, likely driven by Loop Vectorize or Loop Simplify passes — improving both code size and potential vectorization readiness.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
None yet
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link: llvm/llvm-project#170474
Requested by: @nikic