public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/66391] New: suboptimal code for assignment of SImode struct with bitfields
@ 2015-06-03  6:56 bonzini at gnu dot org
  2015-06-03  7:22 ` [Bug rtl-optimization/66391] " rguenth at gcc dot gnu.org
  2021-08-19  0:47 ` [Bug middle-end/66391] " pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: bonzini at gnu dot org @ 2015-06-03  6:56 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 66391
           Summary: suboptimal code for assignment of SImode struct with
                    bitfields
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bonzini at gnu dot org
  Target Milestone: ---

This is caused by early SRA splitting elem's assignment into separate per-field
assignments.

struct x {
        unsigned a : 6;
        unsigned b : 26;
};      

int f(struct x *x, unsigned a, unsigned b)
{       
        struct x elem = { .a = a, .b = b };
        int i;

        for (i = 0; i < 512; i++)
                x[i] = elem;
}       

Generated code:

.LFB0:
        .cfi_startproc
        leaq    2048(%rdi), %rcx
        andl    $63, %esi
        sall    $6, %edx
        .p2align 4,,10
        .p2align 3
.L2:
        movzbl  (%rdi), %eax
        addq    $4, %rdi
        andl    $-64, %eax
        orl     %esi, %eax
        movb    %al, -4(%rdi)
        movl    -4(%rdi), %eax
        andl    $63, %eax
        orl     %edx, %eax
        movl    %eax, -4(%rdi)
        cmpq    %rcx, %rdi
        jne     .L2
        rep ret
        .cfi_endproc


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

* [Bug rtl-optimization/66391] suboptimal code for assignment of SImode struct with bitfields
  2015-06-03  6:56 [Bug rtl-optimization/66391] New: suboptimal code for assignment of SImode struct with bitfields bonzini at gnu dot org
@ 2015-06-03  7:22 ` rguenth at gcc dot gnu.org
  2021-08-19  0:47 ` [Bug middle-end/66391] " pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-06-03  7:22 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-06-03
     Ever confirmed|0                           |1


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

* [Bug middle-end/66391] suboptimal code for assignment of SImode struct with bitfields
  2015-06-03  6:56 [Bug rtl-optimization/66391] New: suboptimal code for assignment of SImode struct with bitfields bonzini at gnu dot org
  2015-06-03  7:22 ` [Bug rtl-optimization/66391] " rguenth at gcc dot gnu.org
@ 2021-08-19  0:47 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-19  0:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So at -O2 we get decent code from GCC 9+ due to store merging which "undoes"
what SRA did.

But at -O3 the loop gets split into two.

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

end of thread, other threads:[~2021-08-19  0:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-03  6:56 [Bug rtl-optimization/66391] New: suboptimal code for assignment of SImode struct with bitfields bonzini at gnu dot org
2015-06-03  7:22 ` [Bug rtl-optimization/66391] " rguenth at gcc dot gnu.org
2021-08-19  0:47 ` [Bug middle-end/66391] " pinskia at gcc dot gnu.org

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