Skip to content

Commit d926928

Browse files
committed
[a64] Fix out-of-bounds OPCODE_VECTOR_SHL(all-same) case
Out-of-bound shift-values are handled as modulo-element-size
1 parent c785488 commit d926928

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/xenia/cpu/backend/a64/a64_seq_vector.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ struct VECTOR_SHL_V128
539539
}
540540
if (all_same) {
541541
// Every count is the same, so we can use SHL
542-
e.SHL(i.dest.reg().B16(), i.src1.reg().B16(), shamt.u8[0]);
542+
e.SHL(i.dest.reg().B16(), i.src1.reg().B16(), shamt.u8[0] & 0x7);
543543
return;
544544
}
545545
e.ADD(e.GetNativeParam(1), SP, e.StashConstantV(1, i.src2.constant()));
@@ -563,7 +563,7 @@ struct VECTOR_SHL_V128
563563
}
564564
if (all_same) {
565565
// Every count is the same, so we can use SHL
566-
e.SHL(i.dest.reg().H8(), i.src1.reg().H8(), shamt.u8[0]);
566+
e.SHL(i.dest.reg().H8(), i.src1.reg().H8(), shamt.u8[0] & 0xF);
567567
return;
568568
}
569569
e.ADD(e.GetNativeParam(1), SP, e.StashConstantV(1, i.src2.constant()));
@@ -587,7 +587,7 @@ struct VECTOR_SHL_V128
587587
}
588588
if (all_same) {
589589
// Every count is the same, so we can use SHL
590-
e.SHL(i.dest.reg().S4(), i.src1.reg().S4(), shamt.u8[0]);
590+
e.SHL(i.dest.reg().S4(), i.src1.reg().S4(), shamt.u8[0] & 0x1F);
591591
return;
592592
}
593593
e.ADD(e.GetNativeParam(1), SP, e.StashConstantV(1, i.src2.constant()));

0 commit comments

Comments
 (0)