Landing: 3c5cc8819fe0

Project / Subsystem

gcc / match

Date

2026-08-19

Author

Kyrylo Tkachov

Commit

3c5cc8819fe03b63cba9ff82569623d092fdf0f5

Source

github

Perf win

No

Breaking

No

All attributes

project
gcc
subsystem
match
patch_id
—
commit_hash
3c5cc8819fe03b63cba9ff82569623d092fdf0f5
source_type
github
headline
Match: Rejects NARROW_CLIP saturating truncation at minimum value for correctness.
tldr
Pattern matching for unsigned integer narrow clip saturating truncation now rejects cases involving the minimum value to avoid incorrect results.
author
Kyrylo Tkachov
outcome
committed
performance_win
false
breaking_change
false
series_id
—
series_parts
[]
tags
  • • match
  • • optimization
  • • bugfix
  • • integer arithmetic
  • • saturating arithmetic
discussion_id_link
—
bugzilla_pr
—
date
2026-08-19T00:00:00.000Z

This commit adjusts the unsigned_integer_narrow_clip pattern in GCC’s matcher to reject cases where the operand is known to be the minimum value of its type. The original pattern could incorrectly rewrite a program when the minimum value was present, leading to a stored value of NT_MAX instead of the expected 0 on certain targets. The updated pattern now requires the minimum value not to occur, preserving correctness and resolving PR126981.