[PATCH] LoongArch: add "b{eq, ne}z" as an alias for "b{eq, ne}" on LA32R

Lulu Cai cailulu@loongson.cn
Sun Jan 4 02:11:12 GMT 2026


On 1/2/26 11:20 PM, Xi Ruoyao wrote:
> On Tue, 2025-12-23 at 17:44 +0800, Lulu Cai wrote:
>> LoongArch32 Reduced(LA32R) does not support "b{eq,ne}z rj, simm". We
>> added `-march=la32r` in gas to recognize it as an alias for "b{eq,ne} rj,
>> zero, simm". Currently, only `-march=la32r` is accepted, and it will not
>> be recognized as an alias when `-march` is not specified.
> GCC supports using #pragma GCC target to switch between LA32S and LA32R:
>
> void a() {...}
> #pragma GCC target ("arch=la32v1.0")
> void b() {...}
>
> When the code above is compiled, beqz/bnez in function "b" shouldn't be
> changed to beq/bne.  Thus GCC cannot pass -march= to GAS if this patch
> is applied.
>
> But in real life people often compile .s files with "gcc -c" instead of
> "as", and the .S files must be compiled with "gcc -c", not "as".  So
> this patch won't really help.
>
> Thus, this should be made a gas directive instead so GCC can emit the
> directive to change the behavior of beqz/bnez for each function.
>
After discussion, we have decided not to implement instruction aliasing. 
To ensure compatibility, we recommend that users prioritize instructions 
supported across all architectures.



More information about the Binutils mailing list