1 /* { dg-do compile } */ 2 /* { dg-options "-O2 -fdump-tree-forwprop1" } */ 3 4 typedef __SIZE_TYPE__ size_t; 5 typedef __PTRDIFF_TYPE__ ptrdiff_t; 6 foo1(char * a,size_t n)7ptrdiff_t foo1 (char *a, size_t n) 8 { 9 char *b1 = a + 8 * n; 10 char *b2 = a + 8 * (n - 1); 11 12 return b1 - b2; 13 } 14 15 int use_ptr (char *a, char *b); 16 foo2(char * a,size_t n)17ptrdiff_t foo2 (char *a, size_t n) 18 { 19 char *b1 = a + 8 * (n - 1); 20 char *b2 = a + 8 * n; 21 22 use_ptr (b1, b2); 23 24 return b1 - b2; 25 } 26 27 int use_int (int i); 28 goo(unsigned m_param,unsigned n_param)29unsigned goo (unsigned m_param, unsigned n_param) 30 { 31 unsigned b1 = m_param * (n_param + 2); 32 unsigned b2 = m_param * (n_param + 1); 33 int r = (int)(b1) - (int)(b2); 34 35 use_int (r); 36 37 return r; 38 } 39 40 /* { dg-final { scan-tree-dump-times "return 8;" 1 "forwprop1" } } */ 41 /* { dg-final { scan-tree-dump-times "return -8;" 1 "forwprop1" } } */ 42 /* { dg-final { scan-tree-dump-times "return m_param" 1 "forwprop1" } } */ 43