1  /* PR opt/6722 */
       2  /* { dg-do run } */
       3  /* { dg-options "-O2" } */
       4  
       5  /* We need this type to be as wide as the register chosen below, so
       6     that, when we preserve it across main, we preserve all of it.  */
       7  typedef int __attribute__ ((mode (__word__))) reg_type;
       8  
       9  #if !__PIC__
      10  register reg_type k asm("%ebx");
      11  #elif __amd64
      12  register reg_type k asm("%r12");
      13  #else
      14  register reg_type k asm("%esi");
      15  #endif
      16  
      17  void __attribute__((noinline))
      18  foo()
      19  {
      20    k = 1;
      21  }
      22  
      23  void test()
      24  {
      25    reg_type i;
      26    for (i = 0; i < 10; i += k)
      27      {
      28        k = 0;
      29        foo();
      30      }
      31  }
      32  
      33  int main()
      34  {
      35    reg_type old = k;
      36    test();
      37    k = old;
      38    return 0;
      39  }