Skip to content

Commit a0dfd3d

Browse files
authored andcommitted
[RISCV] Add missing hasPostISelHook = 1 to vector pseudos that might read FRM. (#114186)
We need an implicit FRM read operand anytime the rounding mode is dynamic. The post isel hook is responsible for this when isel creates an instruction with dynamic rounding mode. Add a MachineVerifier check to verify the operand is present. (cherry picked from commit 71b6f6b)
1 parent e21dc4b commit a0dfd3d

File tree

Image for: File tree

2 files changed

Image for: 2 files changed
+15
-9
lines changed

2 files changed

Image for: 2 files changed
+15
-9
lines changed

‎llvm/lib/Target/RISCV/RISCVInstrInfo.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2536,6 +2536,13 @@ bool RISCVInstrInfo::verifyInstruction(const MachineInstr &MI,
25362536
}
25372537
}
25382538

2539+
if (int Idx = RISCVII::getFRMOpNum(Desc);
2540+
Idx >= 0 && MI.getOperand(Idx).getImm() == RISCVFPRndMode::DYN &&
2541+
!MI.readsRegister(RISCV::FRM, /*TRI=*/nullptr)) {
2542+
ErrInfo = "dynamic rounding mode should read FRM";
2543+
return false;
2544+
}
2545+
25392546
return true;
25402547
}
25412548

‎llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6471,7 +6471,7 @@ defm PseudoVFRDIV : VPseudoVFRDIV_VF_RM;
64716471
//===----------------------------------------------------------------------===//
64726472
// 13.5. Vector Widening Floating-Point Multiply
64736473
//===----------------------------------------------------------------------===//
6474-
let mayRaiseFPException = true, hasSideEffects = 0 in {
6474+
let mayRaiseFPException = true, hasSideEffects = 0, hasPostISelHook = 1 in {
64756475
defm PseudoVFWMUL : VPseudoVWMUL_VV_VF_RM;
64766476
}
64776477

@@ -6504,7 +6504,7 @@ defm PseudoVFWMACCBF16 : VPseudoVWMAC_VV_VF_BF_RM;
65046504
//===----------------------------------------------------------------------===//
65056505
// 13.8. Vector Floating-Point Square-Root Instruction
65066506
//===----------------------------------------------------------------------===//
6507-
let mayRaiseFPException = true, hasSideEffects = 0 in
6507+
let mayRaiseFPException = true, hasSideEffects = 0, hasPostISelHook = 1 in
65086508
defm PseudoVFSQRT : VPseudoVSQR_V_RM;
65096509

65106510
//===----------------------------------------------------------------------===//
@@ -6516,7 +6516,7 @@ defm PseudoVFRSQRT7 : VPseudoVRCP_V;
65166516
//===----------------------------------------------------------------------===//
65176517
// 13.10. Vector Floating-Point Reciprocal Estimate Instruction
65186518
//===----------------------------------------------------------------------===//
6519-
let mayRaiseFPException = true, hasSideEffects = 0 in
6519+
let mayRaiseFPException = true, hasSideEffects = 0, hasPostISelHook = 1 in
65206520
defm PseudoVFREC7 : VPseudoVRCP_V_RM;
65216521

65226522
//===----------------------------------------------------------------------===//
@@ -6627,9 +6627,10 @@ defm PseudoVFNCVT_F_X : VPseudoVNCVTF_W_RM;
66276627
defm PseudoVFNCVT_RM_F_XU : VPseudoVNCVTF_RM_W;
66286628
defm PseudoVFNCVT_RM_F_X : VPseudoVNCVTF_RM_W;
66296629

6630-
let hasSideEffects = 0, hasPostISelHook = 1 in
6630+
let hasSideEffects = 0, hasPostISelHook = 1 in {
66316631
defm PseudoVFNCVT_F_F : VPseudoVNCVTD_W_RM;
66326632
defm PseudoVFNCVTBF16_F_F : VPseudoVNCVTD_W_RM;
6633+
}
66336634

66346635
defm PseudoVFNCVT_ROD_F_F : VPseudoVNCVTD_W;
66356636
} // mayRaiseFPException = true
@@ -6665,8 +6666,7 @@ let Predicates = [HasVInstructionsAnyF] in {
66656666
//===----------------------------------------------------------------------===//
66666667
// 14.3. Vector Single-Width Floating-Point Reduction Instructions
66676668
//===----------------------------------------------------------------------===//
6668-
let mayRaiseFPException = true,
6669-
hasSideEffects = 0 in {
6669+
let mayRaiseFPException = true, hasSideEffects = 0, hasPostISelHook = 1 in {
66706670
defm PseudoVFREDOSUM : VPseudoVFREDO_VS_RM;
66716671
defm PseudoVFREDUSUM : VPseudoVFRED_VS_RM;
66726672
}
@@ -6678,9 +6678,8 @@ defm PseudoVFREDMAX : VPseudoVFREDMINMAX_VS;
66786678
//===----------------------------------------------------------------------===//
66796679
// 14.4. Vector Widening Floating-Point Reduction Instructions
66806680
//===----------------------------------------------------------------------===//
6681-
let IsRVVWideningReduction = 1,
6682-
hasSideEffects = 0,
6683-
mayRaiseFPException = true in {
6681+
let IsRVVWideningReduction = 1, hasSideEffects = 0, mayRaiseFPException = true,
6682+
hasPostISelHook = 1 in {
66846683
defm PseudoVFWREDUSUM : VPseudoVFWRED_VS_RM;
66856684
defm PseudoVFWREDOSUM : VPseudoVFWREDO_VS_RM;
66866685
}

0 commit comments

Image for: 0 commit comments
Comments
 (0)