Skip to content

Commit

Permalink
Fix issue 470. Add a test for it.
Browse files Browse the repository at this point in the history
  • Loading branch information
vnmakarov committed Jun 20, 2024
1 parent 14de6c7 commit 2719bf5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
9 changes: 9 additions & 0 deletions c-tests/mir/issue470.mir
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
M0: module
main: func i64
local i64:num
mov num, 0x100000000
bfs l1, num
ret 1
l1: ret 2
endfunc
endmodule
1 change: 1 addition & 0 deletions c-tests/mir/issue470.mir.expectrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2
12 changes: 10 additions & 2 deletions mir-gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -4702,11 +4702,19 @@ static void gvn_modify (gen_ctx_t gen_ctx) {
}
break;
case MIR_BT:
case MIR_BTS: const_p = get_gvn_op (insn, 1, &val); break;
case MIR_BTS:
const_p = get_gvn_op (insn, 1, &val);
if (const_p && insn->code == MIR_BTS) val = (int32_t) val;
break;
case MIR_BF:
case MIR_BFS:
const_p = get_gvn_op (insn, 1, &val);
if (const_p) val = !val;
if (const_p) {
if (insn->code == MIR_BF)
val = !val;
else
val = !(int32_t) val;
}
break;
case MIR_BEQ: GVN_ICMP (==); break;
case MIR_BEQS: GVN_ICMPS (==); break;
Expand Down

0 comments on commit 2719bf5

Please sign in to comment.