Commit e607a9a5 authored by Junliang Yan's avatar Junliang Yan Committed by V8 LUCI CQ

ppc: fix builtin_ctz undefined behaviour on 0

Change-Id: I3d166575a5828b4ac1a1a7d11e5f67460428a00c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3097870Reviewed-by: 's avatarMilad Fa <mfarazma@redhat.com>
Commit-Queue: Junliang Yan <junyan@redhat.com>
Cr-Commit-Position: refs/heads/master@{#76314}
parent 7a5a8ff1
......@@ -2552,7 +2552,7 @@ void Simulator::ExecuteGeneric(Instruction* instr) {
int rs = instr->RSValue();
int ra = instr->RAValue();
uint32_t rs_val = static_cast<uint32_t>(get_register(rs));
uintptr_t count = __builtin_ctz(rs_val);
uintptr_t count = rs_val == 0 ? 32 : __builtin_ctz(rs_val);
set_register(ra, count);
if (instr->Bit(0)) { // RC Bit set
int bf = 0;
......@@ -2570,7 +2570,7 @@ void Simulator::ExecuteGeneric(Instruction* instr) {
int rs = instr->RSValue();
int ra = instr->RAValue();
uint64_t rs_val = get_register(rs);
uintptr_t count = __builtin_ctz(rs_val);
uintptr_t count = rs_val == 0 ? 64 : __builtin_ctzl(rs_val);
set_register(ra, count);
if (instr->Bit(0)) { // RC Bit set
int bf = 0;
......
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