(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
sh/
pr51244-14.c
       1  /* This is a case extracted from CSiBE which would sometimes contain the
       2     following sequence:
       3  	cmp/eq	r12,r13
       4  	movt	r0
       5  	xor	#1,r0
       6  	extu.b	r0,r0
       7  	movt	r3
       8  	tst	r0,r0
       9  	bf/s	.L35
      10     where the negated T bit store did not combine properly.  Since there are
      11     other movt insns and the sequence will try to utilize the 'movt_movrt'
      12     patterns, we only check for the extu.  */
      13  /* { dg-do compile }  */
      14  /* { dg-options "-O2" } */
      15  /* { dg-final { scan-assembler-not "extu" } } */
      16  
      17  typedef struct transaction_s transaction_t;
      18  
      19  struct journal_head
      20  {
      21    transaction_t * b_transaction;
      22    struct journal_head *b_cpnext, *b_cpprev;
      23  };
      24  
      25  struct transaction_s
      26  {
      27    struct journal_head * t_checkpoint_list;
      28    transaction_t *t_cpnext, *t_cpprev;
      29  };
      30  
      31  struct journal_s
      32  {
      33    transaction_t * j_checkpoint_transactions;
      34    unsigned long j_first, j_last;
      35  };
      36  
      37  typedef struct journal_s journal_t;
      38  
      39  extern int __try_to_free_cp_buf (struct journal_head *jh);
      40  extern int __cleanup_transaction (journal_t *journal, transaction_t *transaction);
      41  extern void __flush_batch (void **bhs, int *batch_count);
      42  extern void* jh2bh (void*);
      43  
      44  static int
      45  __flush_buffer (journal_t *journal, struct journal_head *jh,
      46  		void **bhs, int *batch_count, int *drop_count)
      47  {
      48    void *bh = jh2bh (jh);
      49    int ret = 0;
      50    if (bh)
      51      {
      52        bhs[*batch_count] = bh;
      53        (*batch_count)++;
      54        if (*batch_count == 64)
      55  	  ret = 1;
      56      }
      57    else
      58      {
      59        int last_buffer = 0;
      60        if (jh->b_cpnext == jh)
      61  	last_buffer = 1;
      62        if (__try_to_free_cp_buf (jh))
      63  	{
      64  	  (*drop_count)++;
      65  	  ret = last_buffer;
      66  	}
      67      }
      68    return ret;
      69  }
      70  
      71  int
      72  log_do_checkpoint (journal_t *journal, int nblocks)
      73  {
      74    transaction_t *transaction, *last_transaction, *next_transaction;
      75    int batch_count = 0;
      76    void *bhs[64];
      77  
      78  repeat:
      79    transaction = journal->j_checkpoint_transactions;
      80    if (transaction == ((void *)0))
      81      return 0;
      82    last_transaction = transaction->t_cpprev;
      83    next_transaction = transaction;
      84    do
      85      {
      86        struct journal_head *jh, *last_jh, *next_jh;
      87        int drop_count = 0;
      88        int cleanup_ret, retry = 0;
      89        transaction = next_transaction;
      90        next_transaction = transaction->t_cpnext;
      91        jh = transaction->t_checkpoint_list;
      92        last_jh = jh->b_cpprev;
      93        next_jh = jh;
      94        do
      95  	{
      96  	  jh = next_jh;
      97  	  next_jh = jh->b_cpnext;
      98  	  retry = __flush_buffer(journal, jh, bhs, &batch_count, &drop_count);
      99  	} while (jh != last_jh && !retry);
     100  
     101        if (retry)
     102  	goto repeat;
     103  
     104        cleanup_ret = __cleanup_transaction(journal, transaction);
     105        goto repeat;
     106      } while (transaction != last_transaction);
     107  }