annotate clang/test/CodeGen/bitfield-assign.c @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 /* Check that the result of a bitfield assignment is properly
anatofuz
parents:
diff changeset
2 truncated and does not generate a redundant load. */
anatofuz
parents:
diff changeset
3
anatofuz
parents:
diff changeset
4 /* Check that we get one load for each simple assign and two for the
anatofuz
parents:
diff changeset
5 compound assign (load the old value before the add then load again
anatofuz
parents:
diff changeset
6 to store back). Also check that our g0 pattern is good. */
anatofuz
parents:
diff changeset
7 // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -o %t %s
anatofuz
parents:
diff changeset
8 // RUN: grep 'load ' %t | count 5
anatofuz
parents:
diff changeset
9 // RUN: grep "@g0" %t | count 4
anatofuz
parents:
diff changeset
10
anatofuz
parents:
diff changeset
11 // Check that we got the right value.
anatofuz
parents:
diff changeset
12 // RUN: %clang_cc1 -triple i386-unknown-unknown -O3 -emit-llvm -o %t %s
anatofuz
parents:
diff changeset
13 // RUN: not grep 'load ' %t
anatofuz
parents:
diff changeset
14 // RUN: not grep "@g0" %t
anatofuz
parents:
diff changeset
15
anatofuz
parents:
diff changeset
16 struct s0 {
anatofuz
parents:
diff changeset
17 int f0 : 2;
anatofuz
parents:
diff changeset
18 _Bool f1 : 1;
anatofuz
parents:
diff changeset
19 unsigned f2 : 2;
anatofuz
parents:
diff changeset
20 };
anatofuz
parents:
diff changeset
21
anatofuz
parents:
diff changeset
22 int g0();
anatofuz
parents:
diff changeset
23
anatofuz
parents:
diff changeset
24 void f0(void) {
anatofuz
parents:
diff changeset
25 struct s0 s;
anatofuz
parents:
diff changeset
26 if ((s.f0 = 3) != -1) g0();
anatofuz
parents:
diff changeset
27 }
anatofuz
parents:
diff changeset
28
anatofuz
parents:
diff changeset
29 void f1(void) {
anatofuz
parents:
diff changeset
30 struct s0 s;
anatofuz
parents:
diff changeset
31 if ((s.f1 = 3) != 1) g0();
anatofuz
parents:
diff changeset
32 }
anatofuz
parents:
diff changeset
33
anatofuz
parents:
diff changeset
34 void f2(void) {
anatofuz
parents:
diff changeset
35 struct s0 s;
anatofuz
parents:
diff changeset
36 if ((s.f2 = 3) != 3) g0();
anatofuz
parents:
diff changeset
37 }
anatofuz
parents:
diff changeset
38
anatofuz
parents:
diff changeset
39 void f3(void) {
anatofuz
parents:
diff changeset
40 struct s0 s;
anatofuz
parents:
diff changeset
41 // Just check this one for load counts.
anatofuz
parents:
diff changeset
42 s.f0 += 3;
anatofuz
parents:
diff changeset
43 }
anatofuz
parents:
diff changeset
44