[llvm] 5b4445e - [AArch64] Add a test for converting fdiv by constant to fmul. NFC
David Green via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 3 01:03:37 PDT 2024
Author: David Green
Date: 2024-06-03T09:03:32+01:00
New Revision: 5b4445e5e5d09b4bdf0e3c1fab52719bfb3f75e2
URL: https://github.com/llvm/llvm-project/commit/5b4445e5e5d09b4bdf0e3c1fab52719bfb3f75e2
DIFF: https://github.com/llvm/llvm-project/commit/5b4445e5e5d09b4bdf0e3c1fab52719bfb3f75e2.diff
LOG: [AArch64] Add a test for converting fdiv by constant to fmul. NFC
Added:
llvm/test/CodeGen/AArch64/fdiv-const.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/CodeGen/AArch64/fdiv-const.ll b/llvm/test/CodeGen/AArch64/fdiv-const.ll
new file mode 100644
index 0000000000000..5a8f733843401
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/fdiv-const.ll
@@ -0,0 +1,150 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc < %s -mtriple=arm64-eabi -mattr=fullfp16,sve | FileCheck %s
+
+define float @divf32_2(float %a) nounwind {
+; CHECK-LABEL: divf32_2:
+; CHECK: // %bb.0:
+; CHECK-NEXT: fmov s1, #2.00000000
+; CHECK-NEXT: fdiv s0, s0, s1
+; CHECK-NEXT: ret
+ %r = fdiv float %a, 2.0
+ ret float %r
+}
+
+define float @divf32_2_arcp(float %a) nounwind {
+; CHECK-LABEL: divf32_2_arcp:
+; CHECK: // %bb.0:
+; CHECK-NEXT: fmov s1, #0.50000000
+; CHECK-NEXT: fmul s0, s0, s1
+; CHECK-NEXT: ret
+ %r = fdiv arcp float %a, 2.0
+ ret float %r
+}
+
+define float @divf32_p75(float %a) nounwind {
+; CHECK-LABEL: divf32_p75:
+; CHECK: // %bb.0:
+; CHECK-NEXT: fmov s1, #0.75000000
+; CHECK-NEXT: fdiv s0, s0, s1
+; CHECK-NEXT: ret
+ %r = fdiv float %a, 0.75
+ ret float %r
+}
+
+define float @divf32_p75_arcp(float %a) nounwind {
+; CHECK-LABEL: divf32_p75_arcp:
+; CHECK: // %bb.0:
+; CHECK-NEXT: mov w8, #43691 // =0xaaab
+; CHECK-NEXT: movk w8, #16298, lsl #16
+; CHECK-NEXT: fmov s1, w8
+; CHECK-NEXT: fmul s0, s0, s1
+; CHECK-NEXT: ret
+ %r = fdiv arcp float %a, 0.75
+ ret float %r
+}
+
+define half @divf16_2(half %a) nounwind {
+; CHECK-LABEL: divf16_2:
+; CHECK: // %bb.0:
+; CHECK-NEXT: fmov h1, #2.00000000
+; CHECK-NEXT: fdiv h0, h0, h1
+; CHECK-NEXT: ret
+ %r = fdiv half %a, 2.0
+ ret half %r
+}
+
+define half @divf16_32768(half %a) nounwind {
+; CHECK-LABEL: divf16_32768:
+; CHECK: // %bb.0:
+; CHECK-NEXT: mov w8, #30720 // =0x7800
+; CHECK-NEXT: fmov h1, w8
+; CHECK-NEXT: fdiv h0, h0, h1
+; CHECK-NEXT: ret
+ %r = fdiv half %a, 32768.0
+ ret half %r
+}
+
+define half @divf16_32768_arcp(half %a) nounwind {
+; CHECK-LABEL: divf16_32768_arcp:
+; CHECK: // %bb.0:
+; CHECK-NEXT: mov w8, #512 // =0x200
+; CHECK-NEXT: fmov h1, w8
+; CHECK-NEXT: fmul h0, h0, h1
+; CHECK-NEXT: ret
+ %r = fdiv arcp half %a, 32768.0
+ ret half %r
+}
+
+define double @divf64_2(double %a) nounwind {
+; CHECK-LABEL: divf64_2:
+; CHECK: // %bb.0:
+; CHECK-NEXT: fmov d1, #2.00000000
+; CHECK-NEXT: fdiv d0, d0, d1
+; CHECK-NEXT: ret
+ %r = fdiv double %a, 2.0
+ ret double %r
+}
+
+define <4 x float> @divv4f32_2(<4 x float> %a) nounwind {
+; CHECK-LABEL: divv4f32_2:
+; CHECK: // %bb.0:
+; CHECK-NEXT: movi v1.4s, #64, lsl #24
+; CHECK-NEXT: fdiv v0.4s, v0.4s, v1.4s
+; CHECK-NEXT: ret
+ %r = fdiv <4 x float> %a, <float 2.0, float 2.0, float 2.0, float 2.0>
+ ret <4 x float> %r
+}
+
+define <4 x float> @divv4f32_2_arcp(<4 x float> %a) nounwind {
+; CHECK-LABEL: divv4f32_2_arcp:
+; CHECK: // %bb.0:
+; CHECK-NEXT: movi v1.4s, #63, lsl #24
+; CHECK-NEXT: fmul v0.4s, v0.4s, v1.4s
+; CHECK-NEXT: ret
+ %r = fdiv arcp <4 x float> %a, <float 2.0, float 2.0, float 2.0, float 2.0>
+ ret <4 x float> %r
+}
+
+define <4 x float> @divv4f32_3(<4 x float> %a) nounwind {
+; CHECK-LABEL: divv4f32_3:
+; CHECK: // %bb.0:
+; CHECK-NEXT: fmov v1.4s, #3.00000000
+; CHECK-NEXT: fdiv v0.4s, v0.4s, v1.4s
+; CHECK-NEXT: ret
+ %r = fdiv <4 x float> %a, <float 3.0, float 3.0, float 3.0, float 3.0>
+ ret <4 x float> %r
+}
+
+define <4 x float> @divv4f32_3_arcp(<4 x float> %a) nounwind {
+; CHECK-LABEL: divv4f32_3_arcp:
+; CHECK: // %bb.0:
+; CHECK-NEXT: mov w8, #43691 // =0xaaab
+; CHECK-NEXT: movk w8, #16042, lsl #16
+; CHECK-NEXT: dup v1.4s, w8
+; CHECK-NEXT: fmul v0.4s, v0.4s, v1.4s
+; CHECK-NEXT: ret
+ %r = fdiv arcp <4 x float> %a, <float 3.0, float 3.0, float 3.0, float 3.0>
+ ret <4 x float> %r
+}
+
+define <4 x float> @divv4f32_24816(<4 x float> %a) nounwind {
+; CHECK-LABEL: divv4f32_24816:
+; CHECK: // %bb.0:
+; CHECK-NEXT: adrp x8, .LCPI12_0
+; CHECK-NEXT: ldr q1, [x8, :lo12:.LCPI12_0]
+; CHECK-NEXT: fdiv v0.4s, v0.4s, v1.4s
+; CHECK-NEXT: ret
+ %r = fdiv <4 x float> %a, <float 2.0, float 4.0, float 8.0, float 16.0>
+ ret <4 x float> %r
+}
+
+define <vscale x 4 x float> @divnxv4f32_2(<vscale x 4 x float> %a) nounwind {
+; CHECK-LABEL: divnxv4f32_2:
+; CHECK: // %bb.0:
+; CHECK-NEXT: fmov z1.s, #2.00000000
+; CHECK-NEXT: ptrue p0.s
+; CHECK-NEXT: fdiv z0.s, p0/m, z0.s, z1.s
+; CHECK-NEXT: ret
+ %r = fdiv <vscale x 4 x float> %a, splat (float 2.0)
+ ret <vscale x 4 x float> %r
+}
More information about the llvm-commits
mailing list