public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/107047] New: load introduced of struct fields after assigning it to a local variable
@ 2022-09-27  7:25 absoler at smail dot nju.edu.cn
  2022-09-27  9:10 ` [Bug middle-end/107047] " rguenth at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: absoler at smail dot nju.edu.cn @ 2022-09-27  7:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107047

            Bug ID: 107047
           Summary: load introduced of struct fields after assigning it to
                    a local variable
           Product: gcc
           Version: 12.1.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: ---

for gcc-12.1.0, with this code:

struct S6 {
   short  f0;
   char  f1;
   int  f2;
};

struct S6 g_36 = {2UL,4L,0x32B3D10AL};
int g_48 = (-1L);


void func_30() {
    struct S6 f[4][7];
    f[1][6] = g_36;
    if (f[1][6].f0 || f[1][6].f1)
        g_48 = f[1][6].f1;
}

when compiled with -O1 option, generated binaries will be like:

0000000000401186 <func_30>:
  401186:       48 83 ec 70             sub    $0x70,%rsp
  40118a:       f7 05 d4 2e 00 00 ff    testl  $0xffffff,0x2ed4(%rip)        #
404068 <g_36>
  401191:       ff ff 00 
  401194:       74 0d                   je     4011a3 <func_30+0x1d>
  401196:       0f be 05 cd 2e 00 00    movsbl 0x2ecd(%rip),%eax        #
40406a <g_36+0x2>
  40119d:       89 05 bd 2e 00 00       mov    %eax,0x2ebd(%rip)        #
404060 <g_48>
  4011a3:       48 83 c4 70             add    $0x70,%rsp
  4011a7:       c3                      retq   

we can see the use of f[1][6] is replaced by g_36 in the if-condition and "g_48
= f[1][6].f1", and the f is not optimized away.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-26  8:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-27  7:25 [Bug rtl-optimization/107047] New: load introduced of struct fields after assigning it to a local variable absoler at smail dot nju.edu.cn
2022-09-27  9:10 ` [Bug middle-end/107047] " rguenth at gcc dot gnu.org
2022-10-05 20:02 ` pinskia at gcc dot gnu.org
2022-10-26  8:31 ` [Bug middle-end/107047] load introduced of struct/union " absoler at smail dot nju.edu.cn

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).