]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/CodeGen/no-bitfield-type-align.c
Vendor import of clang trunk r338150:
[FreeBSD/FreeBSD.git] / test / CodeGen / no-bitfield-type-align.c
1 // RUN: %clang_cc1 -triple x86_64-apple-darwin -fno-bitfield-type-align -emit-llvm -o - %s | FileCheck %s
2
3 // CHECK: %[[STRUCT_S:.*]] = type { i32 }
4
5 struct S {
6   unsigned short:   0;
7   unsigned short  f1:15;
8   unsigned short:   0;
9   unsigned short  f2:15;
10 };
11
12 // CHECK: define void @test_zero_width_bitfield(%[[STRUCT_S]]* %[[A:.*]])
13 // CHECK: %[[BF_LOAD:.*]] = load i32, i32* %[[V1:.*]], align 1
14 // CHECK: %[[BF_CLEAR:.*]] = and i32 %[[BF_LOAD]], 32767
15 // CHECK: %[[BF_CAST:.*]] = trunc i32 %[[BF_CLEAR]] to i16
16 // CHECK: %[[CONV:.*]] = zext i16 %[[BF_CAST]] to i32
17 // CHECK: %[[ADD:.*]] = add nsw i32 %[[CONV]], 1
18 // CHECK: %[[CONV1:.*]] = trunc i32 %[[ADD]] to i16
19 // CHECK: %[[V2:.*]] = zext i16 %[[CONV1]] to i32
20 // CHECK: %[[BF_LOAD2:.*]] = load i32, i32* %[[V1]], align 1
21 // CHECK: %[[BF_VALUE:.*]] = and i32 %[[V2]], 32767
22 // CHECK: %[[BF_CLEAR3:.*]] = and i32 %[[BF_LOAD2]], -32768
23 // CHECK: %[[BF_SET:.*]] = or i32 %[[BF_CLEAR3]], %[[BF_VALUE]]
24 // CHECK: store i32 %[[BF_SET]], i32* %[[V1]], align 1
25
26 // CHECK: %[[BF_LOAD4:.*]] = load i32, i32* %[[V4:.*]], align 1
27 // CHECK: %[[BF_LSHR:.*]] = lshr i32 %[[BF_LOAD4]], 15
28 // CHECK: %[[BF_CLEAR5:.*]] = and i32 %[[BF_LSHR]], 32767
29 // CHECK: %[[BF_CAST6:.*]] = trunc i32 %[[BF_CLEAR5]] to i16
30 // CHECK: %[[CONV7:.*]] = zext i16 %[[BF_CAST6]] to i32
31 // CHECK: %[[ADD8:.*]] = add nsw i32 %[[CONV7]], 2
32 // CHECK: %[[CONV9:.*]] = trunc i32 %[[ADD8]] to i16
33 // CHECK: %[[V5:.*]] = zext i16 %[[CONV9]] to i32
34 // CHECK: %[[BF_LOAD10:.*]] = load i32, i32* %[[V4]], align 1
35 // CHECK: %[[BF_VALUE11:.*]] = and i32 %[[V5]], 32767
36 // CHECK: %[[BF_SHL:.*]] = shl i32 %[[BF_VALUE11]], 15
37 // CHECK: %[[BF_CLEAR12:.*]] = and i32 %[[BF_LOAD10]], -1073709057
38 // CHECK: %[[BF_SET13:.*]] = or i32 %[[BF_CLEAR12]], %[[BF_SHL]]
39 // CHECK: store i32 %[[BF_SET13]], i32* %[[V4]], align 1
40
41 void test_zero_width_bitfield(struct S *a) {
42   a->f1 += 1;
43   a->f2 += 2;
44 }