Author: Kito Cheng Date: 2022-04-30T11:09:12+08:00 New Revision: 02c7de3a4c32f2456df09df07e473bb95c85529c
URL: https://github.com/llvm/llvm-project/commit/02c7de3a4c32f2456df09df07e473bb95c85529c DIFF: https://github.com/llvm/llvm-project/commit/02c7de3a4c32f2456df09df07e473bb95c85529c.diff LOG: [RISCV] Precommit test for D124509 Test case to show the wrong code gen for `int16` -> `__fp16` conversion, clang just emit a load and store without did conversion in the case, and another case used for demonstrate the code gen change of `__fp16` -> `int16`. Reviewed By: khchen Differential Revision: https://reviews.llvm.org/D124510 Added: clang/test/CodeGen/RISCV/__fp16-convert.c Modified: Removed: ################################################################################ diff --git a/clang/test/CodeGen/RISCV/__fp16-convert.c b/clang/test/CodeGen/RISCV/__fp16-convert.c new file mode 100644 index 000000000000..cdb666617553 --- /dev/null +++ b/clang/test/CodeGen/RISCV/__fp16-convert.c @@ -0,0 +1,26 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// RUN: %clang_cc1 -triple riscv64 -emit-llvm %s -o - \ +// RUN: | FileCheck %s + +__fp16 y; +short z; +// CHECK-LABEL: @bar1( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[TMP0:%.*]] = load i16, ptr @y, align 2 +// CHECK-NEXT: [[TMP1:%.*]] = call float @llvm.convert.from.fp16.f32(i16 [[TMP0]]) +// CHECK-NEXT: [[CONV:%.*]] = fptosi float [[TMP1]] to i16 +// CHECK-NEXT: store i16 [[CONV]], ptr @z, align 2 +// CHECK-NEXT: ret void +// +void bar1(){ + z = y; +} +// CHECK-LABEL: @bar2( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[TMP0:%.*]] = load i16, ptr @z, align 2 +// CHECK-NEXT: store i16 [[TMP0]], ptr @y, align 2 +// CHECK-NEXT: ret void +// +void bar2(){ + y = z; +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits