[llvm] [RISCV] Explicitly set FRM defs as non-dead to prevent their reordering with instructions that may use it (PR #135176)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 10 08:03:28 PDT 2025


================
@@ -20926,6 +20926,15 @@ RISCVTargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI,
 
 void RISCVTargetLowering::AdjustInstrPostInstrSelection(MachineInstr &MI,
                                                         SDNode *Node) const {
+  // If instruction defines FRM operand, conservatively set it as non-dead to
+  // express data dependency with FRM users and prevent incorrect instruction
+  // reordering (these defs are marked as dead because at the moment of
+  // instruction emission they actually don't have any uses - they are added
+  // later in this hook).
----------------
topperc wrote:

I don't think the code in InstrEmitter that controls the setting of the dead flag would see them even if they were done earlier. It only checks glued nodes or explicit data dependencies. Neither apply to the input case.

https://github.com/llvm/llvm-project/pull/135176


More information about the llvm-commits mailing list