[llvm] AArch64: Add FCANONICALIZE (PR #104429)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 10 01:19:18 PDT 2024
================
@@ -0,0 +1,168 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc --mtriple=aarch64 --mattr=+fullfp16 < %s | FileCheck %s --check-prefix=AARCH64
+
+declare half @llvm.fcanonicalize.f16(half)
+declare float @llvm.fcanonicalize.f32(float)
+declare double @llvm.fcanonicalize.f64(double)
+
+define half @fcanonicalize_half(half %x) {
+; AARCH64-LABEL: fcanonicalize_half:
+; AARCH64: // %bb.0:
+; AARCH64-NEXT: fminnm h0, h0, h0
+; AARCH64-NEXT: ret
+ %z = call half @llvm.canonicalize.f16(half %x)
+ ret half %z
+}
+
+define half @fcanonicalize_half_nnan(half %x) {
+; AARCH64-LABEL: fcanonicalize_half_nnan:
+; AARCH64: // %bb.0:
+; AARCH64-NEXT: fminnm h0, h0, h0
+; AARCH64-NEXT: ret
+ %z = call nnan half @llvm.canonicalize.f16(half %x)
+ ret half %z
+}
+
+define <2 x half> @fcanonicalize_v2f16(<2 x half> %x) {
+; AARCH64-LABEL: fcanonicalize_v2f16:
+; AARCH64: // %bb.0:
+; AARCH64-NEXT: fminnm v0.4h, v0.4h, v0.4h
+; AARCH64-NEXT: ret
+ %z = call <2 x half> @llvm.canonicalize.v2f16(<2 x half> %x)
+ ret <2 x half> %z
+}
+
+define <2 x half> @fcanonicalize_v2f16_nnan(<2 x half> %x) {
+; AARCH64-LABEL: fcanonicalize_v2f16_nnan:
+; AARCH64: // %bb.0:
+; AARCH64-NEXT: fminnm v0.4h, v0.4h, v0.4h
+; AARCH64-NEXT: ret
+ %z = call nnan <2 x half> @llvm.canonicalize.v2f16(<2 x half> %x)
+ ret <2 x half> %z
+}
+
+define <4 x half> @fcanonicalize_v4f16(<4 x half> %x) {
+; AARCH64-LABEL: fcanonicalize_v4f16:
+; AARCH64: // %bb.0:
+; AARCH64-NEXT: fminnm v0.4h, v0.4h, v0.4h
+; AARCH64-NEXT: ret
+ %z = call <4 x half> @llvm.canonicalize.v4f16(<4 x half> %x)
+ ret <4 x half> %z
+}
+
+define <4 x half> @fcanonicalize_v4f16_nnan(<4 x half> %x) {
+; AARCH64-LABEL: fcanonicalize_v4f16_nnan:
+; AARCH64: // %bb.0:
+; AARCH64-NEXT: fminnm v0.4h, v0.4h, v0.4h
+; AARCH64-NEXT: ret
+ %z = call nnan <4 x half> @llvm.canonicalize.v4f16(<4 x half> %x)
+ ret <4 x half> %z
+}
+
+define <8 x half> @fcanonicalize_v8f16(<8 x half> %x) {
+; AARCH64-LABEL: fcanonicalize_v8f16:
+; AARCH64: // %bb.0:
+; AARCH64-NEXT: fminnm v0.8h, v0.8h, v0.8h
+; AARCH64-NEXT: ret
+ %z = call <8 x half> @llvm.canonicalize.v8f16(<8 x half> %x)
+ ret <8 x half> %z
+}
+
+define <8 x half> @fcanonicalize_v8f16_nnan(<8 x half> %x) {
+; AARCH64-LABEL: fcanonicalize_v8f16_nnan:
+; AARCH64: // %bb.0:
+; AARCH64-NEXT: fminnm v0.8h, v0.8h, v0.8h
+; AARCH64-NEXT: ret
+ %z = call nnan <8 x half> @llvm.canonicalize.v8f16(<8 x half> %x)
+ ret <8 x half> %z
+}
+
+define float @fcanonicalize_float(float %x) {
----------------
arsenm wrote:
```suggestion
define float @fcanonicalize_f32(float %x) {
```
https://github.com/llvm/llvm-project/pull/104429
More information about the llvm-commits
mailing list