Landing: 56c81c325ccc

Project / Subsystem

gcc / match.pd

Date

2026-09-13

Author

Dominic P

Commit

56c81c325cccf432954ddea4c73069e2fa047922

Source

github

Perf win

Yes

Breaking

No

All attributes

project
gcc
subsystem
match.pd
patch_id
—
commit_hash
56c81c325cccf432954ddea4c73069e2fa047922
source_type
github
headline
Folds bitwise operations into unsigned range tests.
tldr
Optimizes bitwise operations `(X + C1) | (C2 - X) < 0` into a more efficient unsigned range test.
author
Dominic P
outcome
committed
performance_win
true
breaking_change
false
series_id
—
series_parts
[]
tags
  • • optimization
  • • compiler
  • • risc-v
discussion_id_link
—
bugzilla_pr
—
date
2026-09-13T00:00:00.000Z

This commit introduces a new optimization in match.pd that transforms a specific bitwise pattern into an unsigned range test. The pattern ((X + C1) | (C2 - X)) < 0 is equivalent to checking if X < -C1 or X > C2. This is further simplified to an unsigned comparison (X + C1) > C1 + C2. The optimization is applied to various spellings of this pattern, including those with constants C1 or C2 equal to zero, and is restricted to GIMPLE intermediate representation to avoid issues with sanitizers or GENERIC code.