Landing: 2fcbe075ec3b
Project / Subsystem
gcc / tree-optimization
Date
2026-07-15
Author
Richard Biener
Commit
2fcbe075ec3b32f4a523ebae68a8a32381bb46a9
Source
github
Perf win
No
Breaking
No
All attributes
- project
- gcc
- subsystem
- tree-optimization
- patch_id
- —
- commit_hash
- 2fcbe075ec3b32f4a523ebae68a8a32381bb46a9
- source_type
- github
- headline
- Fix SCEV handling of INT_MIN subtraction to avoid UB
- tldr
- Ensures correct scalar evolution calculation for subtractions involving the most negative integer, preventing undefined behavior.
- author
- Richard Biener
- outcome
- committed
- performance_win
- false
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • optimization
- • integer
- • UB
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-07-15T00:00:00.000Z
This commit resolves an issue in Scalar Evolution (SCEV) analysis where subtracting the most negative value of a signed integer type could lead to undefined behavior and incorrect analysis results. Previously, only the negation of INT_MIN was guarded, but this did not correct the resulting SCEV direction when the operation was flipped from subtraction to addition. The fix now promotes the entire operation to unsigned, ensuring correct analysis even in these edge cases. New test cases verify the fix.