1 /* Demonstrates the aliasing problem with the z80 port when loop
2    induction is turned on.  Run_Index and Int_2_Loc get joined into
3    the same spill location.
4 
5    Stripped down version of dhry.c
6  */
7 
8 #include <testfwk.h>
9 
10 #define NOENUM		1
11 #define NOSTRUCTASSIGN	1
12 #define REG
13 
14 #define Ident_2 1
15 
16 typedef int   Enumeration;
17 
18 typedef int     One_Fifty;
19 typedef char    Capital_Letter;
20 
21 char            Ch_2_Glob;
22 
23 Enumeration Func_1 (Capital_Letter Ch_1_Par_Val, Capital_Letter Ch_2_Par_Val);
24 
25 void
testDhry(void)26 testDhry(void)
27 {
28     One_Fifty       Int_1_Loc;
29     REG   One_Fifty       Int_2_Loc;
30     One_Fifty       Int_3_Loc;
31     REG   Capital_Letter Ch_Index;
32     Enumeration     Enum_Loc;
33     REG   int             Run_Index;
34     REG   int             Number_Of_Runs;
35 
36     /* Must be more than 13... */
37     Number_Of_Runs = 50;
38 
39     /* Main test loop */
40     for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index) {
41 	Int_1_Loc = 2;
42 	Int_2_Loc = 3;
43 	Enum_Loc = Ident_2;
44 
45         /* Removing this section removes the problem. */
46 	while (Int_1_Loc < Int_2_Loc)
47 	    {
48 		Int_3_Loc = 5 * Int_1_Loc - Int_2_Loc;
49 		Int_1_Loc += 1;
50 	    }
51 
52         /* Removing this section removes the problem. */
53 	for (Ch_Index = 'A'; Ch_Index <= Ch_2_Glob; ++Ch_Index)
54 	    {
55 		if (Enum_Loc == Func_1 (Ch_Index, 'C'))
56 		    {
57 			Int_2_Loc = Run_Index;
58 		    }
59 	    }
60 
61         /* Removing any one of the following lines removes the problem. */
62 	Int_2_Loc = Int_2_Loc * Int_1_Loc;
63 	Int_1_Loc = Int_2_Loc / Int_3_Loc;
64 	Int_2_Loc = 7 * (Int_2_Loc - Int_3_Loc) - Int_1_Loc;
65     }
66 }
67 
Func_1(Capital_Letter Ch_1_Par_Val,Capital_Letter Ch_2_Par_Val)68 Enumeration Func_1 (Capital_Letter Ch_1_Par_Val, Capital_Letter Ch_2_Par_Val)
69 {
70     UNUSED(Ch_1_Par_Val);
71     UNUSED(Ch_2_Par_Val);
72 
73     return 0;
74 }
75