summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/20150120-1.c
blob: 18906c47a0974cc74d2bf56d0cdf786aef32aabc (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
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-original" } */

/* x + (x & 1) -> (x + 1) & ~1 */
int
fn1 (int x)
{
	return x + (x & 1);
}
int
fn2 (int x)
{
	return (x & 1) + x;
}
int
fn3 (int x)
{
	return x + (1 & x);
}
int
fn4 (int x)
{
	return (1 & x) + x;
}
unsigned int
fn5 (unsigned int x)
{
	return x + (x & 1);
}
unsigned int
fn6 (unsigned int x)
{
	return (x & 1) + x;
}
unsigned int
fn7 (unsigned int x)
{
	return x + (x % 2);
}
unsigned int
fn8 (unsigned int x)
{
	return (x % 2) + x;
}
unsigned int
fn9 (unsigned int x)
{
	return (1LL & x) + x;
}

/* { dg-final { scan-tree-dump-times "x \\+ 1" 9 "original" } } */