(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
sh/
pr51244-18.c
       1  /* Check that no unnecessary T bit stores are done before conditional
       2     branches.
       3     This case was extracted from the CSiBE set and contained the following
       4     sequence:
       5  	cmp/hi	r1,r0
       6  	movt	r1
       7  	tst	r1,r1
       8  	bt	.L12
       9  	mov.l	@r10,r1
      10     In this reduced code the movt and tst insns were only present in the
      11     unwanted sequence.  Thus, if we see any tst or movt insns, something is
      12     not working as expected.  This test requires -O2 because the T bit stores
      13     in question will be eliminated in additional insn split passes after
      14     reload.  */
      15  /* { dg-do compile }  */
      16  /* { dg-options "-O2" } */
      17  /* { dg-final { scan-assembler-not "movt|tst" } } */
      18  
      19  typedef char Char;
      20  typedef unsigned char Bool;
      21  typedef unsigned char UChar;
      22  typedef int Int32;
      23  typedef unsigned int UInt32;
      24  typedef short Int16;
      25  typedef unsigned short UInt16;
      26  
      27  static inline Bool
      28  mainGtU (UInt32 i1, UInt32 i2, UChar* block, UInt16* quadrant, UInt32 nblock,
      29  	 Int32* budget)
      30  {
      31    Int32 k;
      32    UChar c1, c2;
      33    UInt16 s1, s2;
      34    k = nblock + 8;
      35    do
      36      {
      37        c1 = block[i1];
      38        c2 = block[i2];
      39        if (c1 != c2)
      40  	return (c1 > c2);
      41        s1 = quadrant[i1];
      42        s2 = quadrant[i2];
      43        if (s1 != s2)
      44  	return (s1 > s2);
      45  
      46        i1++; i2++;
      47        k -= 8;
      48     } while (k >= 0);
      49  
      50    return 0;
      51  }
      52  
      53  static inline void
      54  mainSimpleSort (UInt32* ptr, UChar* block, UInt16* quadrant, Int32 nblock,
      55  		Int32 lo, Int32 hi, Int32 d, Int32* budget)
      56  {
      57    Int32 i, j, h, bigN, hp;
      58    UInt32 v;
      59    bigN = hi - lo + 1;
      60    hp = 0;
      61    h = 1;
      62    j = lo + h;
      63    v = ptr[j];
      64  
      65    while (mainGtU (ptr[j-h]+d, v+d, block, quadrant, nblock, budget))
      66      {
      67        ptr[j] = ptr[j-h];
      68        j = j - h;
      69      }
      70  }
      71  
      72  static inline void
      73  mainQSort3 (UInt32* ptr, UChar* block, UInt16* quadrant, Int32 nblock,
      74  	    Int32 loSt, Int32 hiSt, Int32 dSt, Int32* budget)
      75  {
      76    Int32 unLo, unHi, ltLo, gtHi;
      77    Int32 sp, lo, hi, d;
      78  
      79    Int32 stackLo[100];
      80    Int32 stackHi[100];
      81    Int32 stackD [100];
      82  
      83    sp = 0;
      84    stackLo[sp] = loSt;
      85    stackHi[sp] = hiSt;
      86    stackD [sp] = dSt;
      87    lo = stackLo[sp];
      88    hi = stackHi[sp];
      89    d = stackD [sp];
      90    mainSimpleSort (ptr, block, quadrant, nblock, lo, hi, d, budget);
      91  }
      92  
      93  void
      94  mainSort (UInt32* ptr, UChar* block, UInt16* quadrant, UInt32* ftab,
      95  	  Int32 nblock, Int32 verb, Int32* budget)
      96  {
      97    Int32 sb = 0;
      98    Int32 lo = ftab[sb] & (~((1 << 21)));
      99    Int32 hi = (ftab[sb+1] & (~((1 << 21)))) - 1;
     100    mainQSort3 (ptr, block, quadrant, nblock, lo, hi, 2, budget);
     101  }