public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/95126] [10/11/12/13 Regression] Missed opportunity to turn static variables into immediates Date: Sat, 04 Jun 2022 11:23:06 +0000 [thread overview] Message-ID: <bug-95126-4-IbO2WNYcQd@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-95126-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95126 --- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Roger Sayle <sayle@gcc.gnu.org>: https://gcc.gnu.org/g:ed6fd2aed58f2cca99f15331bf68999c0e6df370 commit r13-990-ged6fd2aed58f2cca99f15331bf68999c0e6df370 Author: Roger Sayle <roger@nextmovesoftware.com> Date: Sat Jun 4 12:21:51 2022 +0100 PR middle-end/95126: Expand small const structs as immediate constants. This patch resolves PR middle-end/95126 which is a code quality regression, by teaching the RTL expander to emit small const structs/unions as integer immediate constants. The motivating example from the bugzilla PR is: struct small{ short a,b; signed char c; }; extern int func(struct small X); void call_func(void) { static struct small const s = { 1, 2, 0 }; func(s); } which on x86_64 is currently compiled to: call_func: movzwl s.0+2(%rip), %eax movzwl s.0(%rip), %edx movzwl s.0+4(%rip), %edi salq $16, %rax orq %rdx, %rax salq $32, %rdi orq %rax, %rdi jmp func but with this patch is now optimized to: call_func: movl $131073, %edi jmp func 2022-06-04 Roger Sayle <roger@nextmovesoftware.com> gcc/ChangeLog PR middle-end/95126 * calls.cc (load_register_parameters): When loading a suitable immediate_const_ctor_p VAR_DECL into a single word_mode register, construct it directly in a pseudo rather than read it (by parts) from memory. * expr.cc (int_expr_size): Make tree argument a const_tree. (immediate_const_ctor_p): Helper predicate. Return true for simple constructors that may be materialized in a register. (expand_expr_real_1) [VAR_DECL]: When expanding a constant VAR_DECL with a suitable immediate_const_ctor_p constructor use store_constructor to materialize it directly in a pseudo. * expr.h (immediate_const_ctor_p): Prototype here. * varasm.cc (initializer_constant_valid_for_bitfield_p): Change VALUE argument from tree to const_tree. * varasm.h (initializer_constant_valid_for_bitfield_p): Update prototype. gcc/testsuite/ChangeLog PR middle-end/95126 * gcc.target/i386/pr95126-m32-1.c: New test case. * gcc.target/i386/pr95126-m32-2.c: New test case. * gcc.target/i386/pr95126-m32-3.c: New test case. * gcc.target/i386/pr95126-m32-4.c: New test case. * gcc.target/i386/pr95126-m64-1.c: New test case. * gcc.target/i386/pr95126-m64-2.c: New test case. * gcc.target/i386/pr95126-m64-3.c: New test case. * gcc.target/i386/pr95126-m64-4.c: New test case.
next prev parent reply other threads:[~2022-06-04 11:23 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-05-14 10:16 [Bug c/95126] New: " pskocik at gmail dot com 2020-05-14 11:47 ` [Bug c/95126] " rguenth at gcc dot gnu.org 2021-12-13 4:56 ` [Bug middle-end/95126] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org 2021-12-13 5:02 ` pinskia at gcc dot gnu.org 2022-01-21 13:34 ` rguenth at gcc dot gnu.org 2022-02-08 5:38 ` amodra at gmail dot com 2022-02-26 22:07 ` roger at nextmovesoftware dot com 2022-05-27 9:42 ` [Bug middle-end/95126] [10/11/12/13 " rguenth at gcc dot gnu.org 2022-06-04 11:23 ` cvs-commit at gcc dot gnu.org [this message] 2022-06-10 13:55 ` roger at nextmovesoftware dot com
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-95126-4-IbO2WNYcQd@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).