From 9388ff494a554e1f5d529be3636f9e1596fbf035 Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Sun, 16 Aug 2026 01:24:48 +0800 Subject: [RISCV][GlobalISel] Select word division pseudos --- backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'backend/lib/Target') diff --git a/backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp b/backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp index 854b6a5..1d7aec2 100644 --- a/backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp +++ b/backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp @@ -185,7 +185,10 @@ public: const TargetDescription &Target) const override { if (Instruction.opcode() == instructionOpcode(InstructionOpcode::G_SLLW) || Instruction.opcode() == instructionOpcode(InstructionOpcode::G_SRAW) || - Instruction.opcode() == instructionOpcode(InstructionOpcode::G_SRLW)) { + Instruction.opcode() == instructionOpcode(InstructionOpcode::G_SRLW) || + Instruction.opcode() == instructionOpcode(InstructionOpcode::G_DIVW) || + Instruction.opcode() == instructionOpcode(InstructionOpcode::G_DIVUW) || + Instruction.opcode() == instructionOpcode(InstructionOpcode::G_REMUW)) { const std::optional Type = resultType(Function, Instruction); const std::optional Left = operandType(Function, Instruction, 1); const std::optional Right = operandType(Function, Instruction, 2); @@ -349,6 +352,12 @@ public: return Instruction.setOpcode(instructionOpcode(InstructionOpcode::SRAW)); if (Instruction.opcode() == instructionOpcode(InstructionOpcode::G_SRLW)) return Instruction.setOpcode(instructionOpcode(InstructionOpcode::SRLW)); + if (Instruction.opcode() == instructionOpcode(InstructionOpcode::G_DIVW)) + return Instruction.setOpcode(instructionOpcode(InstructionOpcode::DIVW)); + if (Instruction.opcode() == instructionOpcode(InstructionOpcode::G_DIVUW)) + return Instruction.setOpcode(instructionOpcode(InstructionOpcode::DIVUW)); + if (Instruction.opcode() == instructionOpcode(InstructionOpcode::G_REMUW)) + return Instruction.setOpcode(instructionOpcode(InstructionOpcode::REMUW)); const GenericOpcode Generic = static_cast(Instruction.opcode().value()); const std::optional Type = resultType(Function, Instruction); -- cgit v1.2.3