IR generation for shifts

This commit is contained in:
Alex Beregszaszi
2020-05-06 19:14:23 +02:00
committed by chriseth
parent 3a93080ca9
commit 327c75bc1b
32 changed files with 236 additions and 18 deletions
@@ -7,5 +7,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f() -> 0x0
@@ -5,5 +5,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f() -> 0x4200
@@ -5,5 +5,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f() -> 0x42
@@ -4,6 +4,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f(uint256,uint256): 0x4266, 0x0 -> 0x4266
// f(uint256,uint256): 0x4266, 0x8 -> 0x426600
@@ -5,6 +5,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f(uint256,uint256): 0x4266, 0x0 -> 0x4266
// f(uint256,uint256): 0x4266, 0x8 -> 0x426600
@@ -5,6 +5,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f(uint256,uint8): 0x4266, 0x0 -> 0x4266
// f(uint256,uint8): 0x4266, 0x8 -> 0x426600
@@ -6,6 +6,7 @@ contract C {
return y << x;
}
}
// ====
// compileViaYul: also
// ----
// f() -> 0
@@ -4,6 +4,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f(uint32,uint32): 0x4266, 0x0 -> 0x4266
// f(uint32,uint32): 0x4266, 0x8 -> 0x426600
@@ -4,6 +4,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f(uint8,uint8): 0x66, 0x0 -> 0x66
// f(uint8,uint8): 0x66, 0x8 -> 0
@@ -8,6 +8,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f(int256,int256): 1, -1 -> FAILURE
// g(int256,int256): 1, -1 -> FAILURE
@@ -10,6 +10,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f(int256,int256): 1, -1 -> FAILURE
// g(int256,int256): 1, -1 -> FAILURE
@@ -8,6 +8,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// leftU(uint8,uint8): 255, 8 -> 0
// leftU(uint8,uint8): 255, 1 -> 254
@@ -4,6 +4,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f(uint256,uint256): 0x4266, 0x0 -> 0x4266
// f(uint256,uint256): 0x4266, 0x8 -> 0x42
@@ -5,6 +5,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f(uint256,uint256): 0x4266, 0x0 -> 0x4266
// f(uint256,uint256): 0x4266, 0x8 -> 0x42
@@ -5,6 +5,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f(int256,int256): 0x4266, 0x0 -> 0x4266
// f(int256,int256): 0x4266, 0x8 -> 0x42
@@ -18,6 +18,8 @@ contract C {
return a >> b;
}
}
// ====
// compileViaYul: also
// ----
// f(int8,uint8): 0x00, 0x03 -> 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe
// f(int8,uint8): 0x00, 0x04 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
@@ -10,6 +10,8 @@ contract C {
return a >> b;
}
}
// ====
// compileViaYul: also
// ----
// f(uint8,uint8): 0x00, 0x04 -> 0x0f
// f(uint8,uint8): 0x00, 0x1004 -> FAILURE
@@ -4,6 +4,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f(int256,int256): -4266, 0 -> -4266
// f(int256,int256): -4266, 1 -> -2133
@@ -5,6 +5,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f(int256,int256): -4266, 0 -> -4266
// f(int256,int256): -4266, 1 -> -2133
@@ -4,6 +4,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f(int16,int16): -4266, 0 -> -4266
// f(int16,int16): -4266, 1 -> -2133
@@ -4,6 +4,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f(int32,int32): -4266, 0 -> -4266
// f(int32,int32): -4266, 1 -> -2133
@@ -4,6 +4,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f(int8,int8): -66, 0 -> -66
// f(int8,int8): -66, 1 -> -33
@@ -6,6 +6,8 @@ contract C {
return a >> b;
}
}
// ====
// compileViaYul: also
// ----
// f(int16,int16): 0xff99, 0x00 -> FAILURE
// f(int16,int16): 0xff99, 0x01 -> FAILURE
@@ -6,6 +6,8 @@ contract C {
return a >> b;
}
}
// ====
// compileViaYul: also
// ----
// f(int32,int32): 0xffffff99, 0x00 -> FAILURE
// f(int32,int32): 0xffffff99, 0x01 -> FAILURE
@@ -6,6 +6,8 @@ contract C {
return a >> b;
}
}
// ====
// compileViaYul: also
// ----
// f(int8,int8): 0x99, 0x00 -> FAILURE
// f(int8,int8): 0x99, 0x01 -> FAILURE
@@ -4,6 +4,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f(uint32,uint32): 0x4266, 0x0 -> 0x4266
// f(uint32,uint32): 0x4266, 0x8 -> 0x42
@@ -4,6 +4,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f(uint8,uint8): 0x66, 0x0 -> 0x66
// f(uint8,uint8): 0x66, 0x8 -> 0x0
@@ -0,0 +1,16 @@
contract C {
function f(uint256 a, int8 b) public returns (uint256) {
assembly { b := 0xff }
return a << b;
}
function g(uint256 a, int8 b) public returns (uint256) {
assembly { b := 0xff }
return a >> b;
}
}
// ====
// compileViaYul: also
// ----
// f(uint256,int8): 0x1234, 0x0 -> FAILURE
// g(uint256,int8): 0x1234, 0x0 -> FAILURE