Extracted from what tree-ssa/20030731-2.c probably really wanted to test:

/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized" } */

int offset;

extern void foo (void);

void
bar (int i, int partial, int args_addr)
{
  offset = 0;
  if (args_addr == 0)
    offset = 0;
  if (i >= offset)
    foo ();
}

/* There should be only one IF conditional since the first does nothing
   useful.  */
/* { dg-final { scan-tree-dump-times "if " 1 "optimized"} } */
/* { dg-final { cleanup-tree-dump "optimized" } } */


SCCVN figures the load from offset is zero so DSE is left with

<bb 2>:
  offset = 0;
  if (args_addr_1(D) == 0)
    goto <bb 3>;
  else
    goto <bb 4>;

<bb 3>:
  offset = 0;

<bb 4>:

where it should figure that the store to offset in BB3 is redundant.

This works later on the RTL level.


-- 
           Summary: DSE not removing redundant stores
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: missed-optimization, TREE
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rguenth at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35692

Reply via email to