PPC/S390 [sim]: refactor vsel on simulator

PPC and S390 implement vsel slightly differently which
is also reflected on the simulator.

Change-Id: Iec5e49bfae09d8bf15149e5ab149b82971271b24
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3293409
Reviewed-by: Junliang Yan <junyan@redhat.com>
Commit-Queue: Milad Fa <mfarazma@redhat.com>
Cr-Commit-Position: refs/heads/main@{#78002}
This commit is contained in:
Milad Fa 2021-11-19 15:52:03 -05:00 committed by V8 LUCI CQ
parent 75d7a95c88
commit 41f99df7b2
2 changed files with 12 additions and 17 deletions

View File

@ -4931,14 +4931,12 @@ void Simulator::ExecuteGeneric(Instruction* instr) {
int vra = instr->RAValue();
int vrb = instr->RBValue();
int vrc = instr->RCValue();
FOR_EACH_LANE(i, int64_t) {
int64_t vra_val = get_simd_register_by_lane<int64_t>(vra, i);
int64_t vrb_val = get_simd_register_by_lane<int64_t>(vrb, i);
int64_t mask = get_simd_register_by_lane<int64_t>(vrc, i);
int64_t temp = vra_val ^ vrb_val;
temp = temp & mask;
set_simd_register_by_lane<int64_t>(vrt, i, temp ^ vra_val);
}
unsigned __int128 src_1 = bit_cast<__int128>(get_simd_register(vra).int8);
unsigned __int128 src_2 = bit_cast<__int128>(get_simd_register(vrb).int8);
unsigned __int128 src_3 = bit_cast<__int128>(get_simd_register(vrc).int8);
unsigned __int128 tmp = (src_1 & ~src_3) | (src_2 & src_3);
simdr_t* result = bit_cast<simdr_t*>(&tmp);
set_simd_register(vrt, *result);
break;
}
case VPERM: {

View File

@ -4055,15 +4055,12 @@ EVALUATE(VSEL) {
DECODE_VRR_E_INSTRUCTION(r1, r2, r3, r4, m6, m5);
USE(m5);
USE(m6);
fpr_t scratch = get_simd_register(r2);
fpr_t mask = get_simd_register(r4);
scratch.int64[0] ^= get_simd_register_by_lane<int64_t>(r3, 0);
scratch.int64[1] ^= get_simd_register_by_lane<int64_t>(r3, 1);
mask.int64[0] &= scratch.int64[0];
mask.int64[1] &= scratch.int64[1];
mask.int64[0] ^= get_simd_register_by_lane<int64_t>(r3, 0);
mask.int64[1] ^= get_simd_register_by_lane<int64_t>(r3, 1);
set_simd_register(r1, mask);
unsigned __int128 src_1 = bit_cast<__int128>(get_simd_register(r2).int8);
unsigned __int128 src_2 = bit_cast<__int128>(get_simd_register(r3).int8);
unsigned __int128 src_3 = bit_cast<__int128>(get_simd_register(r4).int8);
unsigned __int128 tmp = (src_1 & src_3) | (src_2 & ~src_3);
fpr_t* result = bit_cast<fpr_t*>(&tmp);
set_simd_register(r1, *result);
return length;
}