Commit 3429236d authored by Milad Farazmand's avatar Milad Farazmand Committed by Commit Bot

PPC: Simulate undefined bit pattern on MULHW/MULHWU

The hight 32 bits of the result of MULHW/MULHWU are undefined
which could be set to any random bits. This CL adds a few
bits to the hight 32 bits of the result to simulate this behaviour.

Change-Id: Iaaaaf83f39e2f4c051071ebd68023dc5fd024595
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2378573Reviewed-by: 's avatarJunliang Yan <jyan@ca.ibm.com>
Commit-Queue: Milad Farazmand <miladfar@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#69578}
parent 6da647f5
......@@ -2216,7 +2216,9 @@ void Simulator::ExecuteGeneric(Instruction* instr) {
int32_t ra_val = (get_register(ra) & 0xFFFFFFFF);
int32_t rb_val = (get_register(rb) & 0xFFFFFFFF);
int64_t alu_out = (int64_t)ra_val * (int64_t)rb_val;
alu_out >>= 32;
// High 32 bits of the result is undefined,
// Which is simulated here by adding random bits.
alu_out = (alu_out >> 32) | 0x421000000000000;
set_register(rt, alu_out);
if (instr->Bit(0)) { // RC bit set
SetCR0(static_cast<intptr_t>(alu_out));
......@@ -2230,7 +2232,9 @@ void Simulator::ExecuteGeneric(Instruction* instr) {
uint32_t ra_val = (get_register(ra) & 0xFFFFFFFF);
uint32_t rb_val = (get_register(rb) & 0xFFFFFFFF);
uint64_t alu_out = (uint64_t)ra_val * (uint64_t)rb_val;
alu_out >>= 32;
// High 32 bits of the result is undefined,
// Which is simulated here by adding random bits.
alu_out = (alu_out >> 32) | 0x421000000000000;
set_register(rt, alu_out);
if (instr->Bit(0)) { // RC bit set
SetCR0(static_cast<intptr_t>(alu_out));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment