public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/112272] New: suboptimal zero-initialization of struct of mixed pointer and integer types
@ 2023-10-29  8:13 lh_mouse at 126 dot com
  2023-10-29 16:32 ` [Bug tree-optimization/112272] " pinskia at gcc dot gnu.org
  2023-11-04  5:57 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: lh_mouse at 126 dot com @ 2023-10-29  8:13 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112272
           Summary: suboptimal zero-initialization of struct of mixed
                    pointer and integer types
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lh_mouse at 126 dot com
  Target Milestone: ---

Testcase:
(https://gcc.godbolt.org/z/97cThnszM)

```
struct data_mixed
  {
    int* p1;
    int* p2;
    __INTPTR_TYPE__ i3;
    int* p4;

    constexpr data_mixed() noexcept : p1(), p2(), i3(), p4() { }
  };

data_mixed
create_data_mixed()
  {
    return {};  // somehow suboptimal ↓↓
//        mov     QWORD PTR [rdi+16], 0
//        mov     QWORD PTR [rdi+24], 0
//        vmovdqu XMMWORD PTR [rdi], xmm0
  }


struct data_ptrs
  {
    int* p1;
    int* p2;
    void* p3;
    int* p4;

    constexpr data_ptrs() noexcept : p1(), p2(), p3(), p4() { }
  };

data_ptrs
create_data_ptrs()
  {
    return {};     // vmovdqu YMMWORD PTR [rdi], ymm0
  }


struct data_ints
  {
    __INTPTR_TYPE__ p1;
    __INTPTR_TYPE__ p2;
    __INTPTR_TYPE__ p3;
    __INTPTR_TYPE__ p4;

    constexpr data_ints() noexcept : p1(), p2(), p3(), p4() { }
  };

data_ints
create_data_ints()
  {
    return {};      // vmovdqu YMMWORD PTR [rdi], ymm0
  }
```

I believe these structs should be initialized in the same way, by storing a
zero YMM register. However mixed use of pointer and integer types seems to
prevent that. This is not specific to GCC 13; in GCC 12 it used to prevent
vectorization completely.

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

* [Bug tree-optimization/112272] suboptimal zero-initialization of struct of mixed pointer and integer types
  2023-10-29  8:13 [Bug tree-optimization/112272] New: suboptimal zero-initialization of struct of mixed pointer and integer types lh_mouse at 126 dot com
@ 2023-10-29 16:32 ` pinskia at gcc dot gnu.org
  2023-11-04  5:57 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-29 16:32 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement

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

* [Bug tree-optimization/112272] suboptimal zero-initialization of struct of mixed pointer and integer types
  2023-10-29  8:13 [Bug tree-optimization/112272] New: suboptimal zero-initialization of struct of mixed pointer and integer types lh_mouse at 126 dot com
  2023-10-29 16:32 ` [Bug tree-optimization/112272] " pinskia at gcc dot gnu.org
@ 2023-11-04  5:57 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-04  5:57 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-11-04
             Blocks|                            |53947
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

I don't know why the SLP vectorizer rejects it.

Though I wonder why store merging also rejects it for a cost reason ...


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53947
[Bug 53947] [meta-bug] vectorizer missed-optimizations

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

end of thread, other threads:[~2023-11-04  5:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-29  8:13 [Bug tree-optimization/112272] New: suboptimal zero-initialization of struct of mixed pointer and integer types lh_mouse at 126 dot com
2023-10-29 16:32 ` [Bug tree-optimization/112272] " pinskia at gcc dot gnu.org
2023-11-04  5:57 ` 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).