LoongArch IR JIT: Check Vec4Scale/Vec4Dot overlap before mapping

The reg cache asserts when one reg is mapped as a vector and as a scalar, so
the overlap check has to come first, like the other ops do it. Found by
CPUEquivalence under qemu on CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-10-14 01:11:59 +02:00
1 parent 9237bade22
commit bdc62d9ea2
1 file changed
+6 -4
+6 -4
View File
@@ -301,10 +301,11 @@ void LoongArch64JitBackend::CompIR_VecArith(IRInst inst) {
break;
case IROp::Vec4Scale:
// Check overlap before mapping: the reg cache can't map a reg as both a vector and a scalar.
if (cpu_info.LOONGARCH_LSX && (Overlap(inst.dest, 4, inst.src2, 1) || Overlap(inst.src1, 4, inst.src2, 1)))
DISABLE;
regs_.Map(inst);
if (cpu_info.LOONGARCH_LSX) {
if (Overlap(inst.dest, 4, inst.src2, 1) || Overlap(inst.src1, 4, inst.src2, 1))
DISABLE;
VSHUF4I_W(regs_.V(inst.src2), regs_.V(inst.src2), 0);
VFMUL_S(regs_.V(inst.dest), regs_.V(inst.src1), regs_.V(inst.src2));
@@ -355,10 +356,11 @@ void LoongArch64JitBackend::CompIR_VecHoriz(IRInst inst) {
switch (inst.op) {
case IROp::Vec4Dot:
// Check overlap before mapping: the reg cache can't map a reg as both a vector and a scalar.
if (cpu_info.LOONGARCH_LSX && (Overlap(inst.dest, 1, inst.src1, 4) || Overlap(inst.dest, 1, inst.src2, 4)))
DISABLE;
regs_.Map(inst);
if (cpu_info.LOONGARCH_LSX) {
if (Overlap(inst.dest, 1, inst.src1, 4) || Overlap(inst.dest, 1, inst.src2, 4))
DISABLE;
VFMUL_S(regs_.V(inst.dest), regs_.V(inst.src1), regs_.V(inst.src2));
VOR_V(EncodeRegToV(SCRATCHF1), regs_.V(inst.dest), regs_.V(inst.dest));