blob: 5f4f85e728aa6b84e66a4a6f91e284b37d2469f5 (
plain)
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
|
/* Test arithmetic CSE with /+-*
type: char, short, long
attr: volatile,
*/
#include <testfwk.h>
void
test_arithCse(void)
{
{attr} {type} res;
{attr} {type} i = 10;
/* addition with 0 */
res = i + 0;
ASSERT (i == 10);
res = 0 + i;
ASSERT (res == 10);
/* multiplication with 1 */
res = 1 * i;
ASSERT (res == 10);
res = i * 1;
ASSERT (res == 10);
/* multiplication with 0 */
res = 0 * i;
ASSERT (res == 0);
res = i * 0;
ASSERT (res == 0);
/* multiplication with -1 */
res = -1 * i;
ASSERT (res == ({type})-i);
res = i * -1;
ASSERT (res == ({type})-i);
/* division by 1 */
res = i / 1;
ASSERT (res == i);
/* division by -1 */
res = i / -1;
ASSERT (res == ({type})-i);
}
|