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 patch introduces several targeted optimizations across many benchmarks, primarily focused on improving optimization opportunities through the insertion of llvm.assume intrinsics and refining memory access patterns. The changes are consistent with LLVM’s standard optimization practices.
Here are the 5 major changes:
Addition of llvm.assume for null-pointer checks: Across numerous functions (e.g., Cnf_ManPostprocess_old, Vec_IntFree.exit, drop_in_place helpers), new icmp ne ptr %x, null + tail call void @llvm.assume(i1) pairs are inserted to inform the optimizer that certain pointers are non-null. This enables more aggressive dereference optimizations and eliminates redundant null checks.
Strengthening of size-bound assumptions: Several places now add llvm.assume calls to encode known upper bounds on integer values — e.g., icmp samesign ult i64 %val, 16, icmp slt i64 %val, -15, or icmp ult i8 %val, 5. These help eliminate unnecessary range checks and enable better vectorization or loop simplification (e.g., in string handling, array indexing, and memcpy length calculations).
Refinement of allocator-related control flow: In multiple alloc_impl functions (e.g., in delta-rs, html5ever-rs, image-rs, qdrant-rs), the logic around zero-size allocation handling is updated: an explicit icmp ne i64 %size, 0 + llvm.assume is added before branching, improving downstream reasoning about allocation validity and enabling dead-code elimination.
Fixes and updates to llvm.assume function attributes: The declaration of @llvm.assume is updated consistently across files to use precise memory attributes (memory(inaccessiblemem: write)) and calling convention attributes (nocallback, nofree, nosync, willreturn). This ensures correct alias analysis and enables more aggressive interprocedural optimizations.
Cleanup of redundant pointer arithmetic and gep chains: In a few locations (e.g., pingora-rs, darktable, msgpack), unnecessary and/getelementptr sequences are removed or simplified — often after llvm.assume has enabled the optimizer to prove alignment or offset safety — resulting in cleaner, more direct memory accesses (e.g., replacing and ..., -128; gep ... with direct gep or memcpy from base address).
No formatting, renaming, or reordering changes were included in this summary — only semantically meaningful transformations that affect optimization potential or correctness.
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#183688
Requested by: @dtcxzyw