Corresponding code in the .cpp file has been commented instead of begin removed pending preliminary reviews

Code generators needed fixing of the cleanup process during typecasting of bytes and integers
This commit is contained in:
nishant-sachdeva
2022-01-28 19:56:15 +05:30
parent b897d5d7c4
commit dec511aad8
10 changed files with 81 additions and 17 deletions
@@ -11,7 +11,6 @@ contract C {
}
}
// ====
// compileToEwasm: also
// compileViaYul: also
// compileViaYul: false
// ----
// f() -> "\xff\xff\xff\xff"
// f() -> 0xffffffff00000000000000000000000000000000000000000000000000000000
@@ -0,0 +1,14 @@
contract C {
function f() public pure returns (bytes32 r) {
bytes4 x = 0xffffffff;
bytes2 y = bytes2(x);
assembly {
r := y
}
}
}
// ====
// compileToEwasm: also
// compileViaYul: true
// ----
// f() -> 0xffff000000000000000000000000000000000000000000000000000000000000
@@ -0,0 +1,23 @@
contract C {
function f() public pure returns (uint32 y) {
uint8 x = uint8(uint256(0x31313131313131313131313131313131));
assembly { y := x }
}
function g() public pure returns (bytes32 y) {
bytes1 x = bytes1(bytes16(0x31313131313131313131313131313131));
assembly { y := x }
}
function h() external returns (bytes32 y) {
bytes1 x;
assembly { x := sub(0,1) }
y = x;
}
}
// ====
// compileViaYul: true
// ----
// f() -> 0x31
// g() -> 0x3100000000000000000000000000000000000000000000000000000000000000
// h() -> 0xff00000000000000000000000000000000000000000000000000000000000000
@@ -0,0 +1,19 @@
contract C {
event ev0(bytes1 indexed);
constructor() {
emit ev0(bytes1(bytes16(0x31313131313131313131313131313131)));
}
function j() external {
bytes1 x;
assembly { x := 0x3131313131313131313131313131313131313131313131313131313131313131 }
emit ev0(x);
}
}
// ====
// compileViaYul: also
// ----
// constructor() ->
// ~ emit ev0(bytes1): #"1"
// gas legacy: 168735
// j() ->
// ~ emit ev0(bytes1): #"1"
@@ -115,7 +115,7 @@ contract ERC20 {
// ----
// constructor()
// ~ emit Transfer(address,address,uint256): #0x00, #0x1212121212121212121212121212120000000012, 0x14
// gas irOptimized: 442239
// gas irOptimized: 447831
// gas legacy: 861559
// gas legacyOptimized: 420959
// totalSupply() -> 20
@@ -98,7 +98,7 @@ contract ERC20 {
// ----
// constructor()
// ~ emit Transfer(address,address,uint256): #0x00, #0x1212121212121212121212121212120000000012, 0x14
// gas irOptimized: 437697
// gas irOptimized: 443295
// gas legacy: 833310
// gas legacyOptimized: 416135
// totalSupply() -> 20