(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
pr34263.c
       1  /* { dg-do run } */
       2  /* { dg-options "-O2 -fdump-tree-optimized" } */
       3  /* Same test as 990128-1.c.  */
       4  
       5  extern int printf (const char *,...);
       6  extern void abort (void);
       7  
       8  struct s { struct s *n; } *p;
       9  struct s ss;
      10  #define MAX     10
      11  struct s sss[MAX];
      12  int count = 0;
      13  
      14  void sub( struct s *p, struct s **pp );
      15  int look( struct s *p, struct s **pp );
      16  
      17  int
      18  main()
      19  {
      20      struct s *pp;
      21      struct s *next;
      22      int i;
      23  
      24      p = &ss;
      25      next = p;
      26      for ( i = 0; i < MAX; i++ ) {
      27          next->n = &sss[i];
      28          next = next->n;
      29      }
      30      next->n = 0;
      31  
      32      sub( p, &pp );
      33      if (count != MAX+2)
      34        abort ();
      35  
      36      return( 0 );
      37  }
      38  
      39  void sub( struct s *p, struct s **pp )
      40  {
      41     for ( ; look( p, pp ); ) {
      42          if ( p )
      43              p = p->n;
      44          else
      45              break;
      46     }
      47  }
      48  
      49  int look( struct s *p, struct s **pp )
      50  {
      51      for ( ; p; p = p->n )
      52          ;
      53      *pp = p;
      54      count++;
      55      return( 1 );
      56  }
      57  
      58  /* { dg-final { scan-tree-dump "Cleaned-up latch block of loop with single BB" "optimized" { xfail { *-*-* } } } } */
      59