Landing: 9d59dcff40a4

Project / Subsystem

gcc / match.pd

Date

2026-08-15

Author

Shivam Gupta

Commit

9d59dcff40a4f39ee82f9c59a67f9466d7a8bc66

Source

github

Perf win

Yes

Breaking

No

All attributes

project
gcc
subsystem
match.pd
patch_id
—
commit_hash
9d59dcff40a4f39ee82f9c59a67f9466d7a8bc66
source_type
github
headline
match.pd: Simplify boolean comparisons of masked bits
tldr
New pattern in match.pd simplifies comparisons of masked bits, canonicalizing them into XOR-mask tests for better optimization.
author
Shivam Gupta
outcome
committed
performance_win
true
breaking_change
false
series_id
—
series_parts
[]
tags
  • • optimization
  • • bitwise
  • • boolean logic
discussion_id_link
—
bugzilla_pr
—
date
2026-08-15T00:00:00.000Z

This commit introduces a new rule into match.pd to simplify boolean comparisons involving masked bits, specifically targeting expressions like (~A & 1) == (~B & 1). The optimization recognizes that these comparisons, especially when dealing with power-of-two masks, can be canonicalized into a more efficient XOR-mask form: ((x ^ y) & c) == 0 or ((x ^ y) & c) != 0. This applies to various combinations of equality and inequality operators and aims to improve optimization effectiveness, particularly at -O1, resolving PR tree-optimization/112533.