aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-ssa/fold-xor-or.c
blob: 51b7373af0d869f9f6a8c13e6196f9ca4ec9b3d5 (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
45
46
47
48
49
50
51
52
53
54
55
/* { dg-do compile } */
/* { dg-options "-O3 -fdump-tree-optimized --param logical-op-non-short-circuit=1" } */

typedef unsigned long int uint64_t;

int cmp1(int d1, int d2) {
  if ((d1 ^ d2) == 0xabcd || d1 != d2)
    return 0;
  return 1;
}

int cmp2(int d1, int d2) {
  if (d1 != d2 || (d1 ^ d2) == 0xabcd)
    return 0;
  return 1;
}

int cmp3(int d1, int d2) {
  if (0xabcd > (d2 ^ d1) || d2 != d1)
    return 0;
  return 1;
}

int cmp4(int d1, int d2) {
  if (d2 != d1 || 0xabcd > (d2 ^ d1))
    return 0;
  return 1;
}

int cmp1_64(uint64_t d1, uint64_t d2) {
  if ((d1 ^ d2) == 0xabcd || d1 != d2)
    return 0;
  return 1;
}

int cmp2_64(uint64_t d1, uint64_t d2) {
  if (d1 != d2 || (d1 ^ d2) == 0xabcd)
    return 0;
  return 1;
}

int cmp3_64(uint64_t d1, uint64_t d2) {
  if (0xabcd > (d2 ^ d1) || d2 != d1)
    return 0;
  return 1;
}

int cmp4_64(uint64_t d1, uint64_t d2) {
  if (d2 != d1 || 0xabcd > (d2 ^ d1))
    return 0;
  return 1;
}

/* The if should be removed, so the condition should not exist */
/* { dg-final { scan-tree-dump-not "d1_\[0-9\]+.D. \\^ d2_\[0-9\]+.D." "optimized" } } */