[Bug tree-optimization/85859] [6/7/8/9 Regression] wrong code with -fno-isolate-erroneous-paths-dereference

2018-09-03 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85859

--- Comment #7 from Tom de Vries  ---
(In reply to Jakub Jelinek from comment #6)
> So fixed on the trunk?  Any plans to backport?

Will do, thanks for the ping.

[Bug tree-optimization/85859] [6/7/8/9 Regression] wrong code with -fno-isolate-erroneous-paths-dereference

2018-08-27 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85859

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #6 from Jakub Jelinek  ---
So fixed on the trunk?  Any plans to backport?

[Bug tree-optimization/85859] [6/7/8/9 Regression] wrong code with -fno-isolate-erroneous-paths-dereference

2018-06-21 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85859

--- Comment #5 from Tom de Vries  ---
Author: vries
Date: Thu Jun 21 12:44:38 2018
New Revision: 261844

URL: https://gcc.gnu.org/viewcvs?rev=261844=gcc=rev
Log:
[tail-merge] Fix side-effect test in stmt_local_def

2018-06-21  Tom de Vries  

PR tree-optimization/85859
* tree-ssa-tail-merge.c (stmt_local_def): Copy gimple_is_call
test with comment from bb_no_side_effects_p.

* gcc.dg/pr85859.c: New test.

Added:
trunk/gcc/testsuite/gcc.dg/pr85859.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-ssa-tail-merge.c

[Bug tree-optimization/85859] [6/7/8/9 Regression] wrong code with -fno-isolate-erroneous-paths-dereference

2018-06-20 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85859

Tom de Vries  changed:

   What|Removed |Added

   Keywords||patch

--- Comment #4 from Tom de Vries  ---
https://gcc.gnu.org/ml/gcc-patches/2018-06/msg01277.html

[Bug tree-optimization/85859] [6/7/8/9 Regression] wrong code with -fno-isolate-erroneous-paths-dereference

2018-06-20 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85859

--- Comment #3 from Tom de Vries  ---
Created attachment 44305
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44305=edit
Tentative patch

[Bug tree-optimization/85859] [6/7/8/9 Regression] wrong code with -fno-isolate-erroneous-paths-dereference

2018-05-22 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85859

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P2
 CC||rguenth at gcc dot gnu.org,
   ||vries at gcc dot gnu.org

--- Comment #2 from Richard Biener  ---
(In reply to Richard Biener from comment #1)
> Confirmed.  foo is discovered as 'const', it is nothrow anyways
> (-fno-exceptions)
> and thus overall it is considered not having side-effects (in particular not
> trap).  Quoting tree-ssa-ifcombine.c:
> 
> /* Verify if the basic block BB does not have side-effects.  Return
>true in this case, else false.  */
> 
> static bool
> bb_no_side_effects_p (basic_block bb)
> {
>   gimple_stmt_iterator gsi;
> 
>   for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next ())
> {
>   gimple *stmt = gsi_stmt (gsi);
> 
>   if (is_gimple_debug (stmt))
> continue;
> 
>   if (gimple_has_side_effects (stmt)
>   || gimple_uses_undefined_value_p (stmt)
>   || gimple_could_trap_p (stmt)
>   || gimple_vuse (stmt)
>   /* const calls don't match any of the above, yet they could
>  still have some side-effects - they could contain
>  gimple_could_trap_p statements, like floating point
>  exceptions or integer division by zero.  See PR70586.
>  FIXME: perhaps gimple_has_side_effects or gimple_could_trap_p
>  should handle this.  */
>   || is_gimple_call (stmt))
> 
> and it is ifcombine pulling the call out of conditional context.

^^^ err, tail merging.  -fno-tree-tail-merge fixes the bug.

+find_duplicates:  duplicate of 
+Removing basic block 4
...
-   [local count: 536870912]:
   _6 = foo (0);
   iftmp.2_10 = (long int) _6;
-  goto ; [100.00%]
-
-   [local count: 536870912]:
-  iftmp.2_11 = (long int) 
-

[Bug tree-optimization/85859] [6/7/8/9 Regression] wrong code with -fno-isolate-erroneous-paths-dereference

2018-05-22 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85859

Richard Biener  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2018-05-22
   Target Milestone|--- |6.5
 Ever confirmed|0   |1

--- Comment #1 from Richard Biener  ---
Confirmed.  foo is discovered as 'const', it is nothrow anyways
(-fno-exceptions)
and thus overall it is considered not having side-effects (in particular not
trap).  Quoting tree-ssa-ifcombine.c:

/* Verify if the basic block BB does not have side-effects.  Return
   true in this case, else false.  */

static bool
bb_no_side_effects_p (basic_block bb)
{
  gimple_stmt_iterator gsi;

  for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next ())
{
  gimple *stmt = gsi_stmt (gsi);

  if (is_gimple_debug (stmt))
continue;

  if (gimple_has_side_effects (stmt)
  || gimple_uses_undefined_value_p (stmt)
  || gimple_could_trap_p (stmt)
  || gimple_vuse (stmt)
  /* const calls don't match any of the above, yet they could
 still have some side-effects - they could contain
 gimple_could_trap_p statements, like floating point
 exceptions or integer division by zero.  See PR70586.
 FIXME: perhaps gimple_has_side_effects or gimple_could_trap_p
 should handle this.  */
  || is_gimple_call (stmt))

and it is ifcombine pulling the call out of conditional context.