https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101403
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Another question is whether we shouldn't extend the short_shift stuff in build_binary_op also to COMPOUND_EXPRs with INTEGER_CST on the ultimate rhs. unsigned int f1 (unsigned short x) { return x >> 12; } unsigned int f2 (unsigned short x) { static int u; return x >> (u, 12); } The C++ FE already handles these the same, as it does: tree const_op1 = fold_for_warn (op1); if (TREE_CODE (const_op1) != INTEGER_CST) const_op1 = op1; But it won't handle int f (); unsigned int f3 (unsigned short x) { return x >> (f (), 12); } either. The C FE doesn't try to simplify op1 in any way. I guess in those cases we don't really care about any side-effects in the expression, what we are looking for is just whether the value is known constant. For diagnostics, it would be nice if we handled x >> (f (), 37) like we handle x >> 37 if it is an out of bounds shift. For the optimization, maybe the short_shift stuff could be repeated in match.pd.