3 ms·
GCC does this match.pd. Here's the add_zero example, I think: /* Simplifications of operations with one constant operand and simplifications to con
by fweimer 2y ago
GCC does this match.pd. Here's the add_zero example, I think:
/* Simplifications of operations with one constant operand and
simplifications to constants or single values. */
(for op (plus pointer_plus minus bit_ior bit_xor)
(simplify
(op @0 integer_zerop)
(non_lvalue @0)))
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/match.pd https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/match.pd
The floating point case can be more complicated because of signed zeros and signaling NaNs, see fold_real_zero_addition_p.