https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117297
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- I am not 100% sure if this will help but if we can run the cost before calling changes_are_worthwhile in insn_combination::run to precalucate the old cost, this might improve the situtation.