public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/85563] [8/9/10/11 regression] -Wmaybe-uninitialized false alarm regression with __builtin_unreachable and GCC 8
       [not found] <bug-85563-4@http.gcc.gnu.org/bugzilla/>
@ 2021-04-15 21:39 ` msebor at gcc dot gnu.org
  2021-04-27 11:38 ` [Bug middle-end/85563] [8/9/10/11/12 " jakub 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-15 21:39 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
   Last reconfirmed|2018-04-30 00:00:00         |2021-4-15
                 CC|                            |msebor at gcc dot gnu.org
      Known to fail|8.0.1                       |10.2.0, 11.0, 8.3.0, 9.3.0

--- Comment #18 from Martin Sebor <msebor at gcc dot gnu.org> ---
Reconfirming with GCC 11.

Inverting the reachability expression:

  ((CONSP (Vframe_list)) ? (void) 0 : __builtin_unreachable ());

to

  (!(CONSP (Vframe_list)) ? __builtin_unreachable () : (void) 0);

or changing it to a corresponding if statement avoids the warning and improves
the emitted code, implying there is a missed optimization opportunity there
somewhere.

I also reduced the test from comment #6 a bit further to make it easier to
read:

struct A
{
  struct A *p, *q;
};

extern void *p;

inline _Bool
f (void* a)
{
  return ((__INTPTR_TYPE__) (a) & ~(- (1 << 3))) == 3;
}

inline struct A *
g (void* a)
{
  return (struct A *)((char *)a - 3);
}

extern void* foo (void*);

void bar (void)
{
#if NOWARN
  if (!f (p))
    __builtin_unreachable ();
#else
  f (p) ? (void)0 : __builtin_unreachable ();
#endif

  void* q;
  for (void *r = p; f (r) && ((q = g (r)->p), 1); r = g (r)->q)
    ;

  foo (q);
}

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

* [Bug middle-end/85563] [8/9/10/11/12 regression] -Wmaybe-uninitialized false alarm regression with __builtin_unreachable and GCC 8
       [not found] <bug-85563-4@http.gcc.gnu.org/bugzilla/>
  2021-04-15 21:39 ` [Bug middle-end/85563] [8/9/10/11 regression] -Wmaybe-uninitialized false alarm regression with __builtin_unreachable and GCC 8 msebor at gcc dot gnu.org
@ 2021-04-27 11:38 ` jakub at gcc dot gnu.org
  2021-07-28  7:04 ` [Bug middle-end/85563] [9/10/11/12 " rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-04-27 11:38 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.0                        |11.2

--- Comment #19 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 11.1 has been released, retargeting bugs to GCC 11.2.

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

* [Bug middle-end/85563] [9/10/11/12 regression] -Wmaybe-uninitialized false alarm regression with __builtin_unreachable and GCC 8
       [not found] <bug-85563-4@http.gcc.gnu.org/bugzilla/>
  2021-04-15 21:39 ` [Bug middle-end/85563] [8/9/10/11 regression] -Wmaybe-uninitialized false alarm regression with __builtin_unreachable and GCC 8 msebor at gcc dot gnu.org
  2021-04-27 11:38 ` [Bug middle-end/85563] [8/9/10/11/12 " jakub at gcc dot gnu.org
@ 2021-07-28  7:04 ` rguenth at gcc dot gnu.org
  2022-04-21  7:47 ` 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-07-28  7:04 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.2                        |11.3

--- Comment #20 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 11.2 is being released, retargeting bugs to GCC 11.3

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

* [Bug middle-end/85563] [9/10/11/12 regression] -Wmaybe-uninitialized false alarm regression with __builtin_unreachable and GCC 8
       [not found] <bug-85563-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2021-07-28  7:04 ` [Bug middle-end/85563] [9/10/11/12 " rguenth at gcc dot gnu.org
@ 2022-04-21  7:47 ` rguenth at gcc dot gnu.org
  2022-11-20  4:20 ` [Bug middle-end/85563] [10/11/12/13 " law at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-04-21  7:47 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.3                        |11.4

--- Comment #21 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 11.3 is being released, retargeting bugs to GCC 11.4.

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

* [Bug middle-end/85563] [10/11/12/13 regression] -Wmaybe-uninitialized false alarm regression with __builtin_unreachable and GCC 8
       [not found] <bug-85563-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2022-04-21  7:47 ` rguenth at gcc dot gnu.org
@ 2022-11-20  4:20 ` law at gcc dot gnu.org
  2023-03-30 13:23 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: law at gcc dot gnu.org @ 2022-11-20  4:20 UTC (permalink / raw)
  To: gcc-bugs

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

Jeffrey A. Law <law at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |law at gcc dot gnu.org

--- Comment #22 from Jeffrey A. Law <law at gcc dot gnu.org> ---
Interestingly enough the original testcase seems OK now, but Jakub's reduced
testcase in c#6 still fails.  So keeping this open.

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

* [Bug middle-end/85563] [10/11/12/13 regression] -Wmaybe-uninitialized false alarm regression with __builtin_unreachable and GCC 8
       [not found] <bug-85563-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2022-11-20  4:20 ` [Bug middle-end/85563] [10/11/12/13 " law at gcc dot gnu.org
@ 2023-03-30 13:23 ` rguenth at gcc dot gnu.org
  2023-05-29 10:02 ` [Bug middle-end/85563] [10/11/12/13/14 " jakub at gcc dot gnu.org
  2023-06-26  5:20 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-03-30 13:23 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amacleod at redhat dot com,
                   |                            |rguenth at gcc dot gnu.org
   Last reconfirmed|2021-04-15 00:00:00         |2023-3-30

--- Comment #23 from Richard Biener <rguenth at gcc dot gnu.org> ---
Re-confirmed.  On the testcase in comment#6 we have before EVRP

  <bb 2> :
  Vframe_list.0_1 = Vframe_list;
  a.1_17 = (long int) Vframe_list.0_1;
  _15 = (unsigned int) a.1_17;
  _13 = _15 & 7;
  _10 = _13 == 3;
  if (_13 != 3)
    goto <bb 3>; [INV]
  else
    goto <bb 4>; [INV]

  <bb 3> :
  __builtin_unreachable ();

  <bb 4> :
  # frame1_6 = PHI <frame1_12(D)(2), frame1_16(5)>
  # tail_7 = PHI <Vframe_list.0_1(2), tail_18(5)>
  a.1_19 = (long int) tail_7;
  _20 = (unsigned int) a.1_19;
  _21 = _20 & 7;
  _22 = _21 == 3;
  if (_21 == 3)
    goto <bb 5>; [INV]

  else
    goto <bb 6>; [INV]

  <bb 5> :
  _25 = tail_7 + 18446744073709551613;
  _26 = __builtin_assume_aligned (_25, 8);
  frame1_16 = _26->u.s.car;
  tail_18 = _26->u.s.u.cdr;
  goto <bb 4>; [INV]


  <bb 6> :
  do_switch_frame (frame1_6);

and we fail to realize we are never exiting the loop in the first iteration.
The diagnostic happens because we run into loop header copying which
then results in a jump around the loop with an obviously uninitialized
argument to frame1_6.  And that's because we have thrown away the
__builtin_unreachable before loop header copying (in VRP1, after the first
threadfull).

Re-ordering CH before VRP fails to optimize even when I also put a copyprop
between CH and VRP.  We then see

  <bb 2> [local count: 118111600]:
  # PT = nonlocal escaped null
  Vframe_list.0_1 = Vframe_list;
  a.1_12 = (long int) Vframe_list.0_1;
  _10 = (unsigned int) a.1_12;
  # RANGE [irange] Lisp_Type [0, 7] NONZERO 0x7
  _8 = _10 & 7;
  if (_8 != 3)
    goto <bb 3>; [0.00%]
  else
    goto <bb 4>; [100.00%]

  <bb 3> [count: 0]:
  __builtin_unreachable ();

  <bb 4> [local count: 118111600]:
  a.1_21 = (long int) Vframe_list.0_1;
  _22 = (unsigned int) a.1_21;
  # RANGE [irange] Lisp_Type [0, 7] NONZERO 0x7
  _23 = _22 & 7;
  if (_23 == 3)

but for some reason VRP doesn't optimize the second compare.  We'd probably
need to value-number here (loop header copying does, but only parts of the
function and not including this leading block).

So somewhat of a pass ordering issue.  The next CSE is DOM and then PRE.

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

* [Bug middle-end/85563] [10/11/12/13/14 regression] -Wmaybe-uninitialized false alarm regression with __builtin_unreachable and GCC 8
       [not found] <bug-85563-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2023-03-30 13:23 ` rguenth at gcc dot gnu.org
@ 2023-05-29 10:02 ` jakub at gcc dot gnu.org
  2023-06-26  5:20 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-05-29 10:02 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #24 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 11.4 is being released, retargeting bugs to GCC 11.5.

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

* [Bug middle-end/85563] [10/11/12/13/14 regression] -Wmaybe-uninitialized false alarm regression with __builtin_unreachable and GCC 8
       [not found] <bug-85563-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2023-05-29 10:02 ` [Bug middle-end/85563] [10/11/12/13/14 " jakub at gcc dot gnu.org
@ 2023-06-26  5:20 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-26  5:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #25 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #23)
> 
> So somewhat of a pass ordering issue.  The next CSE is DOM and then PRE.

I was going to say this is related to PR 110405 but pointers don't record
ranges (nor nonzerobits) but have a different kind of flow senative
information.

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

end of thread, other threads:[~2023-06-26  5:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-85563-4@http.gcc.gnu.org/bugzilla/>
2021-04-15 21:39 ` [Bug middle-end/85563] [8/9/10/11 regression] -Wmaybe-uninitialized false alarm regression with __builtin_unreachable and GCC 8 msebor at gcc dot gnu.org
2021-04-27 11:38 ` [Bug middle-end/85563] [8/9/10/11/12 " jakub at gcc dot gnu.org
2021-07-28  7:04 ` [Bug middle-end/85563] [9/10/11/12 " rguenth at gcc dot gnu.org
2022-04-21  7:47 ` rguenth at gcc dot gnu.org
2022-11-20  4:20 ` [Bug middle-end/85563] [10/11/12/13 " law at gcc dot gnu.org
2023-03-30 13:23 ` rguenth at gcc dot gnu.org
2023-05-29 10:02 ` [Bug middle-end/85563] [10/11/12/13/14 " jakub at gcc dot gnu.org
2023-06-26  5:20 ` 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).