[llvm] [RISCV] Add CompressPat for all cases in isCopyInstrImpl (PR #136875)
Alex Bradbury via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 24 08:01:05 PDT 2025
asb wrote:
> I'm mildly of the opinion that we should canonicalize the copy instead. Not a strongly held opinion or anything.
>
> Maybe instead of a specific canonicalizeCopyInst, we could introduce a generic optimizeInstruction which is called after mutation? It could canonicalize the copy, but could also e.g. fold a sh2add x2, x1, x0 to slli x2, x1, 2.
Good point. I'm seeing only a single static instance of that specific example (`sh?add` that can be a shift), but there are a few other potentials.
> Alternatively, if we wanted something localized, we could extend the late optimization pass we just added for branches to handle non-branch instructions.
Before that I had it in mind that the pseudo instruction expansion pass might become a canonicalisation + pseudo instruction expansion pass. But yes, there are a few possible places for this.
Just to give a holding pattern update: given the fact we suspect this isn't necessarily the best way of handling it I'm going through the other suboptimal or improperly canonicalised instructions to make sure I can follow up with a proposal that considers all the ones we care about. I suspect this looks like the optimizeInstruction idea, but will report back once I've checked.
https://github.com/llvm/llvm-project/pull/136875
More information about the llvm-commits
mailing list