public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/81958] [9/10/11 Regression] spurious -Wmaybe-uninitialized warning in gcc-8, or with -O1
       [not found] <bug-81958-4@http.gcc.gnu.org/bugzilla/>
@ 2021-04-02 19:36 ` msebor at gcc dot gnu.org
  2021-04-08 14:24 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-04-02 19:36 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|spurious                    |[9/10/11 Regression]
                   |-Wmaybe-uninitialized       |spurious
                   |warning in gcc-8, or with   |-Wmaybe-uninitialized
                   |-O1                         |warning in gcc-8, or with
                   |                            |-O1
      Known to fail|                            |10.2.0, 11.0, 8.3.0, 9.3.0
                 CC|                            |msebor at gcc dot gnu.org
      Known to work|                            |7.3.0
   Last reconfirmed|2017-09-30 00:00:00         |2021-4-2

--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
Reconfirming with GCC 11 as a GCC 8 regression introduced in r249013. It fails
the same with -O1 and -O2.  I think the warning seems to be doing what it's
designed to do.  The IL below annotated with my comments in bb 7 shows that
there is a patch along which the use is uninitialized.

void lpfc_debug_dump_all_queues (unsigned int maxidx)
{
  unsigned long ivtmp.7;
  unsigned int eqidx;
  struct lpfc_queue * eq;
  struct lpfc_queue * cq_phba.0_1;
  struct lpfc_queue * _2;
  int _5;
  unsigned int _23;
  long unsigned int _24;

  <bb 2> [count: 0]:
  # .MEM_12 = VDEF <.MEM_11(D)>
  printk ();
  # VUSE <.MEM_12>
  cq_phba.0_1 = cq_phba;
  goto <bb 4>; [0.00%]

  <bb 3> [count: 0]:
  # VUSE <.MEM_12>
  _2 = cq_phba.0_1->hba_eq;
  _24 = ivtmp.7_25 * 16;
  eq_16 = _2 + _24;
  # VUSE <.MEM_12>
  _5 = eq_16->queue_id;
  ivtmp.7_26 = ivtmp.7_25 + 1;
  if (_5 != 0)
    goto <bb 9>; [0.00%]
  else
    goto <bb 8>; [0.00%]

  <bb 9> [count: 0]:
  goto <bb 7>; [100.00%]

  <bb 8> [count: 0]:

  <bb 4> [count: 0]:
  # eq_7 = PHI <eq_14(D)(2), eq_16(8)>
  # ivtmp.7_25 = PHI <0(2), ivtmp.7_26(8)>
  _23 = (unsigned int) ivtmp.7_25;
  if (maxidx_15(D) > _23)
    goto <bb 3>; [0.00%]
  else
    goto <bb 5>; [0.00%]

  <bb 5> [count: 0]:
  if (maxidx_15(D) == _23)
    goto <bb 6>; [0.00%]
  else
    goto <bb 10>; [0.00%]

  <bb 10> [count: 0]:
  goto <bb 7>; [100.00%]

  <bb 6> [count: 0]:
  # VUSE <.MEM_12>
  eq_18 = cq_phba.0_1->hba_eq;

  <bb 7> [count: 0]:
  ## eq_7(10) = PHI <eq_14(D)(2), eq_16(8)>
  ## eq_7(10) = eq_14(D)(2) (unconditional: 2 -> 4)
  ## eq_9 = eq_7 = eq_14(D)(2)
  ##   if (maxidx_15(D) <= _23 && maxidx_15(D) != _23: 4 -> 5, 5 -> 10, 10 ->
7)
  # eq_9 = PHI <eq_7(10), eq_18(6), eq_16(9)>
  # .MEM_19 = VDEF <.MEM_12>
  printk (eq_9); [tail call]
  # VUSE <.MEM_19>
  return;

}

Before r249013 there is no uninitialized read from eq in the IL:

; Function lpfc_debug_dump_all_queues (lpfc_debug_dump_all_queues,
funcdef_no=0, decl_uid=1800, cgraph_uid=0, symbol_order=1)

lpfc_debug_dump_all_queues (unsigned int maxidx)
{
  unsigned int eqidx;
  struct lpfc_queue * eq;
  struct lpfc_queue * prephitmp_1;
  unsigned long _2;
  int _5;
  struct lpfc_queue * _20;
  int _22;
  struct lpfc_queue * pretmp_23;
  struct lpfc_queue * pretmp_24;
  struct lpfc_queue * cq_phba.0_25;
  struct lpfc_queue * _26;
  unsigned long _28;

  <bb 2> [14.44%]:
  printk ();
  if (maxidx_15(D) != 0)
    goto <bb 4>; [92.50%]
  else
    goto <bb 3>; [7.50%]

  <bb 3> [1.08%]:
  pretmp_23 = cq_phba;
  pretmp_24 = pretmp_23->hba_eq;
  goto <bb 7>; [100.00%]

  <bb 4> [13.32%]:
  cq_phba.0_25 = cq_phba;
  _26 = cq_phba.0_25->hba_eq;
  _22 = _26->queue_id;
  if (_22 != 0)
    goto <bb 9>; [7.50%]
  else
    goto <bb 10>; [92.50%]

  <bb 10> [12.32%]:
  goto <bb 6>; [100.00%]

  <bb 9> [1.00%]:
  goto <bb 8>; [100.00%]

  <bb 5> [79.18%]:
  _2 = (unsigned long) eq_29;
  _28 = _2 + 16;
  _20 = (struct lpfc_queue *) _28;
  _5 = MEM[base: _20, offset: 0B];
  if (_5 != 0)
    goto <bb 11>; [7.50%]
  else
    goto <bb 12>; [92.50%]

  <bb 11> [5.94%]:
  goto <bb 8>; [100.00%]

  <bb 12> [73.24%]:

  <bb 6> [85.60%]:
  # eqidx_27 = PHI <eqidx_17(12), 0(10)>
  # eq_29 = PHI <_20(12), _26(10)>
  eqidx_17 = eqidx_27 + 1;
  if (maxidx_15(D) != eqidx_17)
    goto <bb 5>; [92.50%]
  else
    goto <bb 13>; [7.50%]

  <bb 13> [6.42%]:

  <bb 7> [5.44%]:
  # prephitmp_1 = PHI <_26(13), pretmp_24(3)>

  <bb 8> [14.44%]:
  # eq_9 = PHI <_26(9), prephitmp_1(7), _20(11)>
  printk (eq_9); [tail call]
  return;

}

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

* [Bug tree-optimization/81958] [9/10/11 Regression] spurious -Wmaybe-uninitialized warning in gcc-8, or with -O1
       [not found] <bug-81958-4@http.gcc.gnu.org/bugzilla/>
  2021-04-02 19:36 ` [Bug tree-optimization/81958] [9/10/11 Regression] spurious -Wmaybe-uninitialized warning in gcc-8, or with -O1 msebor at gcc dot gnu.org
@ 2021-04-08 14:24 ` rguenth at gcc dot gnu.org
  2021-06-01  8:09 ` [Bug tree-optimization/81958] [9/10/11/12 " rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-04-08 14:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |9.4

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

* [Bug tree-optimization/81958] [9/10/11/12 Regression] spurious -Wmaybe-uninitialized warning in gcc-8, or with -O1
       [not found] <bug-81958-4@http.gcc.gnu.org/bugzilla/>
  2021-04-02 19:36 ` [Bug tree-optimization/81958] [9/10/11 Regression] spurious -Wmaybe-uninitialized warning in gcc-8, or with -O1 msebor at gcc dot gnu.org
  2021-04-08 14:24 ` rguenth at gcc dot gnu.org
@ 2021-06-01  8:09 ` rguenth at gcc dot gnu.org
  2022-01-21 13:52 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-01  8:09 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.4                         |9.5

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9.4 is being released, retargeting bugs to GCC 9.5.

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

* [Bug tree-optimization/81958] [9/10/11/12 Regression] spurious -Wmaybe-uninitialized warning in gcc-8, or with -O1
       [not found] <bug-81958-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2021-06-01  8:09 ` [Bug tree-optimization/81958] [9/10/11/12 " rguenth at gcc dot gnu.org
@ 2022-01-21 13:52 ` rguenth at gcc dot gnu.org
  2022-05-27  9:37 ` [Bug tree-optimization/81958] [10/11/12/13 " rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-21 13:52 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

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

* [Bug tree-optimization/81958] [10/11/12/13 Regression] spurious -Wmaybe-uninitialized warning in gcc-8, or with -O1
       [not found] <bug-81958-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2022-01-21 13:52 ` rguenth at gcc dot gnu.org
@ 2022-05-27  9:37 ` rguenth at gcc dot gnu.org
  2022-06-28 10:33 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-27  9:37 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.5                         |10.4

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9 branch is being closed

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

* [Bug tree-optimization/81958] [10/11/12/13 Regression] spurious -Wmaybe-uninitialized warning in gcc-8, or with -O1
       [not found] <bug-81958-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2022-05-27  9:37 ` [Bug tree-optimization/81958] [10/11/12/13 " rguenth at gcc dot gnu.org
@ 2022-06-28 10:33 ` jakub at gcc dot gnu.org
  2023-03-30 12:53 ` rguenth at gcc dot gnu.org
  2023-07-07 10:32 ` [Bug tree-optimization/81958] [11/12/13/14 " rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-28 10:33 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.4                        |10.5

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 10.4 is being released, retargeting bugs to GCC 10.5.

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

* [Bug tree-optimization/81958] [10/11/12/13 Regression] spurious -Wmaybe-uninitialized warning in gcc-8, or with -O1
       [not found] <bug-81958-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2022-06-28 10:33 ` jakub at gcc dot gnu.org
@ 2023-03-30 12:53 ` rguenth at gcc dot gnu.org
  2023-07-07 10:32 ` [Bug tree-optimization/81958] [11/12/13/14 " rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-03-30 12:53 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
We see

<bb 4> [count: 0]:
# eq_7 = PHI <eq_14(D)(2), eq_16(8)>
# ivtmp.7_23 = PHI <0(2), ivtmp.7_24(8)>
_25 = (unsigned int) ivtmp.7_23;
if (maxidx_15(D) > _25)
  goto <bb 3>; [0.00%]
else
  goto <bb 5>; [0.00%] // loop exit

<bb 5> [count: 0]:
if (maxidx_15(D) == _25)
  goto <bb 6>; [0.00%]
else
  goto <bb 10>; [0.00%]

<bb 7> [count: 0]:
# eq_9 = PHI <eq_7(10), eq_18(6), eq_16(9)>
printk (eq_9); [tail call]
return;

and the appearant uninit use is on the 10->7 edge, when maxidx != _25
but at the same time maxidx > _25.  We don't realize that the
maxidx == _25 condition is always true.  The possible easiest way
is probably to rewrite the in-loop condition to maxid != _25 somewhere
(ivcanon?).

uninit analysis itself just sees maxid <= _25 && maxid ==_25 as the
initialized cases - it could possibly analyze how _25 evolves
when defined in a loop to further optimize this to true.

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

* [Bug tree-optimization/81958] [11/12/13/14 Regression] spurious -Wmaybe-uninitialized warning in gcc-8, or with -O1
       [not found] <bug-81958-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2023-03-30 12:53 ` rguenth at gcc dot gnu.org
@ 2023-07-07 10:32 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07 10:32 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.5                        |11.5

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 10 branch is being closed.

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

end of thread, other threads:[~2023-07-07 10:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-81958-4@http.gcc.gnu.org/bugzilla/>
2021-04-02 19:36 ` [Bug tree-optimization/81958] [9/10/11 Regression] spurious -Wmaybe-uninitialized warning in gcc-8, or with -O1 msebor at gcc dot gnu.org
2021-04-08 14:24 ` rguenth at gcc dot gnu.org
2021-06-01  8:09 ` [Bug tree-optimization/81958] [9/10/11/12 " rguenth at gcc dot gnu.org
2022-01-21 13:52 ` rguenth at gcc dot gnu.org
2022-05-27  9:37 ` [Bug tree-optimization/81958] [10/11/12/13 " rguenth at gcc dot gnu.org
2022-06-28 10:33 ` jakub at gcc dot gnu.org
2023-03-30 12:53 ` rguenth at gcc dot gnu.org
2023-07-07 10:32 ` [Bug tree-optimization/81958] [11/12/13/14 " rguenth 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).