Skip to content

Commit 4827265

Browse files
committed
[RISCV] Add missing hasPostISelHook = 1 to vector pseudos that might read FRM.
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.
1 parent 9a7519f commit 4827265

File tree

2 files changed

+15
-9
lines changed

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
@@ -2617,6 +2617,13 @@ bool RISCVInstrInfo::verifyInstruction(const MachineInstr &MI,
26172617
}
26182618
}
26192619

2620+
if (int Idx = RISCVII::getFRMOpNum(Desc);
2621+
Idx >= 0 && MI.getOperand(Idx).getImm() == RISCVFPRndMode::DYN &&
2622+
!MI.readsRegister(RISCV::FRM, /*TRI=*/nullptr)) {
2623+
ErrInfo = "dynamic rounding mode should read FRM";
2624+
return false;
2625+
}
2626+
26202627
return true;
26212628
}
26222629

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
//===----------------------------------------------------------------------===//
@@ -6628,9 +6628,10 @@ defm PseudoVFNCVT_F_X : VPseudoVNCVTF_W_RM;
66286628
defm PseudoVFNCVT_RM_F_XU : VPseudoVNCVTF_RM_W;
66296629
defm PseudoVFNCVT_RM_F_X : VPseudoVNCVTF_RM_W;
66306630

6631-
let hasSideEffects = 0, hasPostISelHook = 1 in
6631+
let hasSideEffects = 0, hasPostISelHook = 1 in {
66326632
defm PseudoVFNCVT_F_F : VPseudoVNCVTD_W_RM;
66336633
defm PseudoVFNCVTBF16_F_F : VPseudoVNCVTD_W_RM;
6634+
}
66346635

66356636
defm PseudoVFNCVT_ROD_F_F : VPseudoVNCVTD_W;
66366637
} // mayRaiseFPException = true
@@ -6666,8 +6667,7 @@ let Predicates = [HasVInstructionsAnyF] in {
66666667
//===----------------------------------------------------------------------===//
66676668
// 14.3. Vector Single-Width Floating-Point Reduction Instructions
66686669
//===----------------------------------------------------------------------===//
6669-
let mayRaiseFPException = true,
6670-
hasSideEffects = 0 in {
6670+
let mayRaiseFPException = true, hasSideEffects = 0, hasPostISelHook = 1 in {
66716671
defm PseudoVFREDOSUM : VPseudoVFREDO_VS_RM;
66726672
defm PseudoVFREDUSUM : VPseudoVFRED_VS_RM;
66736673
}
@@ -6679,9 +6679,8 @@ defm PseudoVFREDMAX : VPseudoVFREDMINMAX_VS;
66796679
//===----------------------------------------------------------------------===//
66806680
// 14.4. Vector Widening Floating-Point Reduction Instructions
66816681
//===----------------------------------------------------------------------===//
6682-
let IsRVVWideningReduction = 1,
6683-
hasSideEffects = 0,
6684-
mayRaiseFPException = true in {
6682+
let IsRVVWideningReduction = 1, hasSideEffects = 0, mayRaiseFPException = true,
6683+
hasPostISelHook = 1 in {
66856684
defm PseudoVFWREDUSUM : VPseudoVFWRED_VS_RM;
66866685
defm PseudoVFWREDOSUM : VPseudoVFWREDO_VS_RM;
66876686
}

0 commit comments

Comments
 (0)