Skip to content

[RISCV] Fix incorrect codegen for Zfa with negated forms of constants in the lookup table #68026

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

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ int RISCVLoadFPImm::getLoadFPImm(APFloat FPImm) {
if (Sign) {
if (Entry == 16)
return 0;
return false;
return -1;
}

return Entry;
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/CodeGen/RISCV/double-zfa.ll
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ define double @loadfpimm16() {

; 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: lui a0, %hi(.LCPI15_0)
; CHECK-NEXT: fld fa0, %lo(.LCPI15_0)(a0)
; CHECK-NEXT: ret
ret double -2.0
}
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/CodeGen/RISCV/float-zfa.ll
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ define float @loadfpimm11() {

; 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: lui a0, 786432
; CHECK-NEXT: fmv.w.x fa0, a0
; CHECK-NEXT: ret
ret float -2.0
}
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/CodeGen/RISCV/half-zfa-fli.ll
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,11 @@ define half @loadfpimm13() {

; 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: lui a0, 1048572
; CHECK-NEXT: fmv.h.x fa0, a0
; CHECK-NEXT: ret
;
; ZFHMIN-LABEL: loadfpimm14:
Expand Down