https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85598
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Note, while the _8 SSA_NAME above is created during: #1 0x0000000001442100 in copy_ssa_name_fn (fn=0x7fffefdcb000, name=<ssa_name 0x7fffefc89d38>, stmt=<gimple_phi 0x7fffefdccd00>) at ../../gcc/tree-ssanames.c:728 #2 0x00000000014425aa in duplicate_ssa_name_fn (fn=0x7fffefdcb000, name=<ssa_name 0x7fffefc89d38>, stmt=<gimple_phi 0x7fffefdccd00>) at ../../gcc/tree-ssanames.c:792 #3 0x00000000011e86ec in duplicate_ssa_name (var=<ssa_name 0x7fffefc89d38>, stmt=<gimple_phi 0x7fffefdccd00>) at ../../gcc/tree-ssanames.h:132 #4 0x00000000011efe9c in create_new_def_for (old_name=<ssa_name 0x7fffefc89d38>, stmt=<gimple_phi 0x7fffefdccd00>, def=0x7fffefdccd30) at ../../gcc/tree-into-ssa.c:2973 #5 0x0000000001176e3b in gimple_duplicate_bb (bb=<basic_block 0x7fffefc8a340 (4)>) at ../../gcc/tree-cfg.c:6171 #6 0x0000000000a281d5 in duplicate_block (bb=<basic_block 0x7fffefc8a340 (4)>, e=<edge 0x0>, after=<basic_block 0x0>) at ../../gcc/cfghooks.c:1085 #7 0x0000000001419034 in create_block_for_threading (bb=<basic_block 0x7fffefc8a340 (4)>, rd=0x2f1e310, count=0, duplicate_blocks=0x7fffffffd820) at ../../gcc/tree-ssa-threadupdate.c:336 #8 0x000000000141a7b1 in ssa_create_duplicates (slot=0x30bd5d8, local_info=0x7fffffffd810) at ../../gcc/tree-ssa-threadupdate.c:1114 the _10 SSA_NAME where it is more important to update the range info is created during: #0 make_ssa_name_fn (fn=0x7fffefdcb000, var=<var_decl 0x7ffff7ff6b40 x>, stmt=<gimple 0x0>, version=0) at ../../gcc/tree-ssanames.c:327 #1 0x0000000001442100 in copy_ssa_name_fn (fn=0x7fffefdcb000, name=<ssa_name 0x7fffefc89d38>, stmt=<gimple 0x0>) at ../../gcc/tree-ssanames.c:728 #2 0x00000000014425aa in duplicate_ssa_name_fn (fn=0x7fffefdcb000, name=<ssa_name 0x7fffefc89d38>, stmt=<gimple 0x0>) at ../../gcc/tree-ssanames.c:792 #3 0x00000000011e86ec in duplicate_ssa_name (var=<ssa_name 0x7fffefc89d38>, stmt=<gimple 0x0>) at ../../gcc/tree-ssanames.h:132 #4 0x00000000011eb287 in insert_phi_nodes_for (var=<ssa_name 0x7fffefc89d38>, phi_insertion_points=0x2fa49a8, update_p=true) at ../../gcc/tree-into-ssa.c:1008 #5 0x00000000011f0657 in insert_updated_phi_nodes_for (var=<ssa_name 0x7fffefc89d38>, dfs=0x2f945d0, blocks=0x2fa4988, update_flags=2048) at ../../gcc/tree-into-ssa.c:3190 #6 0x00000000011f0f09 in update_ssa (update_flags=2048) at ../../gcc/tree-into-ssa.c:3456 so the smarts would need to go into tree-into-ssa.c or so (perhaps just handle the most common cases like this?). Note, insert_phi_nodes_for still doesn't have enough info, it creates just: # x_10 = PHI <x_1(4), x_1(6)> and marks the PHI for rewrite. Or do it only when we propagate the constant 0 into one of the phi arguments later (at that point just check if the condition dominating the edge for the other phi argument isn't a comparison against constant and if it is, use some vr API to adjust the range?