Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LoongArch] Add test for scalar FP rounding #114968

Merged
merged 1 commit into from
Nov 5, 2024

Conversation

zhaoqi5
Copy link
Contributor

@zhaoqi5 zhaoqi5 commented Nov 5, 2024

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Nov 5, 2024

@llvm/pr-subscribers-backend-loongarch

Author: ZhaoQi (zhaoqi5)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/114968.diff

1 Files Affected:

  • (added) llvm/test/CodeGen/LoongArch/fp-rounding.ll (+124)
diff --git a/llvm/test/CodeGen/LoongArch/fp-rounding.ll b/llvm/test/CodeGen/LoongArch/fp-rounding.ll
new file mode 100644
index 00000000000000..19c4e3fb573da9
--- /dev/null
+++ b/llvm/test/CodeGen/LoongArch/fp-rounding.ll
@@ -0,0 +1,124 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc --mtriple=loongarch64 --mattr=-lsx < %s | FileCheck %s --check-prefix=NOLSX
+; RUN: llc --mtriple=loongarch64 --mattr=+lsx < %s | FileCheck %s --check-prefix=LSX
+
+;; ceilf
+define float @ceil_f32(float %i) nounwind {
+; NOLSX-LABEL: ceil_f32:
+; NOLSX:       # %bb.0: # %entry
+; NOLSX-NEXT:    b %plt(ceilf)
+;
+; LSX-LABEL: ceil_f32:
+; LSX:       # %bb.0: # %entry
+; LSX-NEXT:    b %plt(ceilf)
+entry:
+  %0 = call float @llvm.ceil.f32(float %i)
+  ret float %0
+}
+
+;; ceil
+define double @ceil_f64(double %i) nounwind {
+; NOLSX-LABEL: ceil_f64:
+; NOLSX:       # %bb.0: # %entry
+; NOLSX-NEXT:    b %plt(ceil)
+;
+; LSX-LABEL: ceil_f64:
+; LSX:       # %bb.0: # %entry
+; LSX-NEXT:    b %plt(ceil)
+entry:
+  %0 = call double @llvm.ceil.f64(double %i)
+  ret double %0
+}
+
+;; floorf
+define float @floor_f32(float %i) nounwind {
+; NOLSX-LABEL: floor_f32:
+; NOLSX:       # %bb.0: # %entry
+; NOLSX-NEXT:    b %plt(floorf)
+;
+; LSX-LABEL: floor_f32:
+; LSX:       # %bb.0: # %entry
+; LSX-NEXT:    b %plt(floorf)
+entry:
+  %0 = call float @llvm.floor.f32(float %i)
+  ret float %0
+}
+
+;; floor
+define double @floor_f64(double %i) nounwind {
+; NOLSX-LABEL: floor_f64:
+; NOLSX:       # %bb.0: # %entry
+; NOLSX-NEXT:    b %plt(floor)
+;
+; LSX-LABEL: floor_f64:
+; LSX:       # %bb.0: # %entry
+; LSX-NEXT:    b %plt(floor)
+entry:
+  %0 = call double @llvm.floor.f64(double %i)
+  ret double %0
+}
+
+;; truncf
+define float @trunc_f32(float %i) nounwind {
+; NOLSX-LABEL: trunc_f32:
+; NOLSX:       # %bb.0: # %entry
+; NOLSX-NEXT:    b %plt(truncf)
+;
+; LSX-LABEL: trunc_f32:
+; LSX:       # %bb.0: # %entry
+; LSX-NEXT:    b %plt(truncf)
+entry:
+  %0 = call float @llvm.trunc.f32(float %i)
+  ret float %0
+}
+
+;; trunc
+define double @trunc_f64(double %i) nounwind {
+; NOLSX-LABEL: trunc_f64:
+; NOLSX:       # %bb.0: # %entry
+; NOLSX-NEXT:    b %plt(trunc)
+;
+; LSX-LABEL: trunc_f64:
+; LSX:       # %bb.0: # %entry
+; LSX-NEXT:    b %plt(trunc)
+entry:
+  %0 = call double @llvm.trunc.f64(double %i)
+  ret double %0
+}
+
+;; roundevenf
+define float @roundeven_f32(float %i) nounwind {
+; NOLSX-LABEL: roundeven_f32:
+; NOLSX:       # %bb.0: # %entry
+; NOLSX-NEXT:    b %plt(roundevenf)
+;
+; LSX-LABEL: roundeven_f32:
+; LSX:       # %bb.0: # %entry
+; LSX-NEXT:    b %plt(roundevenf)
+entry:
+  %0 = call float @llvm.roundeven.f32(float %i)
+  ret float %0
+}
+
+;; roundeven
+define double @roundeven_f64(double %i) nounwind {
+; NOLSX-LABEL: roundeven_f64:
+; NOLSX:       # %bb.0: # %entry
+; NOLSX-NEXT:    b %plt(roundeven)
+;
+; LSX-LABEL: roundeven_f64:
+; LSX:       # %bb.0: # %entry
+; LSX-NEXT:    b %plt(roundeven)
+entry:
+  %0 = call double @llvm.roundeven.f64(double %i)
+  ret double %0
+}
+
+declare float @llvm.ceil.f32(float)
+declare double @llvm.ceil.f64(double)
+declare float @llvm.floor.f32(float)
+declare double @llvm.floor.f64(double)
+declare float @llvm.trunc.f32(float)
+declare double @llvm.trunc.f64(double)
+declare float @llvm.roundeven.f32(float)
+declare double @llvm.roundeven.f64(double)

@SixWeining SixWeining merged commit 4ff6205 into llvm:main Nov 5, 2024
8 of 10 checks passed
@zhaoqi5 zhaoqi5 deleted the test-for-fp-conv branch November 5, 2024 13:21
PhilippRados pushed a commit to PhilippRados/llvm-project that referenced this pull request Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants