[llvm] 910ca0e - [RISCV][NFC] Add tests for checking isnan patterns

Sam Elliott via llvm-commits llvm-commits at lists.llvm.org
Sat May 2 06:57:51 PDT 2020


Author: Sam Elliott
Date: 2020-05-02T14:57:18+01:00
New Revision: 910ca0e435913be2c4cd8e7d9d12a0f4c759a215

URL: https://github.com/llvm/llvm-project/commit/910ca0e435913be2c4cd8e7d9d12a0f4c759a215
DIFF: https://github.com/llvm/llvm-project/commit/910ca0e435913be2c4cd8e7d9d12a0f4c759a215.diff

LOG: [RISCV][NFC] Add tests for checking isnan patterns

Summary:
I worked on adding some SelectionDag patterns to address code generated by these
examples, which came out of some differential testing against GCC. The pattern
additions will be in a follow-up patch.

Reviewers: luismarques, asb

Reviewed By: luismarques, asb

Differential Revision: https://reviews.llvm.org/D78907

Added: 
    llvm/test/CodeGen/RISCV/double-isnan.ll
    llvm/test/CodeGen/RISCV/float-isnan.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/CodeGen/RISCV/double-isnan.ll b/llvm/test/CodeGen/RISCV/double-isnan.ll
new file mode 100644
index 000000000000..d9443ddc19b8
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/double-isnan.ll
@@ -0,0 +1,39 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv32 -mattr=+d -target-abi ilp32d -verify-machineinstrs \
+; RUN:   < %s | FileCheck -check-prefix=RV32IFD %s
+; RUN: llc -mtriple=riscv64 -mattr=+d -target-abi lp64d -verify-machineinstrs \
+; RUN:   < %s | FileCheck -check-prefix=RV64IFD %s
+
+define zeroext i1 @double_is_nan(double %a) nounwind {
+; RV32IFD-LABEL: double_is_nan:
+; RV32IFD:       # %bb.0:
+; RV32IFD-NEXT:    feq.d a0, fa0, fa0
+; RV32IFD-NEXT:    and a0, a0, a0
+; RV32IFD-NEXT:    seqz a0, a0
+; RV32IFD-NEXT:    ret
+;
+; RV64IFD-LABEL: double_is_nan:
+; RV64IFD:       # %bb.0:
+; RV64IFD-NEXT:    feq.d a0, fa0, fa0
+; RV64IFD-NEXT:    and a0, a0, a0
+; RV64IFD-NEXT:    seqz a0, a0
+; RV64IFD-NEXT:    ret
+  %1 = fcmp uno double %a, 0.000000e+00
+  ret i1 %1
+}
+
+define zeroext i1 @double_not_nan(double %a) nounwind {
+; RV32IFD-LABEL: double_not_nan:
+; RV32IFD:       # %bb.0:
+; RV32IFD-NEXT:    feq.d a0, fa0, fa0
+; RV32IFD-NEXT:    and a0, a0, a0
+; RV32IFD-NEXT:    ret
+;
+; RV64IFD-LABEL: double_not_nan:
+; RV64IFD:       # %bb.0:
+; RV64IFD-NEXT:    feq.d a0, fa0, fa0
+; RV64IFD-NEXT:    and a0, a0, a0
+; RV64IFD-NEXT:    ret
+  %1 = fcmp ord double %a, 0.000000e+00
+  ret i1 %1
+}

diff  --git a/llvm/test/CodeGen/RISCV/float-isnan.ll b/llvm/test/CodeGen/RISCV/float-isnan.ll
new file mode 100644
index 000000000000..0a716d7ea554
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/float-isnan.ll
@@ -0,0 +1,39 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv32 -mattr=+f -target-abi ilp32f -verify-machineinstrs \
+; RUN:   < %s | FileCheck -check-prefix=RV32IF %s
+; RUN: llc -mtriple=riscv64 -mattr=+f -target-abi lp64f -verify-machineinstrs \
+; RUN:   < %s | FileCheck -check-prefix=RV64IF %s
+
+define zeroext i1 @float_is_nan(float %a) nounwind {
+; RV32IF-LABEL: float_is_nan:
+; RV32IF:       # %bb.0:
+; RV32IF-NEXT:    feq.s a0, fa0, fa0
+; RV32IF-NEXT:    and a0, a0, a0
+; RV32IF-NEXT:    seqz a0, a0
+; RV32IF-NEXT:    ret
+;
+; RV64IF-LABEL: float_is_nan:
+; RV64IF:       # %bb.0:
+; RV64IF-NEXT:    feq.s a0, fa0, fa0
+; RV64IF-NEXT:    and a0, a0, a0
+; RV64IF-NEXT:    seqz a0, a0
+; RV64IF-NEXT:    ret
+  %1 = fcmp uno float %a, 0.000000e+00
+  ret i1 %1
+}
+
+define zeroext i1 @float_not_nan(float %a) nounwind {
+; RV32IF-LABEL: float_not_nan:
+; RV32IF:       # %bb.0:
+; RV32IF-NEXT:    feq.s a0, fa0, fa0
+; RV32IF-NEXT:    and a0, a0, a0
+; RV32IF-NEXT:    ret
+;
+; RV64IF-LABEL: float_not_nan:
+; RV64IF:       # %bb.0:
+; RV64IF-NEXT:    feq.s a0, fa0, fa0
+; RV64IF-NEXT:    and a0, a0, a0
+; RV64IF-NEXT:    ret
+  %1 = fcmp ord float %a, 0.000000e+00
+  ret i1 %1
+}


        


More information about the llvm-commits mailing list