Imported Upstream version 2.9.0
[debian/cc1111] / support / regression / tests / arithcse.c
1 /* Test arithmetic CSE with /+-*
2
3     type: char, short, long
4     attr: volatile,
5  */
6
7 #include <testfwk.h>
8
9 void
10 test_arithCse(void)
11 {
12   {attr} {type} res;
13   {attr} {type} i = 10;
14
15   /* addition with 0 */
16   res = i + 0;
17   ASSERT (i == 10);
18
19   res = 0 + i;
20   ASSERT (res == 10);
21
22   /* multiplication with 1 */
23   res = 1 * i;
24   ASSERT (res == 10);
25
26   res = i * 1;
27   ASSERT (res == 10);
28
29   /* multiplication with 0 */
30   res = 0 * i;
31   ASSERT (res == 0);
32
33   res = i * 0;
34   ASSERT (res == 0);
35
36   /* multiplication with -1 */
37   res = -1 * i;
38   ASSERT (res == -i);
39
40   res = i * -1;
41   ASSERT (res == -i);
42
43   /* division by 1 */
44   res = i / 1;
45   ASSERT (res == i);
46
47   /* division by -1 */
48   res = i / -1;
49   ASSERT (res == -i);
50 }