Landing: 33cd7bbb32c5

Project / Subsystem

gcc / match

Date

2026-05-21

Author

Avinal Kumar

Commit

33cd7bbb32c5eee4aff7aa06f351aa983be419bc

Source

github

Perf win

Yes

Breaking

No

All attributes

project
gcc
subsystem
match
patch_id
commit_hash
33cd7bbb32c5eee4aff7aa06f351aa983be419bc
source_type
github
headline
GCC now handles `X != INT_MIN ? -X : INT_MIN` without bailing out.
tldr
GCC optimizes a conditional negation involving `INT_MIN` by using an unsigned negation to avoid undefined behavior.
author
Avinal Kumar
outcome
committed
performance_win
true
breaking_change
false
series_id
series_parts
[]
tags
  • gcc
  • optimization
discussion_id_link
bugzilla_pr
date
2026-05-21T00:00:00.000Z

GCC can now optimize expressions of the form X != INT_MIN ? -X : INT_MIN even when the signed negation of INT_MIN is undefined behavior. The compiler now emits an unsigned negate (equivalent to (signed)(-(unsigned)X)) in these cases, mirroring the existing handling of the abs pattern for the same edge case. This ensures the expression is well-defined and allows for further optimization.