summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug-2982.c
blob: 1ce29c36b76e33928a6970a9842eb47e6f5cfc57 (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
/* bug-2982.c
   A bug in the z80 peephole optimizer.
 */

#include <testfwk.h>

#pragma disable_warning 85

static int L, STEP;

void Basic_PRINT(int i)
{
  ASSERT (i == 36);
}

signed char Basic_RND(char a)
{
  return 51;
}

int f(int argc, char **argv)
{
    STEP = Basic_RND(0);
    do {
        // A load of L into register pair de got optimized out, though it was still needed for the calculation of L + 50
        Basic_PRINT((L + 50) / 100);
        L += STEP;
    } while (!(L > 3600));
}

void testBug(void)
{
	L = 3550;
	f(0, 0);
}