https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81601
--- Comment #18 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Note, it isn't just optimize_bit_field_compare, but also fold_truth_andor_1 that creates this stuff. Doing this at gimple might have best framework in the reassoc pass, because you need to look through conditions in multiple basic blocks with no significant code in between, but also conditions bitwise ored or anded within a single bb, i.e. the result of how multiple &&s or ||s are lowered. The reassoc pass is the only one with this kind of framework, in optimize_range_tests. Probably it would need to be done only in the second reassoc pass, which, while it is before vrp2, it is only shortly before that and as an advantage it there would be some time gimple passes to clean stuff up if needed.