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-skip-if "" { "sh*-*-*" } { "-m5*" } { "" } } */ 18/* { dg-final { scan-assembler-not "movt|tst" } } */ 19 20typedef char Char; 21typedef unsigned char Bool; 22typedef unsigned char UChar; 23typedef int Int32; 24typedef unsigned int UInt32; 25typedef short Int16; 26typedef unsigned short UInt16; 27 28static inline Bool 29mainGtU (UInt32 i1, UInt32 i2, UChar* block, UInt16* quadrant, UInt32 nblock, 30 Int32* budget) 31{ 32 Int32 k; 33 UChar c1, c2; 34 UInt16 s1, s2; 35 k = nblock + 8; 36 do 37 { 38 c1 = block[i1]; 39 c2 = block[i2]; 40 if (c1 != c2) 41 return (c1 > c2); 42 s1 = quadrant[i1]; 43 s2 = quadrant[i2]; 44 if (s1 != s2) 45 return (s1 > s2); 46 47 i1++; i2++; 48 k -= 8; 49 } while (k >= 0); 50 51 return 0; 52} 53 54static inline void 55mainSimpleSort (UInt32* ptr, UChar* block, UInt16* quadrant, Int32 nblock, 56 Int32 lo, Int32 hi, Int32 d, Int32* budget) 57{ 58 Int32 i, j, h, bigN, hp; 59 UInt32 v; 60 bigN = hi - lo + 1; 61 hp = 0; 62 h = 1; 63 j = lo + h; 64 v = ptr[j]; 65 66 while (mainGtU (ptr[j-h]+d, v+d, block, quadrant, nblock, budget)) 67 { 68 ptr[j] = ptr[j-h]; 69 j = j - h; 70 } 71} 72 73static inline void 74mainQSort3 (UInt32* ptr, UChar* block, UInt16* quadrant, Int32 nblock, 75 Int32 loSt, Int32 hiSt, Int32 dSt, Int32* budget) 76{ 77 Int32 unLo, unHi, ltLo, gtHi; 78 Int32 sp, lo, hi, d; 79 80 Int32 stackLo[100]; 81 Int32 stackHi[100]; 82 Int32 stackD [100]; 83 84 sp = 0; 85 stackLo[sp] = loSt; 86 stackHi[sp] = hiSt; 87 stackD [sp] = dSt; 88 lo = stackLo[sp]; 89 hi = stackHi[sp]; 90 d = stackD [sp]; 91 mainSimpleSort (ptr, block, quadrant, nblock, lo, hi, d, budget); 92} 93 94void 95mainSort (UInt32* ptr, UChar* block, UInt16* quadrant, UInt32* ftab, 96 Int32 nblock, Int32 verb, Int32* budget) 97{ 98 Int32 sb = 0; 99 Int32 lo = ftab[sb] & (~((1 << 21))); 100 Int32 hi = (ftab[sb+1] & (~((1 << 21)))) - 1; 101 mainQSort3 (ptr, block, quadrant, nblock, lo, hi, 2, budget); 102} 103