Re: [PATCH v15 27/30] LoongArch: KVM: Implement vcpu world switch

From: Xi Ruoyao
Date: Wed Jun 28 2023 - 06:42:40 EST


On Wed, 2023-06-28 at 18:22 +0800, WANG Xuerui wrote:
> > is "ori t0, zero, CSR_PRMD_PIE" hard to understand? It is basic
> > arithmetic instr and easy to understand also. To be frank I do not
> > see the advantage of using li.w, also there is no document that
> > pseudo-instruction should be used with high priority.

> It depends on the reader. Sure the semantics are the same, but with "ori
> xx, zero, xx" someone's always going to wonder "why do 'x = 0 |
> something' when you can simply li.w", because even if it's easy to
> understand it's still an extra level of indirection.
>
> And I've given the historical and general software engineering
> perspective too; it's not something set in stone, but I'd expect general
> software development best practices and minimizing any *possible* reader
> confusion to be acceptable.

The pseudo *should* be the high priority in general. If we don't
consider the pseudos high priority, people will start to load immediates
with "their own way", like writing "addi.w $t0, $zero, 42" or even "xori
$t0, $zero, 42" for "42". These may puzzle the uarch, causing a
performance worse than "ori $t0, $zero, 42". So the only rationale
things are either:

1. Telling people always use pseudos if possible.

or

2. Telling people "remember to use ori for loading small immediates, not
other instructions".

1 is obviously easier.

--
Xi Ruoyao <xry111@xxxxxxxxxxx>
School of Aerospace Science and Technology, Xidian University