public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/114415] [13/14 Regression] wrong code with -Oz -fno-dce -fno-forward-propagate -flive-range-shrinkage -fweb since r13-1826 Date: Mon, 25 Mar 2024 16:59:28 +0000 [thread overview] Message-ID: <bug-114415-4-1GzAdjEB0D@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-114415-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114415 Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |sayle at gcc dot gnu.org, | |uros at gcc dot gnu.org, | |vmakarov at gcc dot gnu.org --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Seems it is lr_shrinkage pass where things go wrong. In bar0, all the 3 calls the function makes have 2 64-byte arguments (plus 64-byte return passed by hidden reference). -Oz apparently uses -mno-accumulate-outgoing-args, allocates some stack and then have (at least initially) before each of the 3 calls two spots which decrement %rsp by 64 and after each call one spot which increments %rsp by 128. csa merges the first %rsp -= 64 with the previous much larger %rsp decrement and in some cases the %rsp += 128 with following %rsp -= 64. The function sets %r12 to be the REG_ARGS_SIZE 64 %rsp level and %rbx to be the REG_ARGS_SIZE 128 %rsp level, i.e. %rbx = %r12 - 64. In asmcons pass, we still have before the call to bar1 %rsp -= 64; rep_movsi (fills in the second argument); %rsp -= 64; rep_movsi (fills in the first argument). But then lr_shrinkage pass moves both the stack decrements after all the rep_movsi calls, so we then have: (insn 60 71 66 2 (parallel [ (set (reg/f:DI 7 sp) (plus:DI (reg/f:DI 7 sp) (const_int -64 [0xffffffffffffffc0]))) (clobber (reg:CC 17 flags)) ]) "pr114415.c":27:8 272 {*adddi_1} (expr_list:REG_UNUSED (reg:CC 17 flags) (expr_list:REG_ARGS_SIZE (const_int 64 [0x40]) (nil)))) (insn 66 60 72 2 (parallel [ (set (reg/f:DI 7 sp) (plus:DI (reg/f:DI 129) (const_int -64 [0xffffffffffffffc0]))) (clobber (reg:CC 17 flags)) ]) "pr114415.c":27:8 272 {*adddi_1} (expr_list:REG_DEAD (reg/f:DI 129) (expr_list:REG_UNUSED (reg:CC 17 flags) (expr_list:REG_ARGS_SIZE (const_int 128 [0x80]) (nil))))) and just set of %rdi and call to bar1. Now, as x86-64 has red zone, this in theory could still work fine (dunno if backend is supposed to have some barriers which prevent moving the rep movsl insns across it, unfortunately the fact that it uses some %rsp based address is not visible directly in the insn due to CSE), but then comes peephole2 ;; With -Oz, transform mov $imm,reg to the shorter push $imm; pop reg. and converts the (set (reg:DI %rcx) (const_int 16)) insns to push/pop pair, which when the stack pointer is higher than it should have been causes clobbering of the value.
next prev parent reply other threads:[~2024-03-25 16:59 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-03-21 12:52 [Bug target/114415] New: wrong code with -Oz -fno-dce -fno-forward-propagate -flive-range-shrinkage -fweb zsojka at seznam dot cz 2024-03-25 14:43 ` [Bug target/114415] [13/14 Regression] wrong code with -Oz -fno-dce -fno-forward-propagate -flive-range-shrinkage -fweb since r13-1826 jakub at gcc dot gnu.org 2024-03-25 16:59 ` jakub at gcc dot gnu.org [this message] 2024-03-25 17:15 ` jakub at gcc dot gnu.org 2024-03-29 23:49 ` law at gcc dot gnu.org 2024-04-03 16:28 ` vmakarov at gcc dot gnu.org 2024-04-04 11:32 ` vmakarov at gcc dot gnu.org 2024-04-04 20:07 ` [Bug rtl-optimization/114415] " cvs-commit at gcc dot gnu.org 2024-04-05 4:10 ` [Bug rtl-optimization/114415] [13 " law at gcc dot gnu.org 2024-04-06 12:01 ` ebotcazou at gcc dot gnu.org 2024-04-06 17:35 ` law at gcc dot gnu.org 2024-05-08 12:28 ` rguenth at gcc dot gnu.org 2024-05-09 10:04 ` jakub at gcc dot gnu.org 2024-05-09 15:40 ` vmakarov at gcc dot gnu.org 2024-05-09 16:42 ` cvs-commit at gcc dot gnu.org 2024-05-09 19:06 ` jakub at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-114415-4-1GzAdjEB0D@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).