[Bug tree-optimization/99918] [9/10/11 Regression] suboptimal code for bool bitfield tests

2021-04-08 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99918

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P2

[Bug tree-optimization/99918] [9/10/11 Regression] suboptimal code for bool bitfield tests

2021-04-06 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99918

Richard Biener  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2021-04-06
 Blocks||85316
 Ever confirmed|0   |1
   Target Milestone|--- |9.4

--- Comment #5 from Richard Biener  ---
The main issue is optimize_bit_field_compare in fold-const.c which produces
during GENERIC folding in .005t.original:

  if ((BIT_FIELD_REF  & 1) != 0)
{
  b.j = 0;
}
  else
{
  b.j = b.i;
}
  return b.j;

that's premature in this place.  For f() it also takes until DOM3 to do
the folding unless you disable SRA which then makes EVRP recognize the
second store as a.j = 0.  With SRA we fail to derive ranges for a_10 in

  a_10 = MEM  [(struct A *)];
  a$1_11 = MEM  [(struct A *) + 1B];
  _1 = VIEW_CONVERT_EXPR<_Bool>(a_10);
  if (_1 != 0)
goto ; [INV]
  else
goto ; [INV]

   :

   :
  # a$1_9 = PHI <0(2), a_10(3)>
  _7 = VIEW_CONVERT_EXPR<_Bool>(a$1_9);

thus we're missing looking through VIEW_CONVERT_EXPR in register_assert_for.
Amending that would eventually also allow optimizing the prematurely folded
vairant.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85316
[Bug 85316] [meta-bug] VRP range propagation missed cases

[Bug tree-optimization/99918] [9/10/11 Regression] suboptimal code for bool bitfield tests

2021-04-05 Thread msebor at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99918

--- Comment #4 from Martin Sebor  ---
(In reply to Andrew Pinski from comment #1)
> This comes down to lowering bitfields too soon.
> my bet it will happen even integer bitfields will have a problem.

Yes, unsigned bit-fields suffer the same problem but unlike for _Bool, GCC
never emitted optimal code for those for this test case.

[Bug tree-optimization/99918] [9/10/11 Regression] suboptimal code for bool bitfield tests

2021-04-05 Thread msebor at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99918

--- Comment #3 from Martin Sebor  ---
This only seems to affect C _Bool bit-fields and not C++ bool.

[Bug tree-optimization/99918] [9/10/11 Regression] suboptimal code for bool bitfield tests

2021-04-05 Thread msebor at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99918

Martin Sebor  changed:

   What|Removed |Added

  Known to fail||10.2.0, 11.0, 6.3.0, 7.0.1,
   ||8.3.0, 9.3.0
Summary|suboptimal code for bool|[9/10/11 Regression]
   |bitfield tests  |suboptimal code for bool
   ||bitfield tests

--- Comment #2 from Martin Sebor  ---
Bisection points to r225825 as the revision where GCC started to fail to fold
the code in g().