public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/103645] New: Gimplifier does not remove empty struct stores in a few cases
@ 2021-12-10 10:43 pinskia at gcc dot gnu.org
  2021-12-10 20:48 ` [Bug c/103645] " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-10 10:43 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103645
           Summary: Gimplifier does not remove empty struct stores in a
                    few cases
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: internal-improvement, missed-optimization
          Severity: minor
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
typedef struct { } spinlock_t;
void init_waitqueue_head(spinlock_t *q)
{
 q = (spinlock_t) { };
}
---- CUT -----

Most likely this is due to compound_literal_expr handling.

  *q = <<< Unknown tree: compound_literal_expr
    struct spinlock_t D.1982 = {}; >>>;

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

* [Bug c/103645] Gimplifier does not remove empty struct stores in a few cases
  2021-12-10 10:43 [Bug c/103645] New: Gimplifier does not remove empty struct stores in a few cases pinskia at gcc dot gnu.org
@ 2021-12-10 20:48 ` pinskia at gcc dot gnu.org
  2021-12-21  4:10 ` [Bug middle-end/103645] " pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-10 20:48 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot gnu.org
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2021-12-10
     Ever confirmed|0                           |1

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

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

* [Bug middle-end/103645] Gimplifier does not remove empty struct stores in a few cases
  2021-12-10 10:43 [Bug c/103645] New: Gimplifier does not remove empty struct stores in a few cases pinskia at gcc dot gnu.org
  2021-12-10 20:48 ` [Bug c/103645] " pinskia at gcc dot gnu.org
@ 2021-12-21  4:10 ` pinskia at gcc dot gnu.org
  2022-01-19  1:48 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-21  4:10 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |middle-end

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
compound_literal_expr is handled in gimplifier.c.

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

* [Bug middle-end/103645] Gimplifier does not remove empty struct stores in a few cases
  2021-12-10 10:43 [Bug c/103645] New: Gimplifier does not remove empty struct stores in a few cases pinskia at gcc dot gnu.org
  2021-12-10 20:48 ` [Bug c/103645] " pinskia at gcc dot gnu.org
  2021-12-21  4:10 ` [Bug middle-end/103645] " pinskia at gcc dot gnu.org
@ 2022-01-19  1:48 ` pinskia at gcc dot gnu.org
  2022-08-08  3:39 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-19  1:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 52223
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52223&action=edit
Patch which has been boostraped and tested a few times

This patch fix the issue but I don't think it qualifies for stage 4 so waiting
until stage 1 to submit it. Placing it here so it does not get lost.

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

* [Bug middle-end/103645] Gimplifier does not remove empty struct stores in a few cases
  2021-12-10 10:43 [Bug c/103645] New: Gimplifier does not remove empty struct stores in a few cases pinskia at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2022-01-19  1:48 ` pinskia at gcc dot gnu.org
@ 2022-08-08  3:39 ` pinskia at gcc dot gnu.org
  2022-08-08 15:14 ` cvs-commit at gcc dot gnu.org
  2022-08-08 15:15 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-08-08  3:39 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |https://gcc.gnu.org/piperma
                   |                            |il/gcc-patches/2022-August/
                   |                            |599424.html
           Keywords|                            |patch

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Slightly different patch submitted:
https://gcc.gnu.org/pipermail/gcc-patches/2022-August/599424.html

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

* [Bug middle-end/103645] Gimplifier does not remove empty struct stores in a few cases
  2021-12-10 10:43 [Bug c/103645] New: Gimplifier does not remove empty struct stores in a few cases pinskia at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2022-08-08  3:39 ` pinskia at gcc dot gnu.org
@ 2022-08-08 15:14 ` cvs-commit at gcc dot gnu.org
  2022-08-08 15:15 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-08-08 15:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>:

https://gcc.gnu.org/g:21c7aab09805d0c8c7695c8a69c8715d673a739a

commit r13-1990-g21c7aab09805d0c8c7695c8a69c8715d673a739a
Author: Andrew Pinski <apinski@marvell.com>
Date:   Mon Dec 20 20:27:33 2021 -0800

    Fix middle-end/103645: empty struct store not removed when using compound
literal

    For compound literals empty struct stores are not removed as they go down a
    different path of the gimplifier; trying to optimize the init constructor.
    This fixes the problem by not adding the gimple assignment at the end
    of gimplify_init_constructor if it was an empty type.

    Note this updates gcc.dg/pr87052.c where we had:
    const char d[0] = { };
    And was expecting a store to d but after this, there is no store
    as the decl's type is zero in size.

    OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

    gcc/ChangeLog:

            PR middle-end/103645
            * gimplify.cc (gimplify_init_constructor): Don't build/add
            gimple assignment of an empty type.

    gcc/testsuite/ChangeLog:
            * gcc.dg/pr87052.c: Update d var to expect nothing.

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

* [Bug middle-end/103645] Gimplifier does not remove empty struct stores in a few cases
  2021-12-10 10:43 [Bug c/103645] New: Gimplifier does not remove empty struct stores in a few cases pinskia at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2022-08-08 15:14 ` cvs-commit at gcc dot gnu.org
@ 2022-08-08 15:15 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-08-08 15:15 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED
   Target Milestone|---                         |13.0

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2022-08-08 15:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-10 10:43 [Bug c/103645] New: Gimplifier does not remove empty struct stores in a few cases pinskia at gcc dot gnu.org
2021-12-10 20:48 ` [Bug c/103645] " pinskia at gcc dot gnu.org
2021-12-21  4:10 ` [Bug middle-end/103645] " pinskia at gcc dot gnu.org
2022-01-19  1:48 ` pinskia at gcc dot gnu.org
2022-08-08  3:39 ` pinskia at gcc dot gnu.org
2022-08-08 15:14 ` cvs-commit at gcc dot gnu.org
2022-08-08 15:15 ` 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).