[Bug tree-optimization/96344] 3rdd case of gnat.dg/opt86a.adb fails because of VRP

2020-12-08 Thread ebotcazou at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96344

Eric Botcazou  changed:

   What|Removed |Added

 Resolution|--- |FIXED
   Target Milestone|--- |11.0
 Status|NEW |RESOLVED

--- Comment #7 from Eric Botcazou  ---
Fixed everywhere.

[Bug tree-optimization/96344] 3rdd case of gnat.dg/opt86a.adb fails because of VRP

2020-12-08 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96344

--- Comment #6 from CVS Commits  ---
The master branch has been updated by Eric Botcazou :

https://gcc.gnu.org/g:ffd961fc053419bc1eb37792c18ec98e7c3bc364

commit r11-5836-gffd961fc053419bc1eb37792c18ec98e7c3bc364
Author: Eric Botcazou 
Date:   Tue Dec 8 08:57:46 2020 +0100

PR tree-optimization/96344

The very recent addition of the if_to_switch pass has partially disabled
the optimization added back in June to optimize_range_tests_to_bit_test,
as witnessed by the 3 new failures in the gnat.dg testsuite.  It turns out
that both tree-ssa-reassoc.c and tree-switch-conversion.c can turn things
into bit tests so the optimization is added to bit_test_cluster::emit too.

The patch also contains a secondary optimization, whereby the full bit-test
sequence is sent to the folder before being gimplified in case there is
only
one test, so that the optimal sequence (bt + jc on x86) can be emitted like
with optimize_range_tests_to_bit_test.

gcc/ChangeLog:
PR tree-optimization/96344
* tree-switch-conversion.c (bit_test_cluster::emit): Compute the
range only if an entry test is necessary.  Merge the entry test in
the bit test when possible.  Use PREC local variable consistently.
When there is only one test, do a single gimplification at the end.

[Bug tree-optimization/96344] 3rdd case of gnat.dg/opt86a.adb fails because of VRP

2020-12-03 Thread ebotcazou at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96344

--- Comment #5 from Eric Botcazou  ---
> A fresh build of trunk on x86_64 shows the following Ada failures:
> 
> !  FAIL: gnat.dg/opt86a.adb (1: +1)
> !  FAIL: gnat.dg/opt86b.adb (1: +1)
> !  FAIL: gnat.dg/opt86c.adb (1: +1)
> 
> The logs show this:
> 
> $ grep "FAIL: gnat.dg/opt86" gcc/testsuite/gnat/gnat.log
> FAIL: gnat.dg/opt86a.adb scan-tree-dump-times optimized ">>" 4
> FAIL: gnat.dg/opt86b.adb scan-tree-dump-not optimized "> 29"
> FAIL: gnat.dg/opt86c.adb scan-tree-dump-not optimized "> 26"

Introduced on 12/01, probably by:

2020-12-01  Martin Liska  

PR tree-optimization/14799
PR ipa/88702
* Makefile.in: Add gimple-if-to-switch.o.
* dbgcnt.def (DEBUG_COUNTER): Add new debug counter.
* passes.def: Include new pass_if_to_switch pass.
* timevar.def (TV_TREE_IF_TO_SWITCH): New timevar.
* tree-pass.h (make_pass_if_to_switch): New.
* tree-ssa-reassoc.c (struct operand_entry): Move to the header.
(dump_range_entry): Move to header file.
(debug_range_entry): Likewise.
(no_side_effect_bb): Make it global.
* tree-switch-conversion.h (simple_cluster::simple_cluster):
Add inline for couple of functions in order to prevent error
about multiple defined symbols.
* gimple-if-to-switch.cc: New file.
* tree-ssa-reassoc.h: New file.

[Bug tree-optimization/96344] 3rdd case of gnat.dg/opt86a.adb fails because of VRP

2020-12-03 Thread msebor at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96344

Martin Sebor  changed:

   What|Removed |Added

 CC||msebor at gcc dot gnu.org

--- Comment #4 from Martin Sebor  ---
Also seen on x86_64-linux.  I was about to open a bug with this:

A fresh build of trunk on x86_64 shows the following Ada failures:

!  FAIL: gnat.dg/opt86a.adb (1: +1)
!  FAIL: gnat.dg/opt86b.adb (1: +1)
!  FAIL: gnat.dg/opt86c.adb (1: +1)

The logs show this:

$ grep "FAIL: gnat.dg/opt86" gcc/testsuite/gnat/gnat.log
FAIL: gnat.dg/opt86a.adb scan-tree-dump-times optimized ">>" 4
FAIL: gnat.dg/opt86b.adb scan-tree-dump-not optimized "> 29"
FAIL: gnat.dg/opt86c.adb scan-tree-dump-not optimized "> 26"

[Bug tree-optimization/96344] 3rdd case of gnat.dg/opt86a.adb fails because of VRP

2020-09-28 Thread ebotcazou at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96344

Eric Botcazou  changed:

   What|Removed |Added

Summary|3rdd case of|3rdd case of
   |gnat.dg/opt86a.adb fails|gnat.dg/opt86a.adb fails
   ||because of VRP
  Component|ada |tree-optimization

--- Comment #3 from Eric Botcazou  ---
The difference is that, on x86-64, the third case is preoptimized (.dse2):

   [local count: 1072024872]:
  system.secondary_stack.ss_release (&FRAME.22.M12b);
  _6 = s3_35 == 1;
  _7 = s3_35 == 4;
  _8 = _6 | _7;
  _57 = s3_35 == 8;
  _56 = _8 | _57;
  if (_56 != 0)
goto ; [0.08%]
  else
goto ; [99.92%]

whereas it is not on PowerPC64:

   [local count: 1072024872]:
  system.secondary_stack.ss_release (&FRAME.22.M12b);
  if (_31 == 1)
goto ; [0.04%]
  else
goto ; [99.96%]

   [local count: 1071596063]:
  if (s3_32 == 4)
goto ; [0.04%]
  else
goto ; [99.96%]

   [local count: 1071167425]:
  if (s3_32 == 8)
goto ; [0.04%]
  else
goto ; [99.96%]

Note the _31 in the first arm instead of s3_32: VRP1 has propagated

s3_32 = (opt86_pkg__enum) _31;

into the first arm but not the others...  So -fno-tree-vrp is a workaround.