1 /* { dg-do compile } */
2 /* { dg-options "-O -fdump-tree-backprop-details" }  */
3 
4 void start (void *);
5 void end (void *);
6 
7 /* Test that we optimize the contents of infinite loops.  */
8 #define TEST_FUNCTION(TYPE, SUFFIX)			\
9   void							\
10   test##SUFFIX (TYPE *array, TYPE y, int n)		\
11   {							\
12     for (;;)						\
13       {							\
14 	start (array);					\
15 	TYPE x = -__builtin_fabs##SUFFIX (array[-1]);	\
16 	for (int i = 0; i < n; ++i)			\
17 	  x = -x / array[i];				\
18 	array[-1] = x * x;				\
19 	array[-2] = __builtin_fma##SUFFIX (x, x, y);	\
20 	array[-3] = __builtin_pow##SUFFIX (x, 20);	\
21 	end (array);					\
22       }							\
23   }
24 
25 TEST_FUNCTION (float, f)
26 TEST_FUNCTION (double, )
27 TEST_FUNCTION (long double, l)
28 
29 /* { dg-final { scan-tree-dump-times {Deleting[^\n]* = -} 6 "backprop" } } */
30 /* { dg-final { scan-tree-dump-times {Deleting[^\n]* = ABS_EXPR <} 3 "backprop" } } */
31