mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-05 23:33:07 +00:00
Feedback
This commit is contained in:
parent
cb2df9fa03
commit
6416826643
@ -120,9 +120,7 @@
|
|||||||
// stack: input, ...
|
// stack: input, ...
|
||||||
PUSH $c
|
PUSH $c
|
||||||
// stack: c, input, ...
|
// stack: c, input, ...
|
||||||
%add_const(1) // This will be optimized out.
|
LT ISZERO // Check it backwards: (input <= c) == !(c < input)
|
||||||
// stack: c + 1, input, ...
|
|
||||||
GT // Check it backwards: (input <= c) == (c + 1 > input)
|
|
||||||
// stack: input <= c, ...
|
// stack: input <= c, ...
|
||||||
%endmacro
|
%endmacro
|
||||||
|
|
||||||
@ -138,9 +136,7 @@
|
|||||||
// stack: input, ...
|
// stack: input, ...
|
||||||
PUSH $c
|
PUSH $c
|
||||||
// stack: c, input, ...
|
// stack: c, input, ...
|
||||||
%sub_const(1) // This will be optimized out.
|
GT ISZERO // Check it backwards: (input >= c) == !(c > input)
|
||||||
// stack: c - 1, input, ...
|
|
||||||
LT // Check it backwards: (input >= c) == (c - 1 < input)
|
|
||||||
// stack: input >= c, ...
|
// stack: input >= c, ...
|
||||||
%endmacro
|
%endmacro
|
||||||
|
|
||||||
|
|||||||
@ -50,6 +50,8 @@ fn constant_propagation(code: &mut Vec<Item>) {
|
|||||||
"SUB" => Some(x.overflowing_sub(y).0),
|
"SUB" => Some(x.overflowing_sub(y).0),
|
||||||
"MUL" => Some(x.overflowing_mul(y).0),
|
"MUL" => Some(x.overflowing_mul(y).0),
|
||||||
"DIV" => Some(x.checked_div(y).unwrap_or(U256::zero())),
|
"DIV" => Some(x.checked_div(y).unwrap_or(U256::zero())),
|
||||||
|
"MOD" => Some(x.checked_rem(y).unwrap_or(U256::zero())),
|
||||||
|
"EXP" => Some(x.overflowing_pow(y).0),
|
||||||
"SHL" => Some(x << y),
|
"SHL" => Some(x << y),
|
||||||
"SHR" => Some(x >> y),
|
"SHR" => Some(x >> y),
|
||||||
"AND" => Some(x & y),
|
"AND" => Some(x & y),
|
||||||
@ -58,6 +60,11 @@ fn constant_propagation(code: &mut Vec<Item>) {
|
|||||||
"LT" => Some(u256_from_bool(x < y)),
|
"LT" => Some(u256_from_bool(x < y)),
|
||||||
"GT" => Some(u256_from_bool(x > y)),
|
"GT" => Some(u256_from_bool(x > y)),
|
||||||
"EQ" => Some(u256_from_bool(x == y)),
|
"EQ" => Some(u256_from_bool(x == y)),
|
||||||
|
"BYTE" => Some(if x < 32.into() {
|
||||||
|
y.byte(x.as_usize()).into()
|
||||||
|
} else {
|
||||||
|
U256::zero()
|
||||||
|
}),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
.map(|res| vec![Push(Literal(res))])
|
.map(|res| vec![Push(Literal(res))])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user