[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Frontend / fixed_point_div_const.c
blob66c028e608db606db5054a9ed4fa86e4437d236a
1 // RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,SIGNED
2 // RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -fpadding-on-unsigned-fixed-point -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,UNSIGNED
4 // RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -emit-llvm %s -o - -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK,SIGNED
5 // RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -fpadding-on-unsigned-fixed-point -emit-llvm %s -o - -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK,UNSIGNED
7 // Division between different fixed point types
8 short _Accum sa_const = 1.0hk / 2.0hk;
9 // CHECK-DAG: @sa_const = {{.*}}global i16 64, align 2
10 _Accum a_const = 1.0hk / 2.0k;
11 // CHECK-DAG: @a_const = {{.*}}global i32 16384, align 4
12 long _Accum la_const = 1.0hk / 2.0lk;
13 // CHECK-DAG: @la_const = {{.*}}global i64 1073741824, align 8
14 short _Accum sa_const2 = 0.5hr / 2.0hk;
15 // CHECK-DAG: @sa_const2 = {{.*}}global i16 32, align 2
16 short _Accum sa_const3 = 0.5r / 2.0hk;
17 // CHECK-DAG: @sa_const3 = {{.*}}global i16 32, align 2
18 short _Accum sa_const4 = 0.5lr / 2.0hk;
19 // CHECK-DAG: @sa_const4 = {{.*}}global i16 32, align 2
20 short _Accum sa_const5 = 2.0hk / 0.5lr;
21 // CHECK-DAG: @sa_const5 = {{.*}}global i16 512, align 2
23 // Unsigned division
24 unsigned short _Accum usa_const = 3.0uhk / 2.0uhk;
25 // SIGNED-DAG: @usa_const = {{.*}}global i16 384, align 2
26 // UNSIGNED-DAG: @usa_const = {{.*}}global i16 192, align 2
28 // Unsigned / signed
29 short _Accum sa_const6 = 1.0uhk / 2.0hk;
30 // CHECK-DAG: @sa_const6 = {{.*}}global i16 64, align 2
32 // Division with negative number
33 short _Accum sa_const7 = 0.5hr / (-2.0hk);
34 // CHECK-DAG: @sa_const7 = {{.*}}global i16 -32, align 2
36 // Int division
37 unsigned short _Accum usa_const2 = 2 / 0.5uhk;
38 // SIGNED-DAG: @usa_const2 = {{.*}}global i16 1024, align 2
39 // UNSIGNED-DAG: @usa_const2 = {{.*}}global i16 512, align 2
40 short _Accum sa_const8 = 2 / (-0.5hk);
41 // CHECK-DAG: @sa_const8 = {{.*}}global i16 -512, align 2
42 short _Accum sa_const9 = 256 / 2.0hk;
43 // CHECK-DAG: @sa_const9 = {{.*}}global i16 16384, align 2
44 long _Fract lf_const = 0.5lr / -1;
45 // CHECK-DAG: @lf_const = {{.*}}global i32 -1073741824, align 4
47 // Saturated division
48 _Sat short _Accum sat_sa_const = (_Sat short _Accum)128.0hk / (-0.25hk);
49 // CHECK-DAG: @sat_sa_const = {{.*}}global i16 -32768, align 2
50 _Sat unsigned short _Accum sat_usa_const = (_Sat unsigned short _Accum)128.0uhk / (0.25uhk);
51 // SIGNED-DAG: @sat_usa_const = {{.*}}global i16 -1, align 2
52 // UNSIGNED-DAG: @sat_usa_const = {{.*}}global i16 32767, align 2
53 _Sat short _Accum sat_sa_const2 = (_Sat short _Accum)-128.0hk / (-0.0125hr);
54 // CHECK-DAG: @sat_sa_const2 = {{.*}}global i16 32767, align 2
55 _Sat unsigned short _Accum sat_usa_const2 = (_Sat unsigned short _Accum)128.0uhk / (-128);
56 // CHECK-DAG: @sat_usa_const2 = {{.*}}global i16 0, align 2
57 _Sat unsigned short _Accum sat_usa_const3 = (_Sat unsigned short _Accum)0.5uhk / -1;
58 // CHECK-DAG: @sat_usa_const3 = {{.*}}global i16 0, align 2
59 _Sat short _Accum sat_sa_const3 = (_Sat short _Accum)-128.0hk / 128;
60 // CHECK-DAG: @sat_sa_const3 = {{.*}}global i16 -128, align 2
61 _Sat short _Accum sat_sa_const4 = (_Sat short _Accum)-25.7hk / 0.1lk;
62 // CHECK-DAG: @sat_sa_const4 = {{.*}}global i16 -32768, align 2
64 // Some more cases
65 short _Accum sa_const10 = 255.9921875hk / 255.9921875hk;
66 // CHECK-DAG: @sa_const10 = {{.*}}global i16 128, align 2
67 short _Accum sat_sa_const5 = (_Sat short _Accum)(-255.0hk - 1.0hk) / 0.0078125hk;
68 // CHECK-DAG: @sat_sa_const5 = {{.*}}global i16 -32768, align 2
69 _Sat short _Accum sat_sa_const6 = (_Sat short _Accum)(-255.0hk - 1.0hk) / -0.0078125hk;
70 // CHECK-DAG: @sat_sa_const6 = {{.*}}global i16 32767, align 2
71 short _Accum sa_const12 = 255.9921875hk / -1.0hk;
72 // CHECK-DAG: @sa_const12 = {{.*}}global i16 -32767, align 2
73 _Sat short _Accum sat_sa_const7 = (_Sat short _Accum)(-255.0hk - 1.0hk) / -1.0hk;
74 // CHECK-DAG: @sat_sa_const7 = {{.*}}global i16 32767, align 2
75 short _Accum sa_const13 = 0.0234375hk / 2.0hk;
76 // CHECK-DAG: @sa_const13 = {{.*}}global i16 1, align 2
77 short _Accum sa_const14 = -0.0234375hk / 2.0hk;
78 // CHECK-DAG: @sa_const14 = {{.*}}global i16 -2, align 2
79 short _Accum sa_const15 = -0.0078125hk / 255.28125hk;
80 // CHECK-DAG: @sa_const15 = {{.*}}global i16 -1, align 2