[PATCH] LoongArch: add "b{eq,ne}z" as an alias for "b{eq,ne}" on LA32R
Xi Ruoyao
xry111@xry111.site
Fri Jan 2 15:20:27 GMT 2026
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.
--
Xi Ruoyao <xry111@xry111.site>
More information about the Binutils
mailing list