[PATCH] D146516: [RISCV][Zfa] Fix FROUND codegen bugs

Jun Sha via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 21 04:54:09 PDT 2023


joshua-arch1 created this revision.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, arichardson.
Herald added a project: All.
joshua-arch1 requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead, eopXD, MaskRay.
Herald added a project: LLVM.

In https://reviews.llvm.org/D143982, I confused ceil and floor. Ceil should correspond to rup and floor should correspond to rdn.


https://reviews.llvm.org/D146516

Files:
  llvm/lib/Target/RISCV/RISCVInstrInfoZfa.td
  llvm/test/CodeGen/RISCV/double-zfa.ll
  llvm/test/CodeGen/RISCV/float-zfa.ll
  llvm/test/CodeGen/RISCV/half-zfa.ll


Index: llvm/test/CodeGen/RISCV/half-zfa.ll
===================================================================
--- llvm/test/CodeGen/RISCV/half-zfa.ll
+++ llvm/test/CodeGen/RISCV/half-zfa.ll
@@ -41,7 +41,7 @@
 define half @fround_h_2(half %a) nounwind {
 ; CHECK-LABEL: fround_h_2:
 ; CHECK:       # %bb.0:
-; CHECK-NEXT:    fround.h fa0, fa0, rup
+; CHECK-NEXT:    fround.h fa0, fa0, rdn
 ; CHECK-NEXT:    ret
   %call = tail call half @llvm.floor.f16(half %a) nounwind readnone
   ret half %call
@@ -53,7 +53,7 @@
 define half @fround_h_3(half %a) nounwind {
 ; CHECK-LABEL: fround_h_3:
 ; CHECK:       # %bb.0:
-; CHECK-NEXT:    fround.h fa0, fa0, rdn
+; CHECK-NEXT:    fround.h fa0, fa0, rup
 ; CHECK-NEXT:    ret
   %call = tail call half @llvm.ceil.f16(half %a) nounwind readnone
   ret half %call
Index: llvm/test/CodeGen/RISCV/float-zfa.ll
===================================================================
--- llvm/test/CodeGen/RISCV/float-zfa.ll
+++ llvm/test/CodeGen/RISCV/float-zfa.ll
@@ -125,7 +125,7 @@
 define float @fround_s_2(float %a) nounwind {
 ; CHECK-LABEL: fround_s_2:
 ; CHECK:       # %bb.0:
-; CHECK-NEXT:    fround.s fa0, fa0, rup
+; CHECK-NEXT:    fround.s fa0, fa0, rdn
 ; CHECK-NEXT:    ret
   %call = tail call float @floorf(float %a) nounwind readnone
   ret float %call
@@ -137,7 +137,7 @@
 define float @fround_s_3(float %a) nounwind {
 ; CHECK-LABEL: fround_s_3:
 ; CHECK:       # %bb.0:
-; CHECK-NEXT:    fround.s fa0, fa0, rdn
+; CHECK-NEXT:    fround.s fa0, fa0, rup
 ; CHECK-NEXT:    ret
   %call = tail call float @ceilf(float %a) nounwind readnone
   ret float %call
Index: llvm/test/CodeGen/RISCV/double-zfa.ll
===================================================================
--- llvm/test/CodeGen/RISCV/double-zfa.ll
+++ llvm/test/CodeGen/RISCV/double-zfa.ll
@@ -170,7 +170,7 @@
 define double @fround_d_2(double %a) nounwind {
 ; CHECK-LABEL: fround_d_2:
 ; CHECK:       # %bb.0:
-; CHECK-NEXT:    fround.d fa0, fa0, rup
+; CHECK-NEXT:    fround.d fa0, fa0, rdn
 ; CHECK-NEXT:    ret
   %call = tail call double @floor(double %a) nounwind readnone
   ret double %call
@@ -182,7 +182,7 @@
 define double @fround_d_3(double %a) nounwind {
 ; CHECK-LABEL: fround_d_3:
 ; CHECK:       # %bb.0:
-; CHECK-NEXT:    fround.d fa0, fa0, rdn
+; CHECK-NEXT:    fround.d fa0, fa0, rup
 ; CHECK-NEXT:    ret
   %call = tail call double @ceil(double %a) nounwind readnone
   ret double %call
Index: llvm/lib/Target/RISCV/RISCVInstrInfoZfa.td
===================================================================
--- llvm/lib/Target/RISCV/RISCVInstrInfoZfa.td
+++ llvm/lib/Target/RISCV/RISCVInstrInfoZfa.td
@@ -226,8 +226,8 @@
 
 def: Pat<(any_fround FPR64 : $rs1), (FROUND_D FPR64 : $rs1, 0b100)>;
 def: Pat<(any_froundeven FPR64 : $rs1), (FROUND_D FPR64 : $rs1, 0b000)>;
-def: Pat<(any_ffloor FPR64 : $rs1), (FROUND_D FPR64 : $rs1, 0b011)>;
-def: Pat<(any_fceil FPR64 : $rs1), (FROUND_D FPR64 : $rs1, 0b010)>;
+def: Pat<(any_ffloor FPR64 : $rs1), (FROUND_D FPR64 : $rs1, 0b010)>;
+def: Pat<(any_fceil FPR64 : $rs1), (FROUND_D FPR64 : $rs1, 0b011)>;
 def: Pat<(any_ftrunc FPR64 : $rs1), (FROUND_D FPR64 : $rs1, 0b001)>;
 
 def: PatSetCC<FPR64, strict_fsetcc, SETLT, FLTQ_D>;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146516.506920.patch
Type: text/x-patch
Size: 3206 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230321/a0773b51/attachment.bin>


More information about the llvm-commits mailing list