blob: cdba5d623af421ab17e60b57feeadc3f75351390 (
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
|
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized-raw" } */
int g(int x, int y)
{
int xp = ~x;
return (x | y) & (xp ^ y); // x & y
}
int g0(int x, int y)
{
int xp = ~x;
return (xp | y) & (x ^ y); // ~x & y
}
_Bool gb(_Bool x, _Bool y)
{
_Bool xp = !x;
return (x | y) & (xp ^ y); // x & y
}
_Bool gb0(_Bool x, _Bool y)
{
_Bool xp = !x;
return (xp | y) & (x ^ y); // !x & y
}
_Bool gbi(int a, int b)
{
_Bool x = a < 2;
_Bool y = b < 3;
_Bool xp = !x;
return (x | y) & (xp ^ y); // x & y
}
_Bool gbi0(int a, int b)
{
_Bool x = a < 2;
_Bool y = b < 3;
_Bool xp = !x;
return (xp | y) & (x ^ y); // !x & y
}
/* All of these should be optimized to `x & y` or `~x & y` */
/* { dg-final { scan-tree-dump-times "le_expr, " 3 "optimized" } } */
/* { dg-final { scan-tree-dump-times "gt_expr, " 1 "optimized" } } */
/* { dg-final { scan-tree-dump-not "bit_xor_expr, " "optimized" } } */
/* { dg-final { scan-tree-dump-times "bit_and_expr, " 6 "optimized" } } */
/* { dg-final { scan-tree-dump-times "bit_not_expr, " 2 "optimized" } } */
|