https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96482
--- Comment #14 from Martin Liška <marxin at gcc dot gnu.org> --- So in ltrans we end up with: addr_to_index (struct nir_builder * b, struct nir_ssa_def * addr, nir_address_format addr_format) { unsigned int num_channels; unsigned int swizzle[16]; unsigned int i; struct nir_ssa_def * D.7072; unsigned int c; struct nir_ssa_def * _9; <bb 2> [local count: 1073741824]: if (addr_format_3(D) == 3) goto <bb 3>; [20.24%] else goto <bb 4>; [79.76%] <bb 3> [local count: 1073741824]: c = 0; _9 = nir_swizzle (b_5(D), addr_6(D), &c, 1); c ={v} {CLOBBER}; return _9; <bb 4> [count: 0]: __builtin_unreachable (); } that's fine, in WPA we identified that possible values are 3 and 5. However ./src/gallium/targets/dri/libgallium_dri.so.ltrans65.ltrans.129t.ccp3 optimizes that to: Folding statement: if (addr_format_3(D) == 3) which is likely CONSTANT Folding predicate addr_format_3(D) == 3 to 0 Folded into: if (0 != 0) which is wrong. The following code is executed: if (flag_tree_bit_ccp) { wide_int nonzero_bits = get_nonzero_bits (var); tree value; widest_int mask; if (SSA_NAME_VAR (var) && TREE_CODE (SSA_NAME_VAR (var)) == PARM_DECL && ipcp_get_parm_bits (SSA_NAME_VAR (var), &value, &mask)) { val.lattice_val = CONSTANT; val.value = value; val.mask = mask; if (nonzero_bits != -1) val.mask &= extend_mask (nonzero_bits, TYPE_SIGN (TREE_TYPE (var))); } where range info for var is: (gdb) p *ri $2 = { ints = { m_precision = 32, m_max_len = 1 '\001', m_len = "\001\001\001", m_val = {3} } } (gdb) p nonzero_bits.dump() [0x3], precision = 32 (gdb) p mask.dump() [...,0x6], precision = 192 (gdb) p debug_tree(value) <integer_cst 0x7ffff7268e10 type <enumeral_type 0x7ffff720e738 nir_address_format> constant 5> So that's we saw in WPA. So far so good, but now these 2 pieces of information are combined: val.mask &= extend_mask (nonzero_bits, TYPE_SIGN (TREE_TYPE (var))); (gdb) p val.mask.dump() [...,0x2], precision = 192 and folding happens :/