swar-c99-6.8.5.3-for_stmt.c
2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* -----------------------------------------------------------------------------
* Copyright (C) 2018-2020 daiteq s.r.o. http://www.daiteq.com
*
* This program is distributed WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE.
*
* -----------------------------------------------------------------------------
* Filename : swar-c99-6.8.5.3-for_stmt.c
* Authors : Roman Bartosinski
* Description : simple test of clang/LLVM compiler with SWAR extension
* Release :
* Version :
* Date :
* -----------------------------------------------------------------------------
*/
//A: --has-swar
//C: -daiteq-swar-enable
#define SWAR_USE_UNSIGNED_TYPES
#define SWAR_USE_SIGNED_TYPES
#include "swar-c99.h"
// iteration statements: while, do-while, for
#define ARRAYSIZE 20
su10x3b v3u[ARRAYSIZE] = {
{0,1,2,3,4,5,6,7,0,1},
{0,1,2,3,4,0,1,2,3,4},
{1,1,1,4,4,4,4,7,7,7},
{7,6,5,4,3,2,1,0,7,6},
{0,0,0,0,0,0,0,0,0,0},
{1,1,1,1,1,1,1,1,1,1},
{2,2,2,2,2,2,2,2,2,2},
{3,3,3,3,3,3,3,3,3,3},
{4,4,4,4,4,4,4,4,4,4},
{5,5,5,5,5,5,5,5,5,5},
{6,6,6,6,6,6,6,6,6,6},
{7,7,7,7,7,7,7,7,7,7},
{0,0,0,0,0,0,0,0,0,0},
{1,1,1,1,1,1,1,1,1,1},
{2,2,2,2,2,2,2,2,2,2},
{3,3,3,3,3,3,3,3,3,3},
{4,4,4,4,4,4,4,4,4,4},
{5,5,5,5,5,5,5,5,5,5},
{6,6,6,6,6,6,6,6,6,6},
{7,7,7,7,7,7,7,7,7,7},
};
su10x3b accum10x3u = {0};
su10x3b gv10x3u[ARRAYSIZE];
ss32x1b var32x1s;
int uno(void)
{
int i = 0;
while(i<ARRAYSIZE) {
accum10x3u += v3u[i];
i++;
}
// int rc = *((int *)&accum10x3u);
int rc = 0;
return rc;
}
//int due(void)
//{
//su10x3b t = v3u[0];
//int i = 0;
//int rc = 0;
//while(i<10) {
//// rc += t[i]; /* not supported in LLVM:IR [i32]=[i32]+[i3] */
//rc += (int)t[i]; /* allowed */
//i++;
//}
//return rc;
//}
//int tre(void)
//{
//accum10x3u = 0;
//for(int i=0;i<ARRAYSIZE;++i) {
//accum10x3u += v3u[i];
//}
//return 0;
//}
//int quattro(void)
//{
//su10x3b var3b = 0x12345678;
//for(int i=0;i<ARRAYSIZE;++i)
//gv10x3u[i] = v3u[i] + var3b;
//return 0;
//}
int main(void)
{
uno();
//due();
//tre();
//quattro();
return 0;
}