int f(int m, bool c) { return c ? (m | 1) : m; } This can be optimized to `return m | c;`. This transformation is done by LLVM, but not by GCC.
Confirmed.
A ? (b | 1) : b -> b | (convert)A Or more generic: (for op (...) (simplify (cond @0 (op @1 integer_one_cst) @1) (op @1 (convert @0))) I think I have patches ...
Appears to be fixed on trunk.
Fixed by r13-4459-g6508d5e5a1a8c0 .