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/105546] New: load introduction when copying a struct Date: Tue, 10 May 2022 11:34:49 +0000 [thread overview] Message-ID: <bug-105546-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105546 Bug ID: 105546 Summary: load introduction when copying a struct Product: gcc Version: 11.3.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: --- Created attachment 52948 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52948&action=edit case file Hi, here's the code: ... struct S0 { unsigned short f0; unsigned short f1; short f2; unsigned char f3; long long f4; long long f5; }; short g_344 = 0xC307L; struct S0 func_1(void) { struct S0 l_346 = {65526UL,1UL,-8L,0xA1L,0x2F513C84A35AAE1BLL,-6L}; if (g_344) { struct S0 l_345 = {0x0AB2L,0x6D27L,-1L,0xABL,3L,0x3E72F31FF82C1E35LL}; return l_345; } else { return l_346; } } ... with option -O1, gcc-11.3.0 generate the following code: Dump of assembler code for function func_1: 0x0000000000401126 <+0>: mov %rdi,%rax 0x0000000000401129 <+3>: cmpw $0x1,0x2eff(%rip) # 0x404030 <g_344> 0x0000000000401131 <+11>: sbb %edi,%edi 0x0000000000401133 <+13>: and $0xf544,%di 0x0000000000401138 <+18>: add $0xab2,%di 0x000000000040113d <+23>: cmpw $0x1,0x2eeb(%rip) # 0x404030 <g_344> 0x0000000000401145 <+31>: sbb %esi,%esi 0x0000000000401147 <+33>: and $0x92da,%si 0x000000000040114c <+38>: add $0x6d27,%si 0x0000000000401151 <+43>: cmpw $0x1,0x2ed7(%rip) # 0x404030 <g_344> 0x0000000000401159 <+51>: sbb %ecx,%ecx 0x000000000040115b <+53>: and $0xfffffff9,%ecx 0x000000000040115e <+56>: sub $0x1,%ecx 0x0000000000401161 <+59>: cmpw $0x1,0x2ec7(%rip) # 0x404030 <g_344> 0x0000000000401169 <+67>: sbb %edx,%edx 0x000000000040116b <+69>: and $0xfffffff6,%edx 0x000000000040116e <+72>: sub $0x55,%edx 0x0000000000401171 <+75>: cmpw $0x0,0x2eb7(%rip) # 0x404030 <g_344> 0x0000000000401179 <+83>: movabs $0x2f513c84a35aae1b,%r9 0x0000000000401183 <+93>: mov $0x3,%r8d 0x0000000000401189 <+99>: cmovne %r8,%r9 0x000000000040118d <+103>: movabs $0x3e72f31ff82c1e35,%r10 0x0000000000401197 <+113>: mov $0xfffffffffffffffa,%r8 0x000000000040119e <+120>: cmovne %r10,%r8 0x00000000004011a2 <+124>: mov %di,(%rax) 0x00000000004011a5 <+127>: mov %si,0x2(%rax) 0x00000000004011a9 <+131>: mov %cx,0x4(%rax) 0x00000000004011ad <+135>: mov %dl,0x6(%rax) 0x00000000004011b0 <+138>: mov %r9,0x8(%rax) 0x00000000004011b4 <+142>: mov %r8,0x10(%rax) 0x00000000004011b8 <+146>: retq it seems the last 4 loads are unneed and can be optimized away, which bring vulnerabilities when facing concurrency and may decrease performance
next reply other threads:[~2022-05-10 11:34 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-05-10 11:34 absoler at smail dot nju.edu.cn [this message] 2022-05-10 11:44 ` [Bug rtl-optimization/105546] load introduction when initializing " absoler at smail dot nju.edu.cn 2022-05-10 21:02 ` [Bug target/105546] [11/12/13 Regression] ifconversion introduces many compares with loads pinskia at gcc dot gnu.org 2022-05-11 7:20 ` rguenth at gcc dot gnu.org 2022-10-19 10:06 ` rguenth at gcc dot gnu.org 2022-10-19 10:07 ` rguenth at gcc dot gnu.org 2023-01-13 21:30 ` roger at nextmovesoftware dot com 2023-05-29 10:07 ` [Bug target/105546] [11/12/13/14 " 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-105546-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).