summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/fold-mod-1.c
blob: 4a26d0fc088458a4238b54f45a3258f592b93126 (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
/* { dg-do compile } */
/* { dg-options "-fdump-tree-gimple" } */

#define ABS(x) (x > 0 ? x : -x)

unsigned int f (unsigned int a) {
	/* (unsigned)-8 is not a power of 2.  */
	return a % -8;
}

int g (int b) {
	return ABS (b) % -8;
}

int h (int c) {
	return ABS (c) % 8;
}

unsigned int k (unsigned int d) {
	return d % 8;
}

/* { dg-final { scan-tree-dump "a % (4294967288|0fffffff8)" "gimple" } } */
/* { dg-final { scan-tree-dump-times " & 7" 3 "gimple" } } */
/* { dg-final { cleanup-tree-dump "gimple" } } */