[PATCH] D124510: [RISCV] Precommit test for D124509

Kito Cheng via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 27 02:32:53 PDT 2022


kito-cheng created this revision.
Herald added subscribers: sunshaoce, VincentWu, luke957, vkmr, frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, arichardson.
Herald added a project: All.
kito-cheng requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, eopXD, MaskRay.
Herald added a project: clang.

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 improvement of `__fp16`
-> `int16`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124510

Files:
  clang/test/CodeGen/RISCV/__fp16-convert.c


Index: clang/test/CodeGen/RISCV/__fp16-convert.c
===================================================================
--- /dev/null
+++ 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;
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124510.425451.patch
Type: text/x-patch
Size: 977 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220427/e4eee740/attachment-0001.bin>


More information about the cfe-commits mailing list