Landing: 372d44c5611e

Project / Subsystem

gcc / gcc/match

Date

2026-08-04

Author

Avinal Kumar

Commit

372d44c5611ecce9144c985a849ca06f108289fe

Source

github

Perf win

Yes

Breaking

No

All attributes

project
gcc
subsystem
gcc/match
patch_id
—
commit_hash
372d44c5611ecce9144c985a849ca06f108289fe
source_type
github
headline
Simplify bitwise comparisons involving powers of two
tldr
Optimizes bitwise OR comparisons to AND for powers of two, potentially improving performance.
author
Avinal Kumar
outcome
committed
performance_win
true
breaking_change
false
series_id
—
series_parts
[]
tags
  • • optimization
  • • bitwise
  • • compiler
discussion_id_link
—
bugzilla_pr
—
date
2026-08-04T00:00:00.000Z

This change simplifies expressions of the form (A | C) == A to (A & C) != 0 when C is a power of two. This optimization avoids a bitwise OR and replaces it with a bitwise AND and a comparison against zero, which can be more efficient on some architectures. The inverse transformation for (A | C) != A to (A & C) == 0 is also included. A new test case verifies the optimization.