Repository navigation
[SCEV] Stop blindly propagating inbounds from GEPs to SCEV nodes - #9116
Open
Natalie Chouinard (sudonatalie) wants to merge 3 commits into
Open
Natalie Chouinard (sudonatalie) wants to merge 3 commits into
Natalie Chouinard (sudonatalie) wants to merge 3 commits into
Conversation
ScalarEvolution::getGEPExpr previously converted a GEP instruction's inbounds flag into SCEV::FlagNSW on the index-by-size multiplication and base addition. When a GEP is guarded by control flow, its inbounds property may not hold across the entire loop, and attaching no-wrap flags to the resulting recurrence can pollute a globally uniqued SCEVAddRecExpr shared with another value (such as the loop's induction variable), causing IndVarSimplify to fold away live loop exit checks. This resolves the PR23527 FIXME in ScalarEvolution::getGEPExpr, matching createSCEV's handling of Add and Mul and backporting the fix from: llvm/llvm-project@2ca8a3f (PR23527, D109789)
Natalie Chouinard (sudonatalie)
requested review from
Chris B (llvm-beanz) and
Steven Perron (s-perron)
November 11, 2026 20:47
Steven Perron (s-perron)
approved these changes
Nov 12, 2026
Chris B (llvm-beanz)
approved these changes
Nov 12, 2026
Chris B (llvm-beanz)
left a comment
Collaborator
There was a problem hiding this comment.
Couple small nits.
Co-authored-by: Chris B <beanz@abolishcrlf.org>
Co-authored-by: Chris B <beanz@abolishcrlf.org>
Natalie Chouinard (sudonatalie)
enabled auto-merge (squash)
November 12, 2026 18:57
Chris B (llvm-beanz)
approved these changes
Nov 12, 2026
Natalie Chouinard (sudonatalie)
disabled auto-merge
November 12, 2026 18:59
Natalie Chouinard (sudonatalie)
force-pushed
the
b-584269341
branch
from
November 12, 2026 19:05
9d83a18 to
9b24d2a
Compare
Natalie Chouinard (sudonatalie)
enabled auto-merge (squash)
November 12, 2026 19:07
Collaborator
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Collaborator
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
This branch has not been deployed
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 free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

ScalarEvolution::getGEPExpr previously converted a GEP instruction's inbounds flag into SCEV::FlagNSW on the index-by-size multiplication and base addition. When a GEP is guarded by control flow, its inbounds property may not hold across the entire loop, and attaching no-wrap flags to the resulting recurrence can pollute a globally uniqued SCEVAddRecExpr shared with another value (such as the loop's induction variable), causing IndVarSimplify to fold away live loop exit checks.
This resolves the PR23527 FIXME in ScalarEvolution::getGEPExpr, matching createSCEV's handling of Add and Mul and backporting the fix from: llvm/llvm-project@2ca8a3f (PR23527, D109789)