| 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 |
| 3 |
|
| 4 |
// Subtraction between different fixed point types |
| 5 |
short _Accum sa_const = 1.0hk - 2.0hk; |
| 6 |
// CHECK-DAG: @sa_const = {{.*}}global i16 -128, align 2 |
| 7 |
_Accum a_const = 1.0hk - 2.0k; |
| 8 |
// CHECK-DAG: @a_const = {{.*}}global i32 -32768, align 4 |
| 9 |
long _Accum la_const = 1.0hk - 2.0lk; |
| 10 |
// CHECK-DAG: @la_const = {{.*}}global i64 -2147483648, align 8 |
| 11 |
short _Accum sa_const2 = 0.5hr - 2.0hk; |
| 12 |
// CHECK-DAG: @sa_const2 = {{.*}}global i16 -192, align 2 |
| 13 |
short _Accum sa_const3 = 0.5r - 2.0hk; |
| 14 |
// CHECK-DAG: @sa_const3 = {{.*}}global i16 -192, align 2 |
| 15 |
short _Accum sa_const4 = 0.5lr - 2.0hk; |
| 16 |
// CHECK-DAG: @sa_const4 = {{.*}}global i16 -192, align 2 |
| 17 |
short _Accum sa_const5 = 2.0hk - 0.5lr; |
| 18 |
// CHECK-DAG: @sa_const5 = {{.*}}global i16 192, align 2 |
| 19 |
|
| 20 |
// Unsigned subtraction |
| 21 |
unsigned short _Accum usa_const = 3.0uhk - 2.0uhk; |
| 22 |
// SIGNED-DAG: @usa_const = {{.*}}global i16 256, align 2 |
| 23 |
// UNSIGNED-DAG: @usa_const = {{.*}}global i16 128, align 2 |
| 24 |
|
| 25 |
// Unsigned - signed |
| 26 |
short _Accum sa_const6 = 1.0uhk - 2.0hk; |
| 27 |
// CHECK-DAG: @sa_const6 = {{.*}}global i16 -128, align 2 |
| 28 |
|
| 29 |
// Subtraction with negative number |
| 30 |
short _Accum sa_const7 = 0.5hr - (-2.0hk); |
| 31 |
// CHECK-DAG: @sa_const7 = {{.*}}global i16 320, align 2 |
| 32 |
|
| 33 |
// Int subtraction |
| 34 |
unsigned short _Accum usa_const2 = 2 - 0.5uhk; |
| 35 |
// SIGNED-DAG: @usa_const2 = {{.*}}global i16 384, align 2 |
| 36 |
// UNSIGNED-DAG: @usa_const2 = {{.*}}global i16 192, align 2 |
| 37 |
short _Accum sa_const8 = 2 - (-0.5hk); |
| 38 |
// CHECK-DAG: @sa_const8 = {{.*}}global i16 320, align 2 |
| 39 |
short _Accum sa_const9 = 257 - 2.0hk; |
| 40 |
// CHECK-DAG: @sa_const9 = {{.*}}global i16 32640, align 2 |
| 41 |
long _Fract lf_const = 0.5lr - 1; |
| 42 |
// CHECK-DAG: @lf_const = {{.*}}global i32 -1073741824, align 4 |
| 43 |
|
| 44 |
// Saturated subtraction |
| 45 |
_Sat short _Accum sat_sa_const = (_Sat short _Accum)128.0hk - (-128.0hk); |
| 46 |
// CHECK-DAG: @sat_sa_const = {{.*}}global i16 32767, align 2 |
| 47 |
_Sat unsigned short _Accum sat_usa_const = (_Sat unsigned short _Accum)128.0uhk - (-128.0uhk); |
| 48 |
// CHECK-DAG: @sat_usa_const = {{.*}}global i16 0, align 2 |
| 49 |
_Sat short _Accum sat_sa_const2 = (_Sat short _Accum)128.0hk - (-128); |
| 50 |
// CHECK-DAG: @sat_sa_const2 = {{.*}}global i16 32767, align 2 |
| 51 |
_Sat unsigned short _Accum sat_usa_const2 = (_Sat unsigned short _Accum)128.0uhk - (-128); |
| 52 |
// SIGNED-DAG: @sat_usa_const2 = {{.*}}global i16 -1, align 2 |
| 53 |
// UNSIGNED-DAG: @sat_usa_const2 = {{.*}}global i16 32767, align 2 |
| 54 |
_Sat unsigned short _Accum sat_usa_const3 = (_Sat unsigned short _Accum)0.5uhk - 2; |
| 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 -32768, align 2 |
| 58 |
_Sat short _Accum sat_sa_const4 = (_Sat short _Accum)-150.0hk - 130.0lk; |
| 59 |
// CHECK-DAG: @sat_sa_const4 = {{.*}}global i16 -32768, align 2 |