Re: [PATCH] MIPS: Ingenic: Allow assembler reordering in the XBurst secondary entry
From: Maciej W. Rozycki
Date: Fri Nov 20 2026 - 11:14:41 EST
On Fri, 20 Nov 2026, David Laight wrote:
> > Remove .set noreorder and the two explicit delay-slot nops from the
> > XBurst secondary CPU reset entry. GNU as emits identical reset-entry
> > instructions with reordering enabled in both the CI20 and generic
> > MIPS64r2 Ingenic SMP builds.
>
> If the ordering actually mattered then the fact that the current toolchain
> doesn't break thinks isn't enough to guarantee that a future version
> won't find some way of generating invalid code.
Nope, unless there is an explicit need to prevent GAS from ensuring that
pipeline hazards are taken care of user code is expected to use the
standard `reorder' mode.
Legitimate examples are scheduling a branch delay slot when there is a
data dependency (the vast majority of cases, e.g. writing to a register
the branch reads from) or when you do want to exploit a pipeline hazard
for some reason (RFE in a branch delay slot comes to mind).
Otherwise the assembler ensures code semantics as written. If that is
not the case, then it is a bug in the tool that needs to be fixed. You
can't write code in a specific way "because there may be a bug in a future
version of a tool that could trigger if I wrote this differently," that's
ridiculous.
From experience people tend to use `noreorder' when there's a missed
optimisation opportunity and they can't be bothered to file a bug against
GAS. Or they take code produced by a compiler and tweak it by hand not
bothering to rewrite it for `reorder' mode. This has caused real damage
and hard to chase bugs.
> The explicit nop in the delay slots might even be there because there
> is another reason for the .set noreorder.
Then `noreorder' blocks are supposed to wrap actual instruction sequences
that require manual scheduling and not the whole function, and the reason
for the individual `noreorder' blocks needs to be documented within the
code.
Conversely I had to fix code many times when someone used `noreorder'
needlessly and didn't take pipeline hazards into account of processors
they didn't care of. That's just the wrong use of the tool.
And yes, I did put a lot of effort into GAS to get many missed scheduling
optimisations fixed. Most recently over the last weekend, concerning the
HI/LO accumulator registers. At worst you'll get an extraneous NOP or a
couple. In the vast majority of cases this is not a big deal and in all
cases it's better than an unsatisfied pipeline hazard.
Maciej