Skip to content

Commit 00c4be3

Browse files
authored
[Test] Add and update tests for lrint/llrint (NFC) (#152662)
Many backends are missing either all tests for lrint, or specifically those for f16, which currently crashes for `softPromoteHalf` targets. For a number of popular backends, do the following: * Ensure f16, f32, f64, and f128 are all covered * Ensure both a 32- and 64-bit target are tested, if relevant * Add `nounwind` to clean up CFI output * Add a test covering the above if one did not exist * Always specify the integer type in intrinsic calls There are quite a few FIXMEs here, especially for `f16`, but much of this will be resolved in the near future.
1 parent c416034 commit 00c4be3

28 files changed

+12860
-1306
lines changed

llvm/test/CodeGen/AArch64/sve-fixed-vector-llrint.ll

Lines changed: 337 additions & 27 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AArch64/sve-fixed-vector-lrint.ll

Lines changed: 549 additions & 53 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AArch64/vector-llrint.ll

Lines changed: 261 additions & 18 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AArch64/vector-lrint.ll

Lines changed: 466 additions & 18 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/ARM/llrint-conv.ll

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
; RUN: llc < %s -mtriple=arm-eabi -float-abi=soft | FileCheck %s --check-prefix=SOFTFP
22
; RUN: llc < %s -mtriple=arm-eabi -float-abi=hard | FileCheck %s --check-prefix=HARDFP
33

4+
; SOFTFP-LABEL: testmsxh_builtin:
5+
; SOFTFP: bl llrintf
6+
; HARDFP-LABEL: testmsxh_builtin:
7+
; HARDFP: bl llrintf
8+
define i64 @testmsxh_builtin(half %x) {
9+
entry:
10+
%0 = tail call i64 @llvm.llrint.i64.f16(half %x)
11+
ret i64 %0
12+
}
13+
414
; SOFTFP-LABEL: testmsxs_builtin:
515
; SOFTFP: bl llrintf
616
; HARDFP-LABEL: testmsxs_builtin:
717
; HARDFP: bl llrintf
818
define i64 @testmsxs_builtin(float %x) {
919
entry:
10-
%0 = tail call i64 @llvm.llrint.f32(float %x)
20+
%0 = tail call i64 @llvm.llrint.i64.f32(float %x)
1121
ret i64 %0
1222
}
1323

@@ -17,9 +27,20 @@ entry:
1727
; HARDFP: bl llrint
1828
define i64 @testmsxd_builtin(double %x) {
1929
entry:
20-
%0 = tail call i64 @llvm.llrint.f64(double %x)
30+
%0 = tail call i64 @llvm.llrint.i64.f64(double %x)
31+
ret i64 %0
32+
}
33+
34+
; FIXME(#44744): incorrect libcall
35+
; SOFTFP-LABEL: testmsxq_builtin:
36+
; SOFTFP: bl llrintl
37+
; HARDFP-LABEL: testmsxq_builtin:
38+
; HARDFP: bl llrintl
39+
define i64 @testmsxq_builtin(fp128 %x) {
40+
entry:
41+
%0 = tail call i64 @llvm.llrint.i64.f128(fp128 %x)
2142
ret i64 %0
2243
}
2344

24-
declare i64 @llvm.llrint.f32(float) nounwind readnone
25-
declare i64 @llvm.llrint.f64(double) nounwind readnone
45+
declare i64 @llvm.llrint.i64.f32(float) nounwind readnone
46+
declare i64 @llvm.llrint.i64.f64(double) nounwind readnone

llvm/test/CodeGen/ARM/lrint-conv.ll

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
; RUN: llc < %s -mtriple=arm-eabi -float-abi=soft | FileCheck %s --check-prefix=SOFTFP
22
; RUN: llc < %s -mtriple=arm-eabi -float-abi=hard | FileCheck %s --check-prefix=HARDFP
33

4+
; FIXME: crash
5+
; define i32 @testmswh_builtin(half %x) {
6+
; entry:
7+
; %0 = tail call i32 @llvm.lrint.i32.f16(half %x)
8+
; ret i32 %0
9+
; }
10+
411
; SOFTFP-LABEL: testmsws_builtin:
512
; SOFTFP: bl lrintf
613
; HARDFP-LABEL: testmsws_builtin:
@@ -21,5 +28,16 @@ entry:
2128
ret i32 %0
2229
}
2330

31+
; FIXME(#44744): incorrect libcall
32+
; SOFTFP-LABEL: testmswq_builtin:
33+
; SOFTFP: bl lrintl
34+
; HARDFP-LABEL: testmswq_builtin:
35+
; HARDFP: bl lrintl
36+
define i32 @testmswq_builtin(fp128 %x) {
37+
entry:
38+
%0 = tail call i32 @llvm.lrint.i32.f128(fp128 %x)
39+
ret i32 %0
40+
}
41+
2442
declare i32 @llvm.lrint.i32.f32(float) nounwind readnone
2543
declare i32 @llvm.lrint.i32.f64(double) nounwind readnone

0 commit comments

Comments
 (0)