Skip to content

Commit be7e146

Browse files
authored
AArch64: Add tests for arm64ec for special case math functions (#147234)
1 parent ae43002 commit be7e146

File tree

4 files changed

+104
-4
lines changed

4 files changed

+104
-4
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
; RUN: llc -mtriple=arm64ec-windows-msvc < %s | FileCheck -check-prefix=ARM64EC %s
2+
3+
; Separate from llvm-frexp.ll test because this errors on half cases
4+
5+
; ARM64EC-LABEL: test_frexp_f32_i32
6+
; ARM64EC: fcvt d0, s0
7+
; ARM64EC: bl "#frexp"
8+
; ARM64EC: fcvt s0, d0
9+
define { float, i32 } @test_frexp_f32_i32(float %a) {
10+
%result = call { float, i32 } @llvm.frexp.f32.i32(float %a)
11+
ret { float, i32 } %result
12+
}
13+
14+
; ARM64EC-LABEL: test_frexp_f64_i32
15+
; ARM64EC: bl "#frexp"
16+
define { double, i32 } @test_frexp_f64_i32(double %a) {
17+
%result = call { double, i32 } @llvm.frexp.f64.i32(double %a)
18+
ret { double, i32 } %result
19+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc -mtriple=arm64ec-windows-msvc < %s | FileCheck -check-prefixes=ARM64EC %s
3+
4+
; Separate from ldexp.ll test because this errors on half cases
5+
6+
; ARM64EC-LABEL: ldexp_f32 =
7+
; ARM64EC: fcvt d0, s0
8+
; ARM64EC: bl "#ldexp"
9+
; ARM64EC: fcvt s0, d0
10+
define float @ldexp_f32(float %val, i32 %a) {
11+
%call = call float @llvm.ldexp.f32(float %val, i32 %a)
12+
ret float %call
13+
}
14+
15+
; ARM64EC-LABEL: ldexp_f64 =
16+
; ARM64EC: b "#ldexp"
17+
define double @ldexp_f64(double %val, i32 %a) {
18+
%call = call double @llvm.ldexp.f64(double %val, i32 %a)
19+
ret double %call
20+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc -mtriple=arm64ec-windows-msvc < %s | FileCheck -check-prefix=ARM64EC %s
3+
4+
declare double @llvm.powi.f64.i32(double, i32)
5+
declare float @llvm.powi.f32.i32(float, i32)
6+
7+
; ARM64EC-LABEL: powi_f32
8+
; ARM64EC: scvtf s1, w0
9+
; ARM64EC: b "#powf"
10+
define float @powi_f32(float %x, i32 %n) nounwind {
11+
%ret = tail call float @llvm.powi.f32.i32(float %x, i32 %n)
12+
ret float %ret
13+
}
14+
15+
; ARM64EC-LABEL: powi_f64
16+
; ARM64EC: scvtf d1, w0
17+
; ARM64EC: b "#pow"
18+
define double @powi_f64(double %x, i32 %n) nounwind {
19+
%ret = tail call double @llvm.powi.f64.i32(double %x, i32 %n)
20+
ret double %ret
21+
}

llvm/test/CodeGen/AArch64/powi.ll

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,65 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
12
; RUN: llc < %s -mtriple=aarch64-- | FileCheck %s
3+
; RUN: llc -mtriple=aarch64-windows-pc-msvc < %s | FileCheck -check-prefix=WINDOWS %s
24

35
declare double @llvm.powi.f64.i32(double, i32)
46
declare float @llvm.powi.f32.i32(float, i32)
57
declare float @pow(double noundef, double noundef)
68

7-
define float @powi_f32(float %x) nounwind {
8-
; CHECK-LABEL: powi_f32:
9+
define float @powi_f32_4(float %x) nounwind {
10+
; CHECK-LABEL: powi_f32_4:
911
; CHECK: // %bb.0:
1012
; CHECK-NEXT: fmul s0, s0, s0
1113
; CHECK-NEXT: fmul s0, s0, s0
1214
; CHECK-NEXT: ret
15+
;
16+
; WINDOWS-LABEL: powi_f32_4:
17+
; WINDOWS: // %bb.0:
18+
; WINDOWS-NEXT: fmul s0, s0, s0
19+
; WINDOWS-NEXT: fmul s0, s0, s0
20+
; WINDOWS-NEXT: ret
1321
%1 = tail call float @llvm.powi.f32.i32(float %x, i32 4)
1422
ret float %1
1523
}
1624

17-
define double @powi_f64(double %x) nounwind {
18-
; CHECK-LABEL: powi_f64:
25+
define double @powi_f64_3(double %x) nounwind {
26+
; CHECK-LABEL: powi_f64_3:
1927
; CHECK: // %bb.0:
2028
; CHECK-NEXT: fmul d1, d0, d0
2129
; CHECK-NEXT: fmul d0, d0, d1
2230
; CHECK-NEXT: ret
31+
;
32+
; WINDOWS-LABEL: powi_f64_3:
33+
; WINDOWS: // %bb.0:
34+
; WINDOWS-NEXT: fmul d1, d0, d0
35+
; WINDOWS-NEXT: fmul d0, d0, d1
36+
; WINDOWS-NEXT: ret
2337
%1 = tail call double @llvm.powi.f64.i32(double %x, i32 3)
2438
ret double %1
2539
}
40+
41+
define float @powi_f32(float %x, i32 %n) nounwind {
42+
; CHECK-LABEL: powi_f32:
43+
; CHECK: // %bb.0:
44+
; CHECK-NEXT: b __powisf2
45+
;
46+
; WINDOWS-LABEL: powi_f32:
47+
; WINDOWS: // %bb.0:
48+
; WINDOWS-NEXT: scvtf s1, w0
49+
; WINDOWS-NEXT: b powf
50+
%ret = tail call float @llvm.powi.f32.i32(float %x, i32 %n)
51+
ret float %ret
52+
}
53+
54+
define double @powi_f64(double %x, i32 %n) nounwind {
55+
; CHECK-LABEL: powi_f64:
56+
; CHECK: // %bb.0:
57+
; CHECK-NEXT: b __powidf2
58+
;
59+
; WINDOWS-LABEL: powi_f64:
60+
; WINDOWS: // %bb.0:
61+
; WINDOWS-NEXT: scvtf d1, w0
62+
; WINDOWS-NEXT: b pow
63+
%ret = tail call double @llvm.powi.f64.i32(double %x, i32 %n)
64+
ret double %ret
65+
}

0 commit comments

Comments
 (0)