summaryrefslogtreecommitdiffstats
path: root/clang/test/Frontend/fixed_point_conversions.c
diff options
context:
space:
mode:
authorLeonard Chan <leonardchan@google.com>2019-01-16 18:13:59 +0000
committerLeonard Chan <leonardchan@google.com>2019-01-16 18:13:59 +0000
commit2044ac89aa5203398048b38b6e53e33f682f507d (patch)
tree0876179a140b7bfbdafbe871657660b1940feb40 /clang/test/Frontend/fixed_point_conversions.c
parent07d8b321b3da50e75fbad1b23253dd3646fd6033 (diff)
downloadbcm5719-llvm-2044ac89aa5203398048b38b6e53e33f682f507d.tar.gz
bcm5719-llvm-2044ac89aa5203398048b38b6e53e33f682f507d.zip
[Fixed Point Arithmetic] Fixed Point Addition
This patch covers addition between fixed point types and other fixed point types or integers, using the conversion rules described in 4.1.4 of N1169. Usual arithmetic rules do not apply to binary operations when one of the operands is a fixed point type, and the result of the operation must be calculated with the full precision of the operands, so we should not perform any casting to a common type. This patch does not include constant expression evaluation for addition of fixed point types. That will be addressed in another patch since I think this one is already big enough. Differential Revision: https://reviews.llvm.org/D53738 llvm-svn: 351364
Diffstat (limited to 'clang/test/Frontend/fixed_point_conversions.c')
-rw-r--r--clang/test/Frontend/fixed_point_conversions.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/clang/test/Frontend/fixed_point_conversions.c b/clang/test/Frontend/fixed_point_conversions.c
index 7e98fb1e130..22cde0eb690 100644
--- a/clang/test/Frontend/fixed_point_conversions.c
+++ b/clang/test/Frontend/fixed_point_conversions.c
@@ -214,19 +214,17 @@ void TestFixedPointCastSaturation() {
// Only get overflow checking if signed fract to unsigned accum
sat_ua = sat_sf;
// DEFAULT: [[FRACT:%[0-9a-z]+]] = load i8, i8* %sat_sf, align 1
- // DEFAULT-NEXT: [[FRACT_EXT:%[0-9a-z]+]] = sext i8 [[FRACT]] to i17
- // DEFAULT-NEXT: [[ACCUM:%[0-9a-z]+]] = shl i17 [[FRACT_EXT]], 9
- // DEFAULT-NEXT: [[IS_NEG:%[0-9a-z]+]] = icmp slt i17 [[ACCUM]], 0
- // DEFAULT-NEXT: [[RESULT:%[0-9a-z]+]] = select i1 [[IS_NEG]], i17 0, i17 [[ACCUM]]
- // DEFAULT-NEXT: [[RESULT_EXT:%[0-9a-z]+]] = sext i17 [[RESULT]] to i32
- // DEFAULT-NEXT: store i32 [[RESULT_EXT]], i32* %sat_ua, align 4
+ // DEFAULT-NEXT: [[FRACT_EXT:%[0-9a-z]+]] = sext i8 [[FRACT]] to i32
+ // DEFAULT-NEXT: [[ACCUM:%[0-9a-z]+]] = shl i32 [[FRACT_EXT]], 9
+ // DEFAULT-NEXT: [[IS_NEG:%[0-9a-z]+]] = icmp slt i32 [[ACCUM]], 0
+ // DEFAULT-NEXT: [[RESULT:%[0-9a-z]+]] = select i1 [[IS_NEG]], i32 0, i32 [[ACCUM]]
+ // DEFAULT-NEXT: store i32 [[RESULT]], i32* %sat_ua, align 4
// SAME: [[FRACT:%[0-9a-z]+]] = load i8, i8* %sat_sf, align 1
- // SAME-NEXT: [[FRACT_EXT:%[0-9a-z]+]] = sext i8 [[FRACT]] to i16
- // SAME-NEXT: [[ACCUM:%[0-9a-z]+]] = shl i16 [[FRACT_EXT]], 8
- // SAME-NEXT: [[IS_NEG:%[0-9a-z]+]] = icmp slt i16 [[ACCUM]], 0
- // SAME-NEXT: [[RESULT:%[0-9a-z]+]] = select i1 [[IS_NEG]], i16 0, i16 [[ACCUM]]
- // SAME-NEXT: [[RESULT_EXT:%[0-9a-z]+]] = sext i16 [[RESULT]] to i32
- // SAME-NEXT: store i32 [[RESULT_EXT]], i32* %sat_ua, align 4
+ // SAME-NEXT: [[FRACT_EXT:%[0-9a-z]+]] = sext i8 [[FRACT]] to i32
+ // SAME-NEXT: [[ACCUM:%[0-9a-z]+]] = shl i32 [[FRACT_EXT]], 8
+ // SAME-NEXT: [[IS_NEG:%[0-9a-z]+]] = icmp slt i32 [[ACCUM]], 0
+ // SAME-NEXT: [[RESULT:%[0-9a-z]+]] = select i1 [[IS_NEG]], i32 0, i32 [[ACCUM]]
+ // SAME-NEXT: store i32 [[RESULT]], i32* %sat_ua, align 4
}
void TestFixedPointCastBetFractAccum() {
OpenPOWER on IntegriCloud