1  /* Check that the GBR address optimization does not produce wrong memory
       2     accesses.  In this case the GBR value must be stored to a normal register
       3     and a GBR memory access must not be done.  */
       4  /* { dg-do compile }  */
       5  /* { dg-options "-O1" } */
       6  /* { dg-final { scan-assembler "stc\tgbr" } } */
       7  /* { dg-final { scan-assembler "bf|bt" } } */
       8  
       9  typedef struct
      10  {
      11    int x, y, z, w;
      12  } tcb_t;
      13  
      14  int
      15  test_00 (int a, tcb_t* b)
      16  {
      17    tcb_t* tcb = (a & 5) ? (tcb_t*)__builtin_thread_pointer () : b;
      18    return tcb->w + tcb->x;
      19  }