[llvm] [RISCV] Use C.ADD when OR is not compressible due to register restriction (PR #156044)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 29 08:14:41 PDT 2025
================
@@ -1178,7 +1178,21 @@ bool RISCVAsmPrinter::lowerToMCInst(const MachineInstr *MI, MCInst &OutMI) {
if (lowerRISCVVMachineInstrToMCInst(MI, OutMI, STI))
return false;
- OutMI.setOpcode(MI->getOpcode());
+ unsigned Opcode = MI->getOpcode();
+ // If we have a disjoint OR which isn't compressible as an c.or, we can
+ // convert it to a c.add which doesn't have the gprc register restriction.
+ if (STI->hasStdExtZca() && Opcode == RISCV::OR &&
+ MI->getFlag(MachineInstr::Disjoint)) {
----------------
topperc wrote:
I think we need to fix `TargetInstrInfo::reassociateOps` to clear the Disjoint flag when reassociating. It clears the wrap flags and exact flag, but not disjoint.
https://github.com/llvm/llvm-project/pull/156044
More information about the llvm-commits
mailing list