AArch64 cannot compare shorts directly

This commit is contained in:
Walter Bright 2025-03-24 19:02:19 -07:00 committed by Nicholas Wilson
parent 8c4a95f083
commit 2c8d214650

View file

@ -4432,13 +4432,19 @@ private elem* elcmp(elem* e, Goal goal)
tym_t tym; tym_t tym;
int sz = tysize(e2.Ety); int sz = tysize(e2.Ety);
if (e1.Eoper == OPu16_32 && e2.Vulong <= cast(targ_ulong) SHORTMASK || /* The AArch64 does not have a compare short instruction, so the comparisons
e1.Eoper == OPs16_32 && * have to be done with the LDRH, etc., instructions
e2.Vlong == cast(targ_short) e2.Vlong) */
if (config.target_cpu != TARGET_AArch64)
{ {
tym = (uns || e1.Eoper == OPu16_32) ? TYushort : TYshort; if (e1.Eoper == OPu16_32 && e2.Vulong <= cast(targ_ulong) SHORTMASK ||
e.E2 = el_una(OP32_16,tym,e2); e1.Eoper == OPs16_32 &&
goto L2; e2.Vlong == cast(targ_short) e2.Vlong)
{
tym = (uns || e1.Eoper == OPu16_32) ? TYushort : TYshort;
e.E2 = el_una(OP32_16,tym,e2);
goto L2;
}
} }
/* Try to convert to byte/word comparison for ((x & c)==d) /* Try to convert to byte/word comparison for ((x & c)==d)