Sign extension with OP_LOADI32 in get_int_operand()

Previously, the following code did not give the expected result.

```
% bin/mruby -e 'p "%08X" % ~(-1 << 16)'
"..F0000FFFF"

% ruby32 -e 'p "%08X" % ~(-1 << 24)'
"00FFFFFF"
```

For information: this problem arises in the process of folding numbers through optimisation.
This commit is contained in:
dearblue
2023-04-15 20:52:43 +09:00
parent 68c58eac91
commit c981e151ae
+1 -1
View File
@@ -771,7 +771,7 @@ get_int_operand(codegen_scope *s, struct mrb_insn_data *data, mrb_int *n)
return TRUE;
case OP_LOADI32:
*n = (mrb_int)((uint32_t)data->b<<16)+data->c;
*n = (int32_t)((uint32_t)data->b<<16)+data->c;
return TRUE;
case OP_LOADL: