1/* Copyright (C) 2003 Free Software Foundation. 2 PR target/13256 3 STRICT_LOW_PART was handled incorrectly in delay slots. 4 Origin: Hans-Peter Nilsson. */ 5 6typedef struct { unsigned int e0 : 16; unsigned int e1 : 16; } s1; 7typedef struct { unsigned int e0 : 16; unsigned int e1 : 16; } s2; 8typedef struct { s1 i12; s2 i16; } io; 9static int test_length = 2; 10static io *i; 11static int m = 1; 12static int d = 1; 13static unsigned long test_t0; 14static unsigned long test_t1; 15void test(void) __attribute__ ((__noinline__)); 16extern int f1 (void *port) __attribute__ ((__noinline__)); 17extern void f0 (void) __attribute__ ((__noinline__)); 18int 19f1 (void *port) 20{ 21 int fail_count = 0; 22 unsigned long tlen; 23 s1 x0 = {0}; 24 s2 x1 = {0}; 25 26 i = port; 27 x0.e0 = x1.e0 = 32; 28 i->i12 = x0; 29 i->i16 = x1; 30 do f0(); while (test_t1); 31 x0.e0 = x1.e0 = 8; 32 i->i12 = x0; 33 i->i16 = x1; 34 test (); 35 if (m) 36 { 37 unsigned long e = 1000000000 / 460800 * test_length; 38 tlen = test_t1 - test_t0; 39 if (((tlen-e) & 0x7FFFFFFF) > 1000) 40 f0(); 41 } 42 if (d) 43 { 44 unsigned long e = 1000000000 / 460800 * test_length; 45 tlen = test_t1 - test_t0; 46 if (((tlen - e) & 0x7FFFFFFF) > 1000) 47 f0(); 48 } 49 return fail_count != 0 ? 1 : 0; 50} 51 52int 53main () 54{ 55 io io0; 56 f1 (&io0); 57 abort (); 58} 59 60void 61test (void) 62{ 63 io *iop = i; 64 if (iop->i12.e0 != 8 || iop->i16.e0 != 8) 65 abort (); 66 exit (0); 67} 68 69void 70f0 (void) 71{ 72 static int washere = 0; 73 io *iop = i; 74 if (washere++ || iop->i12.e0 != 32 || iop->i16.e0 != 32) 75 abort (); 76} 77