summaryrefslogtreecommitdiff
path: root/support/regression/tests/patch-466.c
blob: 4307af06c1cfaf79405594130e40e0ffefa0f771 (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
/*
   patch-466.c - tests for some peephole optimizer rules from patch #466
   to optimize theuse of MCs-51 bit instructions.
 */
 
#include <testfwk.h>

#include <stdint.h>
#include <stdbool.h>

uint8_t aaa;
uint8_t bbb;

uint8_t get_bleh (uint8_t x)
{
  bool x0 = x != aaa;
  bool x1 = x != bbb;

  return (!x0 | !x1) ? 0xFF : 0x00;
}

void testPatch(void)
{
  aaa = 0;
  bbb = 0;
  ASSERT (get_bleh (0) == 0xff);
  ASSERT (get_bleh (1) == 0x00);

  aaa = 0;
  bbb = 1;
  ASSERT (get_bleh (0) == 0xff);
  ASSERT (get_bleh (1) == 0xff);

  aaa = 1;
  bbb = 0;
  ASSERT (get_bleh (0) == 0xff);
  ASSERT (get_bleh (1) == 0xff);

  aaa = 1;
  bbb = 1;
  ASSERT (get_bleh (0) == 0x00);
  ASSERT (get_bleh (1) == 0xff);
}