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

Richard Biener <rguenth at gcc dot gnu.org> 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 <rguenth at gcc dot gnu.org> ---
(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 (&gsi))
>     {
>       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: <bb 3> duplicate of <bb 4>
+Removing basic block 4
...
-  <bb 3> [local count: 536870912]:
   _6 = foo (0);
   iftmp.2_10 = (long int) _6;
-  goto <bb 5>; [100.00%]
-
-  <bb 4> [local count: 536870912]:
-  iftmp.2_11 = (long int) &c;
-

Reply via email to