Optimize `(~y & x) ^ y` into `(y | x)`
GCC now optimizes the expression `(~y & x) ^ y` into `(y | x)` to simplify code.
GCC’s pattern matching now transforms the expression (~y & x) ^ y into its simpler equivalent (y | x). This optimization was needed because the front-end performs constant optimizations like ~1 -> -2 before the existing similar rule could be applied.
In Details
The commit adds a new pattern to GCC's match.pd to optimize the expression (~y & x) ^ y into (y | x). A similar rule existed, but front-end constant optimizations (e.g., ~1 -> -2) prevented its application. This new rule addresses that issue by running earlier in the compilation pipeline.
For Context
Compilers often simplify code by recognizing patterns and replacing them with equivalent but less complex forms. This change adds a new rule to GCC's pattern matcher that transforms the expression (~y & x) ^ y into (y | x). In C-like languages, ~ is the bitwise NOT, & is the bitwise AND, ^ is the bitwise XOR, and | is the bitwise OR operator. This change helps the compiler generate more efficient code by performing this simplification.