Skip to content

Commit 2df9328

Browse files
committed
[RISCV] Stop performFP_TO_INTCombine from folding with ISD::FRINT.
FRINT was added to matchRoundingOp after this function was written. So FRINT was not tested originally. For vectors, folding this causes us to create a CSR swap that tries to write 7 to FRM. This is an illegal value and will cause the CSR write to fail. While this might be a legal fold we could do, I'm disabling it for now so we can backport to LLVM 17 with the least risk. Differential Revision: https://reviews.llvm.org/D157583
1 parent d32e68a commit 2df9328

File tree

4 files changed

+1391
-1
lines changed

4 files changed

+1391
-1
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12019,7 +12019,11 @@ static SDValue performFP_TO_INTCombine(SDNode *N,
1201912019
return SDValue();
1202012020

1202112021
RISCVFPRndMode::RoundingMode FRM = matchRoundingOp(Src.getOpcode());
12022-
if (FRM == RISCVFPRndMode::Invalid)
12022+
// If the result is invalid, we didn't find a foldable instruction.
12023+
// If the result is dynamic, then we found an frint which we don't yet
12024+
// support. It will cause 7 to be written to the FRM CSR for vector.
12025+
// FIXME: We could support this by using VFCVT_X_F_VL/VFCVT_XU_F_VL below.
12026+
if (FRM == RISCVFPRndMode::Invalid || FRM == RISCVFPRndMode::DYN)
1202312027
return SDValue();
1202412028

1202512029
SDLoc DL(N);

0 commit comments

Comments
 (0)