(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
sh/
pr51244-13.c
       1  /* This is a case extracted from CSiBE which contained the following
       2     sequence:
       3  	shll	r0
       4  	movt	r0
       5  	tst	r0,r0
       6  	bf	.L11
       7     where the 'tst r0,r0' before the branch can be omitted by inverting the
       8     branch condition.  The tested function contains two other tst insns.  If
       9     everything goes as expected we will be seeing only those other two tst
      10     insns.  */
      11  /* { dg-do compile }  */
      12  /* { dg-options "-O2" } */
      13  /* { dg-final { scan-assembler-times "tst" 2 } } */
      14  
      15  void printk (const char*, const char*, int);
      16  void __constant_set_bit (int, unsigned long int*);
      17  void __set_bit (int, unsigned long int*);
      18  
      19  static __inline__ int
      20  __test_bit (unsigned long nr, volatile void * addr)
      21  {
      22    /*  This is on purpose.  */
      23    int oldbit;
      24    return oldbit & 1;
      25  }
      26  
      27  static __inline__ int
      28  __constant_test_bit (unsigned long nr, volatile void * addr)
      29  {
      30    return (((volatile char *) addr)[(nr>>3)^7] & (1<<(nr&7))) != 0;
      31  }
      32  
      33  struct list_head
      34  {
      35    struct list_head *next, *prev;
      36  };
      37  
      38  void list_add (struct list_head*, struct list_head*);
      39  
      40  static inline void
      41  __list_del (struct list_head *prev, struct list_head *next)
      42  {
      43    next->prev = prev;
      44    prev->next = next;
      45  }
      46  
      47  static inline void
      48  list_del (struct list_head *entry)
      49  {
      50   __list_del(entry->prev, entry->next);
      51   entry->next = 0;
      52   entry->prev = 0;
      53  }
      54  
      55  extern int nr_active_pages;
      56  extern int nr_inactive_pages;
      57  extern struct list_head active_list;
      58  
      59  typedef struct page
      60  {
      61   unsigned long flags;
      62   struct list_head lru;
      63  } mem_map_t;
      64  
      65  void
      66  activate_page_nolock (struct page * page)
      67  {
      68   if ((__builtin_constant_p((6))
      69        ? __constant_test_bit((6),(&(page)->flags))
      70        : __test_bit((6),(&(page)->flags)) )
      71       && !(__builtin_constant_p((7))
      72            ? __constant_test_bit((7),(&(page)->flags))
      73            : __test_bit((7),(&(page)->flags)) ))
      74      {
      75        list_del(&(page)->lru);
      76        nr_inactive_pages--;
      77        if (!(__builtin_constant_p(6) ? __constant_test_bit((6),(&(page)->flags))
      78  				    : __test_bit((6),(&(page)->flags))))
      79  	printk("", "", 43);
      80  
      81        if ((__builtin_constant_p(7) ? __constant_test_bit((7),(&(page)->flags))
      82  				   : __test_bit((7),(&(page)->flags))))
      83  	printk("", "", 43);
      84  
      85        (__builtin_constant_p(7) ? __constant_set_bit((7),(&(page)->flags))
      86  			        : __set_bit((7),(&(page)->flags)) );
      87        list_add(&(page)->lru, &active_list);
      88        nr_active_pages++;
      89      }
      90  }