https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110874
--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (gdb) p debug_tree(expr1) <ssa_name 0x7ffff780df78 type <integer_type 0x7ffff78215e8 int sizes-gimplified public SI size <integer_cst 0x7ffff7802fd8 constant 32> unit-size <integer_cst 0x7ffff7825000 constant 4> align:32 warn_if_not_align:0 symtab:0 alias-set 1 canonical-type 0x7ffff78215e8 precision:32 min <integer_cst 0x7ffff7802f90 -2147483648> max <integer_cst 0x7ffff7802fa8 2147483647> pointer_to_this <pointer_type 0x7ffff7829b28>> visited def_stmt g_227.1_3 = (int) g_227_8; version:3> $3 = void (gdb) up -1 #0 gimple_bitwise_inverted_equal_p (expr1=0x7ffff79db048, expr2=0x7ffff79db3a8, valueize=0x11ba180 <rpo_vn_valueize(tree_node*)>) at /home/apinski/src/upstream-gcc-git/gcc/gcc/gimple-match-head.cc:278 278 if (expr1 == expr2) (gdb) p debug_tree(expr1) <ssa_name 0x7ffff79db048 type <integer_type 0x7ffff7821690 unsigned int sizes-gimplified public unsigned SI size <integer_cst 0x7ffff7802fd8 constant 32> unit-size <integer_cst 0x7ffff7825000 constant 4> align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7ffff7821690 precision:32 min <integer_cst 0x7ffff7825018 0> max <integer_cst 0x7ffff7802fc0 4294967295> pointer_to_this <pointer_type 0x7ffff7831690>> visited def_stmt g_161.3_5 = (unsigned int) g_161.2_4; version:5> $4 = void Value numbering stmt = g_161.2_4 = g_161; Setting value number of g_161.2_4 to g_227.1_3 (changed) g_227.1_3 is available for g_227.1_3 Value numbering stmt = g_161.3_5 = (unsigned int) g_161.2_4; g_227.1_3 is available for g_227.1_3 Applying pattern match.pd:4207, gimple-match-4.cc:4064 Applying pattern match.pd:4299, gimple-match-4.cc:4122 Match-and-simplified (unsigned int) g_161.2_4 to g_227_8 RHS (unsigned int) g_161.2_4 simplified to g_227_8 Setting value number of g_161.3_5 to g_227_15 (changed) Making available beyond BB6 g_161.3_5 for value g_227_15 Value numbering stmt = _6 = g_161.3_5 & t_17(D); So when we go and handle gimple_nop_convert here and we loop between the two. So we just need to limit gimple_bitwise_inverted_equal_p to only one look through I think ...