https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107065
--- Comment #13 from Marc Glisse <glisse at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #12) > Doing it on the match.pd side doesn't look right, there could be many other > optimizations that result in something similar. $ grep -c non_lvalue match.pd 12 probably they should be removed and those that were useful should be fixed by similar techniques as you are considering... To add one more option to your list, maybe the generic-simplify machinery could add non_lvalue automatically in some cases? I still prefer your first option though, tweaking the warning code, which probably expected x!=0 and now gets !(x==0) or something similar.