Landing: 5e26bbfbdfa8

Project / Subsystem

gcc / match.pd

Date

2026-04-27

Author

Netanel Komm

Commit

5e26bbfbdfa875ef464896bb8768669dd5a9ceb9

Source

github

Perf win

Yes

Breaking

No

All attributes

project
gcc
subsystem
match.pd
patch_id
commit_hash
5e26bbfbdfa875ef464896bb8768669dd5a9ceb9
source_type
github
headline
Simplify conditional additions involving constants and vectors.
tldr
GCC simplifies conditional expressions of the form 'x != CST1 ? x + CST2 : CST3' to 'x + CST2' when CST1 + CST2 == CST3, including uniform vectors.
author
Netanel Komm
outcome
committed
performance_win
true
breaking_change
false
series_id
series_parts
[]
tags
  • optimization
  • pattern matching
  • vectorization
discussion_id_link
github:gcc-mirror/gcc#122996
bugzilla_pr
date
2026-04-27T00:00:00.000Z

This patch extends GCC’s pattern matching to simplify conditional addition expressions. When the condition is of the form x != CST1 ? x + CST2 : CST3 and CST1 + CST2 == CST3, the expression is simplified to x + CST2. This handles cases with a third constant and uniform vectors, resolving a missing vector addition fold. New test cases have been added to verify the simplification for both scalar and vector types.