public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "absoler at smail dot nju.edu.cn" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/114258] New: repeat store operation when copying a union Date: Wed, 06 Mar 2024 17:50:17 +0000 [thread overview] Message-ID: <bug-114258-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114258 Bug ID: 114258 Summary: repeat store operation when copying a union Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: absoler at smail dot nju.edu.cn Target Milestone: --- Hi, here's the code and generated binary compiled with gcc-13.2.0 -O2: ``` // https://godbolt.org/z/jsMhcbKnh union U6 { int f0; long long f1; int f2; }; union U8 { int f0; const long long f1; const long long f2; }; union U6 g_13 = {.f0 = 0xE13F5E3DL}; union U8 g_189 = {.f0 = 0x959411BBL}; int d = 0; int a; void func_1() { const union U6 b[] = {{.f0 = 2}, {.f0 = 2}}; for (; d;) a = 0; g_189.f0 &= (g_13 = b[1], 5); } ``` ``` func_1: mov 0x2f02(%rip),%eax # 404028 <d> test %eax,%eax je 401130 <func_1+0x10> jmp 40112a <func_1+0xa> nopl 0x0(%rax) movq $0x0,0x2edd(%rip) # 404018 <g_13> andl $0x5,0x2ece(%rip) # 404010 <g_189> movl $0x2,0x2ecc(%rip) # 404018 <g_13> ret ``` we can see that the first write to `g_13` could be removed to improve performance.
next reply other threads:[~2024-03-06 17:50 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-03-06 17:50 absoler at smail dot nju.edu.cn [this message] 2024-03-06 18:23 ` [Bug middle-end/114258] 2 stores happen when copying from a const union (array) to an union pinskia at gcc dot gnu.org 2024-03-07 8:15 ` rguenth 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-114258-4@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).