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 main()17main() 18 { 19 struct s *pp; 20 struct s *next; 21 int i; 22 23 p = &ss; 24 next = p; 25 for ( i = 0; i < MAX; i++ ) { 26 next->n = &sss[i]; 27 next = next->n; 28 } 29 next->n = 0; 30 31 sub( p, &pp ); 32 if (count != MAX+2) 33 abort (); 34 35 return( 0 ); 36 } 37 sub(struct s * p,struct s ** pp)38void sub( struct s *p, struct s **pp ) 39 { 40 for ( ; look( p, pp ); ) { 41 if ( p ) 42 p = p->n; 43 else 44 break; 45 } 46 } 47 look(struct s * p,struct s ** pp)48int look( struct s *p, struct s **pp ) 49 { 50 for ( ; p; p = p->n ) 51 ; 52 *pp = p; 53 count++; 54 return( 1 ); 55 } 56 57 /* { dg-final { scan-tree-dump "Cleaned-up latch block of loop with single BB" "optimized" { xfail { *-*-* } } } } */ 58 /* { dg-final { cleanup-tree-dump "optimized" } } */ 59 60