Skip to content

[VPlan] Only retain NSW when possible in getFlagsFromIndDesc. - #226315

Merged
fhahn merged 2 commits into
llvm:mainfrom
fhahn:iv-wrap-flags-fix
Sep 25, 2026
Merged

fhahn merged 2 commits into
llvm:mainfrom
fhahn:iv-wrap-flags-fix

Conversation

@fhahn

@fhahn fhahn commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

getFlagsFromIndDesc is used to get the flags to use for wide inductions. Those are normalized to Adds, with the step negated if the induction binop is Sub.

Only retain all flags for Add. For Sub, never retain NUW and only keep NSW if the step is known to not be signed min.

Alive2 Proofs showing incorrect NUW/NSW transfer and transfer of NSW if step is != signed INT_MIN: https://alive2.llvm.org/ce/z/zGKeZg

Fixes #224024.

getFlagsFromIndDesc is used to get the flags to use for wide inductions.
Those are normalized to Adds, with the step negated if the induction
binop is Sub.

Only retain all flags for Add. For Sub, never retain NUW and only keep
NSW if the step is known to not be signed min.

Alive2 Proofs showing incorrect NUW/NSW transfer and transfer of NSW if
step is != signed INT_MIN: https://alive2.llvm.org/ce/z/zGKeZg

Fixes llvm#224024.
@fhahn fhahn added the skip-precommit-approval PR for CI feedback, not intended for review label Sep 24, 2026
@fhahn
fhahn enabled auto-merge (squash) September 24, 2026 22:27
@fhahn
fhahn merged commit d9dbd96 into llvm:main Sep 25, 2026
8 of 10 checks passed
@fhahn
fhahn deleted the iv-wrap-flags-fix branch September 25, 2026 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llvm:transforms skip-precommit-approval PR for CI feedback, not intended for review vectorizers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong code at -O2/3/s on x86_64-linux_gnu

1 participant