Landing: ab6c415e13ca

Project / Subsystem

gcc / gcc/match.pd

Date

2026-05-12

Author

Shivam Gupta

Commit

ab6c415e13ca87e3e4c7a24ccd9bf83e23ef30ee

Source

github

Perf win

Yes

Breaking

No

All attributes

project
gcc
subsystem
gcc/match.pd
patch_id
commit_hash
ab6c415e13ca87e3e4c7a24ccd9bf83e23ef30ee
source_type
github
headline
Simplify ((~x) & y) ^ (x | y) to x or ~x
tldr
GCC now simplifies certain bitwise operations involving XOR, AND, OR, and NOT into simpler forms, potentially improving code generation.
author
Shivam Gupta
outcome
committed
performance_win
true
breaking_change
false
series_id
series_parts
[]
tags
  • optimization
  • bitwise
  • pattern matching
  • tree-ssa
discussion_id_link
bugzilla_pr
date
2026-05-12T00:00:00.000Z

The compiler can now simplify expressions of the form ((~x) & y) ^ (x | y) to x, and ((~x) | y) ^ (x & y) to ~x. This pattern is detected during tree-ssa optimisation, using a pattern-matching framework (match.pd) to rewrite the GIMPLE IR. The change should reduce code size and improve performance in code that uses these bitwise patterns.