1 /*
2 mode-dependent-address.c from the execute part of the gcc torture tests.
3 */
4 
5 #include <testfwk.h>
6 
7 /* { dg-require-effective-target stdint_types } */
8 
9 #include <stdint.h>
10 #include <string.h>
11 #include <stdlib.h>
12 
13 #if !(defined(__SDCC_mcs51) && (defined(__SDCC_MODEL_SMALL) || defined(__SDCC_MODEL_MEDIUM))) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
f883b(int8_t * result,int16_t * restrict arg1,uint32_t * restrict arg2,uint64_t * restrict arg3,uint8_t * restrict arg4)14 void f883b (int8_t * result,
15     int16_t * restrict arg1,
16     uint32_t * restrict arg2,
17     uint64_t * restrict arg3,
18     uint8_t * restrict arg4)
19 {
20     int idx;
21     for (idx=0;idx<96;idx += 1) {
22 	result[idx] = (((((((((((-27 + 2+1)>>1) || arg4[idx]) < arg1[idx])
23 				? (((-27 + 2+1)>>1) || arg4[idx])
24 				: arg1[idx])
25 			       >> (arg2[idx] & 31)) ^ 1) - -32)>>7) | -5) & arg3[idx]);
26     }
27 }
28 
29 int8_t result[96];
30 int16_t arg1[96];
31 uint32_t arg2[96];
32 uint64_t arg3[96];
33 uint8_t arg4[96];
34 #endif
35 
36 void
testTortureExecute(void)37 testTortureExecute (void)
38 {
39 #if !(defined(__SDCC_mcs51) && (defined(__SDCC_MODEL_SMALL) || defined(__SDCC_MODEL_MEDIUM))) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
40   int i;
41   int correct[] = {0x0,0x1,0x2,0x3,0x0,0x1,0x2,0x3,0x8,0x9,0xa,0xb,0x8,0x9,
42                    0xa,0xb,0x10,0x11,0x12,0x13,0x10,0x11,0x12,0x13,
43                    0x18,0x19,0x1a,0x1b,0x18,0x19,0x1a,0x1b,0x20,0x21,0x22,
44                    0x23,0x20,0x21,0x22,0x23,0x28,0x29,0x2a,
45                    0x2b,0x28,0x29,0x2a,0x2b,0x30,0x31,0x32,0x33,
46                    0x30,0x31,0x32,0x33,0x38,0x39,0x3a,0x3b,0x38,0x39,0x3a,
47                    0x3b,0x40,0x41,0x42,0x43,0x40,0x41,0x42,0x43,0x48,0x49,
48                    0x4a,0x4b,0x48,0x49,0x4a,0x4b,0x50,0x51,
49                    0x52,0x53,0x50,0x51,0x52,0x53,0x58,0x59,0x5a,0x5b,
50                    0x58,0x59,0x5a,0x5b};
51 
52   for (i=0; i < 96; i++)
53     arg3[i] = arg2[i] = arg1[i] = arg4[i] = i;
54 
55   f883b(result, arg1, arg2, arg3, arg4);
56 
57   for (i=0; i < 96; i++)
58     if (result[i] != correct[i]) ASSERT(0);
59 #endif
60   return;
61 }
62