https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94516
--- Comment #15 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:d44f14ccef831d90feb57fab56bc3389d543ffdd commit r11-87-gd44f14ccef831d90feb57fab56bc3389d543ffdd Author: Jakub Jelinek <ja...@redhat.com> Date: Tue May 5 16:34:51 2020 +0200 csa, postreload: Improve csa after recent cselib changes [PR94516] This patch addresses a missed optimization caused by the cselib changes. Already in the past postreload could replace sp = sp + const_int with sp = regxy if regxy already has the right value, but with the cselib changes it happens several times more often. It can result in smaller code, so it seems undesirable to prevent such optimizations, but unfortunately it can get into the way of stack adjustment coalescing, where e.g. if we used to have sp = sp + 32; sp = sp - 8;, previously we'd turn that into sp = sp + 24;, but now postreload optimizes into sp = r12; sp = sp - 8; and csa gives up. The patch just adds a REG_EQUAL note when changing sp = sp + const into sp = reg, where we remember it was actually a stack adjustment by certain constant, and the combine-stack-adj changes than make use of those REG_EQUAL notes, together with LR tracking (csa did enable the note problem, just didn't simulate each insn) so that we can add the needed clobbers etc. (taken from the other stack adjustment insn). 2020-05-05 Jakub Jelinek <ja...@redhat.com> PR rtl-optimization/94516 * postreload.c (reload_cse_simplify): When replacing sp = sp + const with sp = reg, add REG_EQUAL note with sp + const. * combine-stack-adj.c (try_apply_stack_adjustment): Change return type from int to bool. Add LIVE and OTHER_INSN arguments. Undo postreload sp = sp + const to sp = reg optimization if needed and possible. (combine_stack_adjustments_for_block): Add LIVE argument. Handle reg = sp insn with sp + const REG_EQUAL note. Adjust try_apply_stack_adjustment caller, call df_simulate_initialize_forwards and df_simulate_one_insn_forwards. (combine_stack_adjustments): Allocate and free LIVE bitmap, adjust combine_stack_adjustments_for_block caller.