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