Landing: b4162b535452

Project / Subsystem

gcc / match.pd

Date

2026-02-18

Author

Daniel Barboza

Commit

b4162b53545220b2ae19993e2edf4707bab4a3db

Source

github

Perf win

Yes

Breaking

No

All attributes

project
gcc
subsystem
match.pd
patch_id
commit_hash
b4162b53545220b2ae19993e2edf4707bab4a3db
source_type
github
headline
match.pd: Remove bit set/bit clear branch mispredict
tldr
GCC now avoids branch mispredictions for certain bitwise operations by replacing conditional bit setting/clearing with unconditional operations.
author
Daniel Barboza
outcome
committed
performance_win
true
breaking_change
false
series_id
series_parts
[]
tags
  • optimization
  • branch prediction
  • bitwise operations
discussion_id_link
bugzilla_pr
date
2026-02-18T00:00:00.000Z

GCC now avoids branch mispredictions in specific bitwise operation scenarios. The compiler now uses unconditional bit setting/clearing instead of conditional operations when checking if a single bit is not set (and setting it) or if a bitmask is set (and clearing it). This change eliminates potential branch mispredictions, improving performance by avoiding unnecessary flushing of the instruction pipeline. The update adds two new patterns to match.pd to accomplish this.