1  /* Test LOOP generation for very short loops. */
       2  
       3  /* { dg-do run } */
       4  /* { dg-options "-O1 -mloop" } */
       5  
       6  /* -O1 in the options is significant.  Without it do-loop will not be
       7     run.  */
       8  
       9  extern void abort (void);
      10  
      11  volatile unsigned int int_12345 = 12345;
      12  volatile unsigned int int_0 = 0;
      13  volatile unsigned int int_1 = 1;
      14  
      15  unsigned int
      16  test_loop_sum (unsigned int n)
      17  {
      18  	unsigned i;
      19  	volatile unsigned int s = 0;
      20  	for (i = 0; i < n; i++) {
      21  		s++;
      22  	}
      23  	return s;
      24  }
      25  
      26  unsigned int
      27  test_loop_shift20 (unsigned int n)
      28  {
      29  	unsigned i;
      30  	for (i = 0; i < 10; i++) {
      31  		n <<= 2;
      32  	}
      33  	return n;
      34  }
      35  
      36  int
      37  main (int argc, char** argv)
      38  {
      39    if (test_loop_sum (int_0) != 0)
      40      abort();
      41    if (test_loop_sum (int_1) != 1)
      42      abort();
      43    if (test_loop_sum (int_12345) != 12345)
      44      abort();
      45  
      46    if (test_loop_shift20 (int_0) != 0)
      47      abort();
      48    if (test_loop_shift20 (int_1) != (1u << 20))
      49      abort();
      50  
      51    return 0;
      52  }
      53