17 Commits

Author SHA1 Message Date
Fangrui Song
eabaee0c59
[RISCV] Omit "@plt" in assembly output "call foo@plt" (#72467)
R_RISCV_CALL/R_RISCV_CALL_PLT distinction is not necessary and
R_RISCV_CALL has been deprecated. Since https://reviews.llvm.org/D132530
`call foo` assembles to R_RISCV_CALL_PLT. The `@plt` suffix is not
useful and can be removed now (matching AArch64 and PowerPC).

GNU assembler assembles `call foo` to RISCV_CALL_PLT since 2022-09
(70f35d72ef04cd23771875c1661c9975044a749c).

Without this patch, unconditionally changing MO_CALL to MO_PLT could
create `jump .L1@plt, a0`, which is invalid in LLVM integrated assembler
and GNU assembler.
2024-01-07 12:09:44 -08:00
Min-Yih Hsu
87f671756d
[RISCV] Use FLI + FNEG to materialize some negative FP constants (#70825)
Most of the FP constants supported by FLI are positive. For negative FP
constants X whose positive values is supported by FLI, we can use `(FNEG
(FLI -X))` to materialize X.
2023-10-31 17:52:50 -07:00
Craig Topper
8ff1422353 [RISCV] Fix incorrect use of Zfa fli instruction for negative minimum value. (#70411)
isSmallestNormalized() only considers the magnitude, not the sign.
2023-10-26 22:11:58 -07:00
Craig Topper
be0cbe9173 [RISCV] Add test cases showing fli being used for negative min normalized value.
We can only use fli for the positive normalized value.
2023-10-26 22:11:58 -07:00
Alex Bradbury
eae1e28cc2
[RISCV] Mark the Zfa extension as non-experimental (#68113)
Following the version bump in #67964 and the bug fix in #68026 I believe
we're ready to mark Zfa as non-experimental. I'll note the GCC torture
suite passes now with Zfa enabled (though it's more of a litmus test
than anything else).
2023-10-03 18:16:13 +01:00
Alex Bradbury
0152e1f2d5
[RISCV] Fix incorrect codegen for Zfa with negated forms of constants in the lookup table (#68026)
The logic in `RISCVLoadFPImm::getLoadFPImm` recognises that the only
supported negative value is -1.0, but due to a typo returns `false`
otherwise (entry 0, which is -1.0) rather than returning -1 (indicating
no match found).
2023-10-02 21:20:38 +01:00
Alex Bradbury
451255b207 [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.
2023-10-02 20:48:30 +01:00
Jun Sha (Joshua)
4bbbae61d3 [RISCV] Fix Zfa fceil/ffloor codegen bugs
D143982 confused ceil and floor. Ceil should use fround instructions with 'rup' and floor should use 'rdn'.

Differential Revision: https://reviews.llvm.org/D146516
2023-03-31 12:19:02 -07:00
Craig Topper
101cf0b8ab [RISCV] Add isReMaterializable to FLI instructions.
Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D146321
2023-03-17 12:16:37 -07:00
Craig Topper
c2bcb21cc6 [RISCV] Print Zfa fli instruction FP values in a more adaptive way.
Previously, we printed all constants in scientific notation with
6 digits of precision. This is not enough to accurately display
the smallest value, but increasing the precision would be too much
for other values.

This patch prints values with fractional bits using only as many digits as
needed. 1*2^-15 and 1*2^-16 will be printed in scientific notation while
the others are printed without scientific notation. The integer values
are printed with a single 0 after the decimal point.

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D145645
2023-03-10 07:57:44 -08:00
Craig Topper
73516b355c [RISCV] Don't parse the decimal minimum value for fli.s/fli.d/fli.h.
There are a couple bugs in the current support for this:
-We do all the parsing in single precision so any value less than or
 equal to the minimum fp32 is accepted as the minimum value for f64.
-To support fp16 minimum value, getLoadFP32Imm has a special case, but
 that causes a miscompile in CodeGen.

Differential Revision: https://reviews.llvm.org/D145542
2023-03-08 09:24:58 -08:00
Craig Topper
f2c1b1a7f5 [RISCV] Add test case for Zfa fli.s miscompile. NFC
The f32 matching code for fli was hacked to allow the f16 minimum value
to match for the fli.h instruction in the assembler. This was done
because the assembler parses the floating point literal for fli.h,
fli.s, and fli.d as a single precision value.

Unfortunately, this function is also used by CodeGen and causes
this value to be miscompiled for f32.
2023-03-07 19:53:07 -08:00
Jun Sha (Joshua)
ada2641460 [RISCV][CodeGen] Add codegen pattern for FLI instruction in experimental zfa extension
This patch implements experimental support for the RISCV Zfa extension as specified here: https://github.com/riscv/riscv-isa-manual/releases/download/draft-20221119-5234c63/riscv-spec.pdf, Ch. 25. This extension has not been ratified. Once ratified, it'll move out of experimental status.

This change adds codegen support for load-immediate instructions (fli.s/fli.d/fli.h).

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D141560
2023-03-07 14:27:48 +08:00
Craig Topper
3d0a5bf7de [RISCV] Add Zfa test cases for strict ONE and UEQ comparisons. NFC
These correspond to islessgreater and it inverse.
2023-02-18 17:28:10 -08:00
Jun Sha (Joshua)
df56b55e12 [RISCV][CodeGen] Add codegen patterns for experimental zfa extension (try 2)
Recommit by preames with commit message, various style cleanups, and unaddressed review comments corrected.

This patch implements experimental codegen support for the RISCV Zfa extension as specified here: https://github.com/riscv/riscv-isa-manual/releases/download/draft-20221119-5234c63/riscv-spec.pdf, Ch. 25. This extension has not been ratified.

This change does not include support for FLI (upcoming in a follow up change) or FCVTMOD (not relevant for C/C++).

Differential Revision: https://reviews.llvm.org/D143982
2023-02-17 10:28:08 -08:00
Philip Reames
80abf86d50 Revert "[RISCV][CodeGen] Add codegen pattern for experimental zfa extension (FLI and FCVTMOD not included)"
This reverts commit fc6d517e2f335c2ab2b14a34eb747a4703aca7e4.  It was submitted without an appropriate patch description.  Will reapply shortly.
2023-02-16 07:49:44 -08:00
Jun Sha (Joshua)
fc6d517e2f [RISCV][CodeGen] Add codegen pattern for experimental zfa extension (FLI and FCVTMOD not included) 2023-02-16 13:41:41 +08:00