blob: 000c5aef2377a35591535a9c107d6913d2834afc (
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
|
/* { dg-do compile } */
/* { dg-options "-O1 -fdump-tree-optimized-raw" } */
/* PR tree-optimization/115449 */
void setBit_un(unsigned char *a, int b) {
unsigned char c = 0x1UL << b;
*a &= ~c;
*a |= c;
}
void setBit_sign(signed char *a, int b) {
signed char c = 0x1UL << b;
*a &= ~c;
*a |= c;
}
void setBit(char *a, int b) {
char c = 0x1UL << b;
*a &= ~c;
*a |= c;
}
/*
All three should produce:
_1 = 1 << b_4(D);
c_5 = (cast) _1;
_2 = *a_7(D);
_3 = _2 | c_5;
*a_7(D) = _3;
Removing the `&~c` as we are matching `(~x & y) | x` -> `x | y`
match pattern even with extra casts are being involved. */
/* { dg-final { scan-tree-dump-not "bit_not_expr, " "optimized" } } */
/* { dg-final { scan-tree-dump-not "bit_and_expr, " "optimized" } } */
/* { dg-final { scan-tree-dump-times "bit_ior_expr, " 3 "optimized" } } */
|