This backport contains 1 patch from gcc main stream tree. ^M The commit id of these patchs list as following in the order of time. 0001-Make-ifcvt-clean-up-dead-comparisons.patch f1f10541903b082d27114db38947fb31f5364bcc diff -Nurp a/gcc/basic-block.h b/gcc/basic-block.h --- a/gcc/basic-block.h 2020-09-12 14:42:34.268000000 +0800 +++ b/gcc/basic-block.h 2020-09-12 14:42:48.448000000 +0800 @@ -507,6 +507,8 @@ ei_cond (edge_iterator ei, edge *p) #define CLEANUP_CFGLAYOUT 32 /* Do cleanup in cfglayout mode. */ #define CLEANUP_CFG_CHANGED 64 /* The caller changed the CFG. */ #define CLEANUP_NO_PARTITIONING 128 /* Do not try to fix partitions. */ +#define CLEANUP_FORCE_FAST_DCE 0x100 /* Force run_fast_dce to be called + at least once. */ /* Return true if BB is in a transaction. */ diff -Nurp a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c --- a/gcc/cfgcleanup.c 2020-09-12 14:42:34.292000000 +0800 +++ b/gcc/cfgcleanup.c 2020-09-12 14:42:48.448000000 +0800 @@ -3197,7 +3197,10 @@ cleanup_cfg (int mode) && !delete_trivially_dead_insns (get_insns (), max_reg_num ())) break; if ((mode & CLEANUP_CROSSJUMP) && crossjumps_occurred) - run_fast_dce (); + { + run_fast_dce (); + mode &= ~CLEANUP_FORCE_FAST_DCE; + } } else break; @@ -3206,6 +3209,9 @@ cleanup_cfg (int mode) if (mode & CLEANUP_CROSSJUMP) remove_fake_exit_edges (); + if (mode & CLEANUP_FORCE_FAST_DCE) + run_fast_dce (); + /* Don't call delete_dead_jumptables in cfglayout mode, because that function assumes that jump tables are in the insns stream. But we also don't _have_ to delete dead jumptables in cfglayout diff -Nurp a/gcc/ifcvt.c b/gcc/ifcvt.c --- a/gcc/ifcvt.c 2020-09-12 14:42:34.300000000 +0800 +++ b/gcc/ifcvt.c 2020-09-12 14:42:48.448000000 +0800 @@ -5457,6 +5457,8 @@ if_convert (bool after_combine) static unsigned int rest_of_handle_if_conversion (void) { + int flags = 0; + if (flag_if_conversion) { if (dump_file) @@ -5466,9 +5468,12 @@ rest_of_handle_if_conversion (void) } cleanup_cfg (CLEANUP_EXPENSIVE); if_convert (false); + if (num_updated_if_blocks) + /* Get rid of any dead CC-related instructions. */ + flags |= CLEANUP_FORCE_FAST_DCE; } - cleanup_cfg (0); + cleanup_cfg (flags); return 0; }