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 applies the nsw (no signed wrap) flag to 64 add i32 instructions across the filter_screened_poisson benchmark’s LLVM IR. All changes are localized to the BSplineEvaluationData class’s evaluation methods (centerValue, cornerValue, ChildEvaluator variants), specifically in code paths computing offset indices via integer addition before sign-extension to i64.
The major changes are:
Addition overflow semantics tightened: 64 add i32 operations—previously plain—now carry the nsw attribute, indicating the compiler may assume no signed integer overflow occurs. This enables optimizations like elimination of overflow checks and more aggressive simplifications.
Consistent pattern in index arithmetic: All modified adds combine a computed mask-like value (%notmask.i.i.i*) with a constant or parameter-derived offset (e.g., %65, %103, %945, %1621). These are part of multi-dimensional B-spline grid indexing logic, where overflow would be undefined behavior; nsw reflects that assumption.
No change to control flow or data layout: The patch only annotates existing arithmetic—no new branches, memory ops, or type changes. The sext i32 to i64 instructions remain unchanged, preserving correctness of index computation.
Targeted to B-spline evaluation hotspots: Modifications span both top-level Evaluator and nested ChildEvaluator methods, covering numerous corner/center value evaluations—suggesting this is performance-critical spline sampling code.
Likely result of improved range analysis or profile-guided optimization: The systematic application of nsw implies the optimizer (e.g., InstCombine or LoopVectorizer) has proven these additions cannot overflow—possibly due to known bounds on input parameters (e.g., grid dimensions, degree, or evaluation coordinates).
No other IR structure, function signatures, or metadata are altered. The change is purely an optimization hint, enhancing safety and enabling downstream optimizations without affecting observable behavior.
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#174355
Requested by: @dtcxzyw