[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Frontend / fixed_point_to_bool.c
blob4b9ed6cebe32332bac4169a74a1e676ac56ecd9e
1 // RUN: %clang_cc1 -ffixed-point -S -emit-llvm %s -o - | FileCheck %s
2 // RUN: %clang_cc1 -ffixed-point -S -emit-llvm %s -o - -fpadding-on-unsigned-fixed-point | FileCheck %s
4 _Bool global_b = 1.0k; // @global_b = {{*.}}global i8 1, align 1
5 _Bool global_b2 = 0.0k; // @global_b2 = {{*.}}global i8 0, align 1
7 void func(void) {
8 _Accum a = 0.5k;
9 unsigned _Accum ua = 0.5uk;
10 _Bool b;
12 // CHECK: store i8 1, ptr %b, align 1
13 // CHECK-NEXT: store i8 0, ptr %b, align 1
14 // CHECK: store i8 1, ptr %b, align 1
15 // CHECK-NEXT: store i8 0, ptr %b, align 1
16 b = 0.5k;
17 b = 0.0k;
18 b = 0.5uk;
19 b = 0.0uk;
21 // CHECK-NEXT: store i8 1, ptr %b, align 1
22 // CHECK-NEXT: store i8 0, ptr %b, align 1
23 // CHECK-NEXT: store i8 1, ptr %b, align 1
24 // CHECK-NEXT: store i8 0, ptr %b, align 1
25 b = (_Bool)0.5r;
26 b = (_Bool)0.0r;
27 b = (_Bool)0.5ur;
28 b = (_Bool)0.0ur;
30 // CHECK-NEXT: [[ACCUM:%[0-9a-z]+]] = load i32, ptr %a, align 4
31 // CHECK-NEXT: [[NOTZERO:%[0-9a-z]+]] = icmp ne i32 [[ACCUM]], 0
32 // CHECK-NEXT: [[FROMBOOL:%[0-9a-z]+]] = zext i1 [[NOTZERO]] to i8
33 // CHECK-NEXT: store i8 [[FROMBOOL]], ptr %b, align 1
34 b = a;
36 // CHECK-NEXT: [[ACCUM:%[0-9a-z]+]] = load i32, ptr %ua, align 4
37 // CHECK-NEXT: [[NOTZERO:%[0-9a-z]+]] = icmp ne i32 [[ACCUM]], 0
38 // CHECK-NEXT: [[FROMBOOL:%[0-9a-z]+]] = zext i1 [[NOTZERO]] to i8
39 // CHECK-NEXT: store i8 [[FROMBOOL]], ptr %b, align 1
40 b = ua;
42 // CHECK-NEXT: [[ACCUM:%[0-9a-z]+]] = load i32, ptr %a, align 4
43 // CHECK-NEXT: [[NOTZERO:%[0-9a-z]+]] = icmp ne i32 [[ACCUM]], 0
44 // CHECK-NEXT: br i1 [[NOTZERO]], label %if.then, label %if.end
45 if (a) {
48 // CHECK: [[ACCUM:%[0-9a-z]+]] = load i32, ptr %ua, align 4
49 // CHECK-NEXT: [[NOTZERO:%[0-9a-z]+]] = icmp ne i32 [[ACCUM]], 0
50 // CHECK-NEXT: br i1 [[NOTZERO]], label %if.then{{[0-9]+}}, label %if.end{{[0-9]+}}
51 if (ua) {