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
This patch introduces several targeted optimizations and correctness improvements across many LLVM IR files, primarily focused on:
Adding @llvm.assume intrinsics to encode known constraints (e.g., pointer non-nullity, integer bounds, loop trip count limits) — enabling more aggressive optimization (e.g., dead code elimination, loop vectorization, memory access simplification). These appear consistently across abc, actix-rs, arrow, boost, clap-rs, darktable, faiss, hermes, html5ever-rs, image-rs, influxdb-rs, mini-lsm-rs, nix, opencv, php, pingora-rs, pola-rs, qdrant-rs, quiche-rs, and others.
Refining @llvm.assume predicates for precision: replacing coarse checks (e.g., icmp ugt i64 %x, 15) with tighter ones (e.g., icmp ult i64 %x, 16 + assume), or adding sign-aware comparisons (icmp samesign ult, icmp sgt i64 %x, -1) to better model signed/unsigned semantics and enable overflow-safe optimizations.
Updating @llvm.assume call attributes: The declaration of @llvm.assume is updated in multiple files to use precise function attributes (nocallback, nofree, nosync, willreturn, memory(inaccessiblemem: write)), improving optimizer reasoning about side effects and memory behavior.
Fixing pointer arithmetic and indexing bugs: Several instances correct off-by-one or misordered arithmetic (e.g., swapping operand order in add nuw instructions, fixing getelementptr base offsets in hashbrown table deallocation paths), often paired with new @llvm.assume calls to validate the fix (e.g., icmp sgt i64 %val, -1 before arithmetic).
Improving phi node consistency and control flow: Multiple patches adjust phi node incoming value lists to match updated basic block predecessors (e.g., changing %15 to %16 in phi operands), ensuring IR validity after CFG changes induced by new assume-inserted branches or reordered instructions.
These changes collectively enhance both correctness (by encoding and validating invariants) and performance (by providing the optimizer richer, more precise information).
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
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#183688
Requested by: @nikic