xref: /illumos-gate/usr/src/tools/smatch/src/validation/optim/canonical-add.c (revision 689b9301078f0c35c7f198fcee8032a0d30eff3a)
1 int xpc_add_ypc(int x, int y)
2 {
3 	return (x + 1) + (y + 1);
4 }
5 
6 int xmc_add_ypc(int x, int y)
7 {
8 	return (x - 1) + (y + 1);
9 }
10 
11 int xpc_add_ymc(int x, int y)
12 {
13 	return (x + 1) + (y - 1);
14 }
15 
16 int xmc_add_ymc(int x, int y)
17 {
18 	return (x - 1) + (y - 1);
19 }
20 
21 int xpc_sub_ypc(int x, int y)
22 {
23 	return (x + 1) - (y + 1);
24 }
25 
26 int xmc_sub_ypc(int x, int y)
27 {
28 	return (x - 1) - (y + 1);
29 }
30 
31 int xpc_sub_ymc(int x, int y)
32 {
33 	return (x + 1) - (y - 1);
34 }
35 
36 int xmc_sub_ymc(int x, int y)
37 {
38 	return (x - 1) - (y - 1);
39 }
40 
41 /*
42  * check-name: canonical-add
43  * check-description:
44  *	1) verify that constants in add/sub chains are
45  *	   pushed at the right of the whole chain.
46  *	   For example '(a + 1) + b' must be canonicalized into '(a + b) + 1'
47  *	   This is needed for '(a + 1) + b - 1' to be simplified into '(a + b)'
48  *
49  * check-command: test-linearize -Wno-decl $file
50  * check-known-to-fail
51  * check-output-ignore
52 
53  * check-output-excludes: \\$1
54  * check-output-excludes: \\$-1
55  */
56