[llvm] 451255b - [RISCV][test] Extend test coverage for Zfa's fli instructions to cover miscompile

Alex Bradbury via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 2 12:48:59 PDT 2023


Author: Alex Bradbury
Date: 2023-10-02T20:48:30+01:00
New Revision: 451255b207c8630534b417c00de387ee98cf89e9

URL: https://github.com/llvm/llvm-project/commit/451255b207c8630534b417c00de387ee98cf89e9
DIFF: https://github.com/llvm/llvm-project/commit/451255b207c8630534b417c00de387ee98cf89e9.diff

LOG: [RISCV][test] Extend test coverage for Zfa's fli instructions to cover miscompile

There's a miscompile currently for negative numbers (other than -1) that
are the negated form of numbers in the fli lookup table. This adds tests
that capture the issue, with a fix to follow in a separate commit/PR.

Added: 
    

Modified: 
    llvm/test/CodeGen/RISCV/double-zfa.ll
    llvm/test/CodeGen/RISCV/float-zfa.ll
    llvm/test/CodeGen/RISCV/half-zfa-fli.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/CodeGen/RISCV/double-zfa.ll b/llvm/test/CodeGen/RISCV/double-zfa.ll
index 881430f6f5ffdd2..00481fb367136f0 100644
--- a/llvm/test/CodeGen/RISCV/double-zfa.ll
+++ b/llvm/test/CodeGen/RISCV/double-zfa.ll
@@ -133,6 +133,25 @@ define double @loadfpimm15() {
   ret double 0x0008000000000000
 }
 
+define double @loadfpimm16() {
+; CHECK-LABEL: loadfpimm16:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    fli.d fa0, -1.0
+; CHECK-NEXT:    ret
+  ret double -1.0
+}
+
+; Ensure fli isn't incorrectly used for negated versions of numbers in the fli
+; table.
+; FIXME: Codegen is incorrect.
+define double @loadfpimm17() {
+; CHECK-LABEL: loadfpimm17:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    fli.d fa0, -1.0
+; CHECK-NEXT:    ret
+  ret double -2.0
+}
+
 declare double @llvm.minimum.f64(double, double)
 
 define double @fminm_d(double %a, double %b) nounwind {

diff  --git a/llvm/test/CodeGen/RISCV/float-zfa.ll b/llvm/test/CodeGen/RISCV/float-zfa.ll
index 94da29bd6bece8a..e41aa631d38a6ee 100644
--- a/llvm/test/CodeGen/RISCV/float-zfa.ll
+++ b/llvm/test/CodeGen/RISCV/float-zfa.ll
@@ -87,6 +87,25 @@ define float @loadfpimm10() {
   ret float 0.00006103515625
 }
 
+define float @loadfpimm11() {
+; CHECK-LABEL: loadfpimm11:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    fli.s fa0, -1.0
+; CHECK-NEXT:    ret
+  ret float -1.0
+}
+
+; Ensure fli isn't incorrectly used for negated versions of numbers in the fli
+; table.
+; FIXME: Codegen is incorrect.
+define float @loadfpimm12() {
+; CHECK-LABEL: loadfpimm12:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    fli.s fa0, -1.0
+; CHECK-NEXT:    ret
+  ret float -2.0
+}
+
 declare float @llvm.minimum.f32(float, float)
 
 define float @fminm_s(float %a, float %b) nounwind {

diff  --git a/llvm/test/CodeGen/RISCV/half-zfa-fli.ll b/llvm/test/CodeGen/RISCV/half-zfa-fli.ll
index f82ae5c00d15962..90d5bb4b53ba46d 100644
--- a/llvm/test/CodeGen/RISCV/half-zfa-fli.ll
+++ b/llvm/test/CodeGen/RISCV/half-zfa-fli.ll
@@ -180,3 +180,34 @@ define half @loadfpimm12() {
 ; ZFHMIN-NEXT:    ret
   ret half 0xH7c01
 }
+
+define half @loadfpimm13() {
+; CHECK-LABEL: loadfpimm13:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    fli.h fa0, -1.0
+; CHECK-NEXT:    ret
+;
+; ZFHMIN-LABEL: loadfpimm13:
+; ZFHMIN:       # %bb.0:
+; ZFHMIN-NEXT:    lui a0, %hi(.LCPI12_0)
+; ZFHMIN-NEXT:    flh fa0, %lo(.LCPI12_0)(a0)
+; ZFHMIN-NEXT:    ret
+  ret half -1.0
+}
+
+; Ensure fli isn't incorrectly used for negated versions of numbers in the fli
+; table.
+; FIXME: Codegen is incorrect when Zfa is enabled.
+define half @loadfpimm14() {
+; CHECK-LABEL: loadfpimm14:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    fli.h fa0, -1.0
+; CHECK-NEXT:    ret
+;
+; ZFHMIN-LABEL: loadfpimm14:
+; ZFHMIN:       # %bb.0:
+; ZFHMIN-NEXT:    lui a0, 1048572
+; ZFHMIN-NEXT:    fmv.h.x fa0, a0
+; ZFHMIN-NEXT:    ret
+  ret half -2.0
+}


        


More information about the llvm-commits mailing list