Landing: 6bbe931ea0e8

Project / Subsystem

gcc / match.pd

Date

2026-06-12

Author

Kyrylo Tkachov

Commit

6bbe931ea0e8f412c81fed8a3df4a07df97821f4

Source

github

Perf win

Yes

Breaking

No

All attributes

project
gcc
subsystem
match.pd
patch_id
commit_hash
6bbe931ea0e8f412c81fed8a3df4a07df97821f4
source_type
github
headline
Fold times negated into negative bitwise AND
tldr
GCC now simplifies `x * -y` to `-(x & y)` when `x` and `y` are known to be 0 or 1, improving code generation for conditional operations.
author
Kyrylo Tkachov
outcome
committed
performance_win
true
breaking_change
false
series_id
series_parts
[]
tags
  • optimization
  • aarch64
  • tree-ssa
discussion_id_link
bugzilla_pr
date
2026-06-12T00:00:00.000Z

This commit adds a new simplification rule to match.pd that folds multiplications of 0/1 values with negated 0/1 values into a negative bitwise AND operation (x * -y becomes -(x & y)). This optimization, particularly useful after if-conversion produces 0/1 masks from comparisons, exposes underlying bitwise logic to subsequent compiler passes. It results in a modest ~2.4% performance improvement in a hot kernel for astcenc on AArch64 within SPEC2026.