Skip to content

Commit

Permalink
ssa: Fix wrong opcode comparison (flyinghead#1769)
Browse files Browse the repository at this point in the history
* ssa: Fix wrong opcode comparison

* ssa: handle 32 bits shift case first (shld, shad)

---------

Co-authored-by: flyinghead <[email protected]>
  • Loading branch information
j-mattsson and flyinghead authored Dec 7, 2024
1 parent a99aa52 commit fff03f6
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions core/hw/sh4/dyna/ssa.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,16 +285,9 @@ class SSAOptimizer
{
// Replace shld/shad with shl/shr/sar
u32 r2 = op.rs2.imm_value();
if ((r2 & 0x80000000) == 0)
if ((r2 & 0x1F) == 0)
{
// rd = r1 << (r2 & 0x1F)
op.op = shop_shl;
op.rs2._imm = r2 & 0x1F;
stats.constant_ops_replaced++;
}
else if ((r2 & 0x1F) == 0)
{
if (op.op == shop_shl)
if (op.op == shop_shld)
// rd = 0
ReplaceByMov32(op, 0);
else
Expand All @@ -305,6 +298,13 @@ class SSAOptimizer
stats.constant_ops_replaced++;
}
}
else if ((r2 & 0x80000000) == 0)
{
// rd = r1 << (r2 & 0x1F)
op.op = shop_shl;
op.rs2._imm = r2 & 0x1F;
stats.constant_ops_replaced++;
}
else
{
// rd = r1 >> ((~r2 & 0x1F) + 1)
Expand Down

0 comments on commit fff03f6

Please sign in to comment.