2020-11-12 14:29:08 +00:00
|
|
|
contract c {
|
2020-12-14 17:34:40 +00:00
|
|
|
bytes1[10] data1;
|
2020-11-12 14:29:08 +00:00
|
|
|
bytes2[32] data2;
|
|
|
|
function test() public returns (uint check, uint res1, uint res2) {
|
|
|
|
uint i;
|
|
|
|
for (i = 0; i < data2.length; ++i)
|
|
|
|
data2[i] = 0xffff;
|
|
|
|
check = uint(uint16(data2[31])) * 0x10000 | uint(uint16(data2[14]));
|
|
|
|
for (i = 0; i < data1.length; ++i)
|
2020-12-14 17:34:40 +00:00
|
|
|
data1[i] = bytes1(uint8(1 + i));
|
2020-11-12 14:29:08 +00:00
|
|
|
data2 = data1;
|
|
|
|
for (i = 0; i < 16; ++i)
|
|
|
|
res1 |= uint(uint16(data2[i])) * 0x10000**i;
|
|
|
|
for (i = 0; i < 16; ++i)
|
|
|
|
res2 |= uint(uint16(data2[16 + i])) * 0x10000**i;
|
|
|
|
}
|
|
|
|
}
|
2020-12-03 17:56:57 +00:00
|
|
|
// ====
|
|
|
|
// compileViaYul: also
|
2021-04-23 15:59:01 +00:00
|
|
|
// compileToEwasm: also
|
2020-11-12 14:29:08 +00:00
|
|
|
// ----
|
|
|
|
// test() -> 0xffffffff, 0x0000000000000000000000000a00090008000700060005000400030002000100, 0x0000000000000000000000000000000000000000000000000000000000000000
|
2021-04-08 12:57:18 +00:00
|
|
|
// gas irOptimized: 218618
|
2021-02-12 12:45:15 +00:00
|
|
|
// gas legacy: 328106
|
2021-03-19 13:25:19 +00:00
|
|
|
// gas legacyOptimized: 307826
|