diff --git a/cranelift/codegen/src/isa/zkasm/inst/emit.rs b/cranelift/codegen/src/isa/zkasm/inst/emit.rs index 3a6e276f6079..b99d1e2ff915 100644 --- a/cranelift/codegen/src/isa/zkasm/inst/emit.rs +++ b/cranelift/codegen/src/isa/zkasm/inst/emit.rs @@ -591,12 +591,11 @@ impl MachInstEmit for Inst { match from { AMode::RegOffset(r, ..) => { debug_assert_eq!(r, e0()); - // For simplicity we assume that register address is word-aligned. - // This was the case for Rust-generated code, but might be violated in the - // future. - put_string(&format!("${{ {} % 8 }} => A\n", reg_name(r)), sink); - put_string(&format!("0: ASSERT\n"), sink); // TODO(#43): Implement the conversion using verifiable computations. + put_string( + &format!("${{ ({}) % 8 }} => A\n", access_reg_with_offset(r, offset),), + sink, + ); put_string( &format!( "${{ ({}) / 8 }} => {}\n", @@ -605,9 +604,18 @@ impl MachInstEmit for Inst { ), sink, ); - let rem = offset % 8; - let width = op.width() as i64; + // Handle the case when read spans two slots. + // We do this read first in case `rd == r == E` which will clobber the + // address register after second `MLOAD`. + put_string( + &format!( + "$ => {} :MLOAD(MEM:{})\n", + reg_name(d0()), + access_reg_with_offset(r, 1) + ), + sink, + ); put_string( &format!( "$ => {} :MLOAD(MEM:{})\n", @@ -618,47 +626,33 @@ impl MachInstEmit for Inst { ); // TODO(#34): Implement unaligned and narrow reads using verifiable // computations. - if rem > 0 { - put_string( - &format!( - "${{ {} >> {} }} => {}\n", - reg_name(rd.to_reg()), - 8 * rem, - reg_name(rd.to_reg()) - ), - sink, - ); - } + put_string( + &format!( + "${{ {} >> (8 * A) }} => {}\n", + reg_name(rd.to_reg()), + reg_name(rd.to_reg()) + ), + sink, + ); - // Handle the case when read spans two slots. - if rem + width > 8 { - let rem = rem + width - 8; - put_string( - &format!( - "$ => {} :MLOAD(MEM:{})\n", - reg_name(d0()), - access_reg_with_offset(r, 1) - ), - sink, - ); - put_string( - &format!( - "${{ (D << {}) | {} }} => {}\n", - 64 - 8 * rem, - reg_name(rd.to_reg()), - reg_name(rd.to_reg()), - ), - sink, - ); - } + // Merge in the read from the second slot. + put_string( + &format!( + "${{ (D << (128 - 8 * (A + {}))) | {} }} => {}\n", + op.width(), + reg_name(rd.to_reg()), + reg_name(rd.to_reg()), + ), + sink, + ); // Mask the value to the width of the resulting type. - if width < 8 { + if op.width() < 8 { put_string( &format!( "${{ {} & ((1 << {}) - 1) }} => {}\n", reg_name(rd.to_reg()), - 8 * width, + 8 * op.width(), reg_name(rd.to_reg()), ), sink, @@ -694,12 +688,11 @@ impl MachInstEmit for Inst { match to { AMode::RegOffset(r, ..) => { debug_assert_eq!(r, e0()); - // For simplicity we assume that register address is word-aligned. - // This was the case for Rust-generated code, but might be violated in the - // future. - put_string(&format!("${{ {} % 8 }} => A\n", reg_name(r)), sink); - put_string(&format!("0: ASSERT\n"), sink); // TODO(#43): Implement the conversion using verifiable computations. + put_string( + &format!("${{ ({}) % 8 }} => A\n", access_reg_with_offset(r, offset)), + sink, + ); put_string( &format!( "${{ ({}) / 8 }} => {}\n", @@ -708,19 +701,10 @@ impl MachInstEmit for Inst { ), sink, ); - let rem = offset % 8; - let width = op.width() as i64; - - if op == StoreOP::I64 && rem == 0 { - put_string( - &format!("{} :MSTORE(MEM:{})\n", reg_name(src), reg_name(r)), - sink, - ); - return; - } // TODO(#34): Implement unaligned and narrow writes using verifiable // computations. + let width = op.width() as i64; if width < 8 { put_string( &format!( @@ -738,38 +722,35 @@ impl MachInstEmit for Inst { ); put_string( &format!( - "${{ (D & ~(((1 << {}) - 1) << {})) | ({} << {}) }} :MSTORE(MEM:{})\n", + "${{ (D & ~(((1 << {}) - 1) << (8 * A))) | ({} << (8 * A)) }} :MSTORE(MEM:{})\n", 8 * width, - 8 * rem, reg_name(src), - 8 * rem, reg_name(r), ), sink, ); // Handle the case when write spans two slots. - if rem + width > 8 { - let rem = rem + width - 8; - put_string( - &format!( - "$ => {} :MLOAD(MEM:{})\n", - reg_name(d0()), - access_reg_with_offset(r, 1) - ), - sink, - ); - put_string( - &format!( - "${{ (D & ~((1 << {}) - 1)) | ({} & ((1 << {}) - 1)) }} :MSTORE(MEM:{})\n", - 8 * rem, - reg_name(src), - 8 * rem, - access_reg_with_offset(r, 1), - ), - sink, - ); - } + put_string( + &format!("${{ (A + {width} > 8) ? (A + {width} - 8) : 0 }} => A\n"), + sink, + ); + put_string( + &format!( + "$ => {} :MLOAD(MEM:{})\n", + reg_name(d0()), + access_reg_with_offset(r, 1) + ), + sink, + ); + put_string( + &format!( + "${{ (D & ~((1 << (8 * A)) - 1)) | ({} & ((1 << (8 * A)) - 1)) }} :MSTORE(MEM:{})\n", + reg_name(src), + access_reg_with_offset(r, 1), + ), + sink, + ); } AMode::SPOffset(..) | AMode::NominalSPOffset(..) | AMode::FPOffset(..) => { assert_eq!(offset % 8, 0); diff --git a/cranelift/zkasm_data/benchmarks/sha256/generated/from_rust.zkasm b/cranelift/zkasm_data/benchmarks/sha256/generated/from_rust.zkasm index 10b4e18ea822..3324c375b74c 100644 --- a/cranelift/zkasm_data/benchmarks/sha256/generated/from_rust.zkasm +++ b/cranelift/zkasm_data/benchmarks/sha256/generated/from_rust.zkasm @@ -41,17 +41,22 @@ function_1: 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 2072) % 8 } => A ${ (E + 2072) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => C :MLOAD(MEM:E) + ${ C >> (8 * A) } => C + ${ (D << (128 - 8 * (A + 8))) | C } => C 0n => A ;; LoadConst32 $ => B :MLOAD(SP + 2) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E - C :MSTORE(MEM:E) + $ => D :MLOAD(MEM:E) + ${ (D & ~(((1 << 64) - 1) << (8 * A))) | (C << (8 * A)) } :MSTORE(MEM:E) + ${ (A + 8 > 8) ? (A + 8 - 8) : 0 } => A + $ => D :MLOAD(MEM:E + 1) + ${ (D & ~((1 << (8 * A)) - 1)) | (C & ((1 << (8 * A)) - 1)) } :MSTORE(MEM:E + 1) 16n => B ;; LoadConst32 $ => A :MLOAD(SP + 13) $ => E :ADD @@ -62,17 +67,22 @@ function_1: 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 2064) % 8 } => A ${ (E + 2064) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => C :MLOAD(MEM:E) + ${ C >> (8 * A) } => C + ${ (D << (128 - 8 * (A + 8))) | C } => C 0n => A ;; LoadConst32 $ => B :MLOAD(SP + 1) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E - C :MSTORE(MEM:E) + $ => D :MLOAD(MEM:E) + ${ (D & ~(((1 << 64) - 1) << (8 * A))) | (C << (8 * A)) } :MSTORE(MEM:E) + ${ (A + 8 > 8) ? (A + 8 - 8) : 0 } => A + $ => D :MLOAD(MEM:E + 1) + ${ (D & ~((1 << (8 * A)) - 1)) | (C & ((1 << (8 * A)) - 1)) } :MSTORE(MEM:E + 1) 8n => B ;; LoadConst32 $ => A :MLOAD(SP + 13) $ => B :ADD @@ -83,17 +93,22 @@ function_1: 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 2056) % 8 } => A ${ (E + 2056) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => C :MLOAD(MEM:E) + ${ C >> (8 * A) } => C + ${ (D << (128 - 8 * (A + 8))) | C } => C 0n => A ;; LoadConst32 $ => B :MLOAD(SP) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E - C :MSTORE(MEM:E) + $ => D :MLOAD(MEM:E) + ${ (D & ~(((1 << 64) - 1) << (8 * A))) | (C << (8 * A)) } :MSTORE(MEM:E) + ${ (A + 8 > 8) ? (A + 8 - 8) : 0 } => A + $ => D :MLOAD(MEM:E + 1) + ${ (D & ~((1 << (8 * A)) - 1)) | (C & ((1 << (8 * A)) - 1)) } :MSTORE(MEM:E + 1) 50n => B ;; LoadConst32 $ => A :MLOAD(SP + 13) $ => B :ADD @@ -103,10 +118,13 @@ function_1: 0n => C ;; LoadConst64 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E - C :MSTORE(MEM:E) + $ => D :MLOAD(MEM:E) + ${ (D & ~(((1 << 64) - 1) << (8 * A))) | (C << (8 * A)) } :MSTORE(MEM:E) + ${ (A + 8 > 8) ? (A + 8 - 8) : 0 } => A + $ => D :MLOAD(MEM:E + 1) + ${ (D & ~((1 << (8 * A)) - 1)) | (C & ((1 << (8 * A)) - 1)) } :MSTORE(MEM:E + 1) 58n => B ;; LoadConst32 $ => A :MLOAD(SP + 13) $ => C :ADD @@ -116,10 +134,13 @@ function_1: 0n => C ;; LoadConst64 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E - C :MSTORE(MEM:E) + $ => D :MLOAD(MEM:E) + ${ (D & ~(((1 << 64) - 1) << (8 * A))) | (C << (8 * A)) } :MSTORE(MEM:E) + ${ (A + 8 > 8) ? (A + 8 - 8) : 0 } => A + $ => D :MLOAD(MEM:E + 1) + ${ (D & ~((1 << (8 * A)) - 1)) | (C & ((1 << (8 * A)) - 1)) } :MSTORE(MEM:E + 1) 66n => B ;; LoadConst32 $ => A :MLOAD(SP + 13) $ => D :ADD @@ -129,10 +150,13 @@ function_1: 0n => C ;; LoadConst64 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E - C :MSTORE(MEM:E) + $ => D :MLOAD(MEM:E) + ${ (D & ~(((1 << 64) - 1) << (8 * A))) | (C << (8 * A)) } :MSTORE(MEM:E) + ${ (A + 8 > 8) ? (A + 8 - 8) : 0 } => A + $ => D :MLOAD(MEM:E + 1) + ${ (D & ~((1 << (8 * A)) - 1)) | (C & ((1 << (8 * A)) - 1)) } :MSTORE(MEM:E + 1) 74n => B ;; LoadConst32 $ => A :MLOAD(SP + 13) $ => E :ADD @@ -142,10 +166,13 @@ function_1: 0n => C ;; LoadConst64 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E - C :MSTORE(MEM:E) + $ => D :MLOAD(MEM:E) + ${ (D & ~(((1 << 64) - 1) << (8 * A))) | (C << (8 * A)) } :MSTORE(MEM:E) + ${ (A + 8 > 8) ? (A + 8 - 8) : 0 } => A + $ => D :MLOAD(MEM:E + 1) + ${ (D & ~((1 << (8 * A)) - 1)) | (C & ((1 << (8 * A)) - 1)) } :MSTORE(MEM:E + 1) 82n => B ;; LoadConst32 $ => A :MLOAD(SP + 13) $ => B :ADD @@ -155,10 +182,13 @@ function_1: 0n => C ;; LoadConst64 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E - C :MSTORE(MEM:E) + $ => D :MLOAD(MEM:E) + ${ (D & ~(((1 << 64) - 1) << (8 * A))) | (C << (8 * A)) } :MSTORE(MEM:E) + ${ (A + 8 > 8) ? (A + 8 - 8) : 0 } => A + $ => D :MLOAD(MEM:E + 1) + ${ (D & ~((1 << (8 * A)) - 1)) | (C & ((1 << (8 * A)) - 1)) } :MSTORE(MEM:E + 1) 88n => B ;; LoadConst32 $ => A :MLOAD(SP + 13) $ => B :ADD @@ -168,60 +198,75 @@ function_1: 0n => C ;; LoadConst64 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E - C :MSTORE(MEM:E) + $ => D :MLOAD(MEM:E) + ${ (D & ~(((1 << 64) - 1) << (8 * A))) | (C << (8 * A)) } :MSTORE(MEM:E) + ${ (A + 8 > 8) ? (A + 8 - 8) : 0 } => A + $ => D :MLOAD(MEM:E + 1) + ${ (D & ~((1 << (8 * A)) - 1)) | (C & ((1 << (8 * A)) - 1)) } :MSTORE(MEM:E + 1) 1n => C ;; LoadConst32 0n => A ;; LoadConst32 $ => B :MLOAD(SP + 13) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 104) % 8 } => A ${ (E + 104) / 8 } => E ${ C & ((1 << 8) - 1) } => C $ => D :MLOAD(MEM:E) - ${ (D & ~(((1 << 8) - 1) << 0)) | (C << 0) } :MSTORE(MEM:E) + ${ (D & ~(((1 << 8) - 1) << (8 * A))) | (C << (8 * A)) } :MSTORE(MEM:E) + ${ (A + 1 > 8) ? (A + 1 - 8) : 0 } => A + $ => D :MLOAD(MEM:E + 1) + ${ (D & ~((1 << (8 * A)) - 1)) | (C & ((1 << (8 * A)) - 1)) } :MSTORE(MEM:E + 1) 0n => C ;; LoadConst64 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 32) % 8 } => A ${ (E + 32) / 8 } => E - C :MSTORE(MEM:E) + $ => D :MLOAD(MEM:E) + ${ (D & ~(((1 << 64) - 1) << (8 * A))) | (C << (8 * A)) } :MSTORE(MEM:E) + ${ (A + 8 > 8) ? (A + 8 - 8) : 0 } => A + $ => D :MLOAD(MEM:E + 1) + ${ (D & ~((1 << (8 * A)) - 1)) | (C & ((1 << (8 * A)) - 1)) } :MSTORE(MEM:E + 1) 0n => C ;; LoadConst64 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 42) % 8 } => A ${ (E + 42) / 8 } => E $ => D :MLOAD(MEM:E) - ${ (D & ~(((1 << 64) - 1) << 16)) | (C << 16) } :MSTORE(MEM:E) + ${ (D & ~(((1 << 64) - 1) << (8 * A))) | (C << (8 * A)) } :MSTORE(MEM:E) + ${ (A + 8 > 8) ? (A + 8 - 8) : 0 } => A $ => D :MLOAD(MEM:E + 1) - ${ (D & ~((1 << 16) - 1)) | (C & ((1 << 16) - 1)) } :MSTORE(MEM:E + 1) + ${ (D & ~((1 << (8 * A)) - 1)) | (C & ((1 << (8 * A)) - 1)) } :MSTORE(MEM:E + 1) 32856n => C ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 40) % 8 } => A ${ (E + 40) / 8 } => E ${ C & ((1 << 16) - 1) } => C $ => D :MLOAD(MEM:E) - ${ (D & ~(((1 << 16) - 1) << 0)) | (C << 0) } :MSTORE(MEM:E) + ${ (D & ~(((1 << 16) - 1) << (8 * A))) | (C << (8 * A)) } :MSTORE(MEM:E) + ${ (A + 2 > 8) ? (A + 2 - 8) : 0 } => A + $ => D :MLOAD(MEM:E + 1) + ${ (D & ~((1 << (8 * A)) - 1)) | (C & ((1 << (8 * A)) - 1)) } :MSTORE(MEM:E + 1) 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 2048) % 8 } => A ${ (E + 2048) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => C :MLOAD(MEM:E) + ${ C >> (8 * A) } => C + ${ (D << (128 - 8 * (A + 8))) | C } => C 0n => A ;; LoadConst32 $ => B :MLOAD(SP + 13) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E - C :MSTORE(MEM:E) + $ => D :MLOAD(MEM:E) + ${ (D & ~(((1 << 64) - 1) << (8 * A))) | (C << (8 * A)) } :MSTORE(MEM:E) + ${ (A + 8 > 8) ? (A + 8 - 8) : 0 } => A + $ => D :MLOAD(MEM:E + 1) + ${ (D & ~((1 << (8 * A)) - 1)) | (C & ((1 << (8 * A)) - 1)) } :MSTORE(MEM:E + 1) 96n => B ;; LoadConst32 $ => A :MLOAD(SP + 13) $ => C :ADD @@ -231,10 +276,13 @@ function_1: 576460752303423488n => C ;; LoadConst64 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E - C :MSTORE(MEM:E) + $ => D :MLOAD(MEM:E) + ${ (D & ~(((1 << 64) - 1) << (8 * A))) | (C << (8 * A)) } :MSTORE(MEM:E) + ${ (A + 8 > 8) ? (A + 8 - 8) : 0 } => A + $ => D :MLOAD(MEM:E + 1) + ${ (D & ~((1 << (8 * A)) - 1)) | (C & ((1 << (8 * A)) - 1)) } :MSTORE(MEM:E + 1) 40n => B ;; LoadConst32 $ => A :MLOAD(SP + 13) $ => D :ADD @@ -251,68 +299,78 @@ function_1: 0n => A ;; LoadConst32 $ => B :MLOAD(SP + 2) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 4))) | B } => B ${ B & ((1 << 32) - 1) } => B B :MSTORE(SP + 12) 0n => A ;; LoadConst32 $ => B :MLOAD(SP + 1) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 4))) | B } => B ${ B & ((1 << 32) - 1) } => B B :MSTORE(SP + 11) 0n => A ;; LoadConst32 $ => B :MLOAD(SP) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 4))) | B } => B ${ B & ((1 << 32) - 1) } => B B :MSTORE(SP + 10) 0n => A ;; LoadConst32 $ => B :MLOAD(SP + 13) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 28) % 8 } => A ${ (E + 28) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) - ${ B >> 32 } => B + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 4))) | B } => B ${ B & ((1 << 32) - 1) } => B B :MSTORE(SP + 9) 0n => A ;; LoadConst32 $ => B :MLOAD(SP + 13) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 20) % 8 } => A ${ (E + 20) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) - ${ B >> 32 } => B + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 4))) | B } => B ${ B & ((1 << 32) - 1) } => B B :MSTORE(SP + 8) 0n => A ;; LoadConst32 $ => B :MLOAD(SP + 13) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 12) % 8 } => A ${ (E + 12) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) - ${ B >> 32 } => B + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 4))) | B } => B ${ B & ((1 << 32) - 1) } => B B :MSTORE(SP + 7) 0n => A ;; LoadConst32 $ => B :MLOAD(SP + 13) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 4) % 8 } => A ${ (E + 4) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) - ${ B >> 32 } => B + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 4))) | B } => B ${ B & ((1 << 32) - 1) } => B B :MSTORE(SP + 6) 75n => A ;; LoadConst64 @@ -320,10 +378,12 @@ function_1: 0n => A ;; LoadConst32 $ => B :MLOAD(SP + 13) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 4))) | B } => B ${ B & ((1 << 32) - 1) } => B B :MSTORE(SP + 5) 24n => A ;; LoadConst32 @@ -1320,70 +1380,82 @@ function_2: 0n => A ;; LoadConst32 $ => B :MLOAD(SP) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 28) % 8 } => A ${ (E + 28) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => E :MLOAD(MEM:E) - ${ E >> 32 } => E + ${ E >> (8 * A) } => E + ${ (D << (128 - 8 * (A + 4))) | E } => E ${ E & ((1 << 32) - 1) } => E E :MSTORE(SP + 9) 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 24) % 8 } => A ${ (E + 24) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => C :MLOAD(MEM:E) + ${ C >> (8 * A) } => C + ${ (D << (128 - 8 * (A + 4))) | C } => C ${ C & ((1 << 32) - 1) } => C C :MSTORE(SP + 10) 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 20) % 8 } => A ${ (E + 20) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => C :MLOAD(MEM:E) - ${ C >> 32 } => C + ${ C >> (8 * A) } => C + ${ (D << (128 - 8 * (A + 4))) | C } => C ${ C & ((1 << 32) - 1) } => C C :MSTORE(SP + 11) 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 16) % 8 } => A ${ (E + 16) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => C :MLOAD(MEM:E) + ${ C >> (8 * A) } => C + ${ (D << (128 - 8 * (A + 4))) | C } => C ${ C & ((1 << 32) - 1) } => C C :MSTORE(SP + 12) 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 12) % 8 } => A ${ (E + 12) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => E :MLOAD(MEM:E) - ${ E >> 32 } => E + ${ E >> (8 * A) } => E + ${ (D << (128 - 8 * (A + 4))) | E } => E ${ E & ((1 << 32) - 1) } => E E :MSTORE(SP + 13) 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 8) % 8 } => A ${ (E + 8) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => E :MLOAD(MEM:E) + ${ E >> (8 * A) } => E + ${ (D << (128 - 8 * (A + 4))) | E } => E ${ E & ((1 << 32) - 1) } => E E :MSTORE(SP + 14) 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 4) % 8 } => A ${ (E + 4) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => C :MLOAD(MEM:E) - ${ C >> 32 } => C + ${ C >> (8 * A) } => C + ${ (D << (128 - 8 * (A + 4))) | C } => C ${ C & ((1 << 32) - 1) } => C C :MSTORE(SP + 15) 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 4))) | B } => B ${ B & ((1 << 32) - 1) } => B B :MSTORE(SP + 16) 0n => B ;; LoadConst32 @@ -1672,10 +1744,12 @@ label_2_3: 0n => A ;; LoadConst32 $ => B :MLOAD(SP + 8) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 4))) | B } => B ${ B & ((1 << 32) - 1) } => B B :MSTORE(SP + 1165) 24n => A ;; LoadConst32 @@ -1885,11 +1959,12 @@ label_2_3: 0n => A ;; LoadConst32 $ => B :MLOAD(SP + 8) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 4) % 8 } => A ${ (E + 4) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) - ${ B >> 32 } => B + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 4))) | B } => B ${ B & ((1 << 32) - 1) } => B B :MSTORE(SP + 1155) 24n => A ;; LoadConst32 @@ -2225,10 +2300,12 @@ label_2_3: 0n => A ;; LoadConst32 $ => B :MLOAD(SP + 8) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 8) % 8 } => A ${ (E + 8) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 4))) | B } => B ${ B & ((1 << 32) - 1) } => B B :MSTORE(SP + 1139) 24n => A ;; LoadConst32 @@ -2564,11 +2641,12 @@ label_2_3: 0n => A ;; LoadConst32 $ => B :MLOAD(SP + 8) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 12) % 8 } => A ${ (E + 12) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) - ${ B >> 32 } => B + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 4))) | B } => B ${ B & ((1 << 32) - 1) } => B B :MSTORE(SP + 1123) 24n => A ;; LoadConst32 @@ -2904,10 +2982,12 @@ label_2_3: 0n => A ;; LoadConst32 $ => B :MLOAD(SP + 8) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 16) % 8 } => A ${ (E + 16) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 4))) | B } => B ${ B & ((1 << 32) - 1) } => B B :MSTORE(SP + 1107) 24n => A ;; LoadConst32 @@ -3242,11 +3322,12 @@ label_2_3: 0n => A ;; LoadConst32 $ => B :MLOAD(SP + 8) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 20) % 8 } => A ${ (E + 20) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) - ${ B >> 32 } => B + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 4))) | B } => B ${ B & ((1 << 32) - 1) } => B B :MSTORE(SP + 1091) 24n => A ;; LoadConst32 @@ -3582,10 +3663,12 @@ label_2_3: 0n => A ;; LoadConst32 $ => B :MLOAD(SP + 8) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 24) % 8 } => A ${ (E + 24) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 4))) | B } => B ${ B & ((1 << 32) - 1) } => B B :MSTORE(SP + 1075) 24n => A ;; LoadConst32 @@ -3921,11 +4004,12 @@ label_2_3: 0n => A ;; LoadConst32 $ => B :MLOAD(SP + 8) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 28) % 8 } => A ${ (E + 28) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) - ${ B >> 32 } => B + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 4))) | B } => B ${ B & ((1 << 32) - 1) } => B B :MSTORE(SP + 1059) 24n => A ;; LoadConst32 @@ -4261,10 +4345,12 @@ label_2_3: 0n => A ;; LoadConst32 $ => B :MLOAD(SP + 8) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 32) % 8 } => A ${ (E + 32) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 4))) | B } => B ${ B & ((1 << 32) - 1) } => B B :MSTORE(SP + 1043) 24n => A ;; LoadConst32 @@ -4600,11 +4686,12 @@ label_2_3: 0n => A ;; LoadConst32 $ => B :MLOAD(SP + 8) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 36) % 8 } => A ${ (E + 36) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) - ${ B >> 32 } => B + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 4))) | B } => B ${ B & ((1 << 32) - 1) } => B B :MSTORE(SP + 1027) 24n => A ;; LoadConst32 @@ -4940,10 +5027,12 @@ label_2_3: 0n => A ;; LoadConst32 $ => B :MLOAD(SP + 8) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 40) % 8 } => A ${ (E + 40) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 4))) | B } => B ${ B & ((1 << 32) - 1) } => B B :MSTORE(SP + 1011) 24n => A ;; LoadConst32 @@ -5279,11 +5368,12 @@ label_2_3: 0n => A ;; LoadConst32 $ => B :MLOAD(SP + 8) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 44) % 8 } => A ${ (E + 44) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) - ${ B >> 32 } => B + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 4))) | B } => B ${ B & ((1 << 32) - 1) } => B B :MSTORE(SP + 995) 24n => A ;; LoadConst32 @@ -5619,10 +5709,12 @@ label_2_3: 0n => A ;; LoadConst32 $ => B :MLOAD(SP + 8) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 48) % 8 } => A ${ (E + 48) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 4))) | B } => B ${ B & ((1 << 32) - 1) } => B B :MSTORE(SP + 979) 24n => A ;; LoadConst32 @@ -5958,11 +6050,12 @@ label_2_3: 0n => A ;; LoadConst32 $ => B :MLOAD(SP + 8) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 52) % 8 } => A ${ (E + 52) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) - ${ B >> 32 } => B + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 4))) | B } => B ${ B & ((1 << 32) - 1) } => B B :MSTORE(SP + 963) 24n => A ;; LoadConst32 @@ -6298,10 +6391,12 @@ label_2_3: 0n => A ;; LoadConst32 $ => B :MLOAD(SP + 8) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 56) % 8 } => A ${ (E + 56) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 4))) | B } => B ${ B & ((1 << 32) - 1) } => B B :MSTORE(SP + 947) 24n => A ;; LoadConst32 @@ -6637,11 +6732,12 @@ label_2_3: 0n => A ;; LoadConst32 $ => B :MLOAD(SP + 8) $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 60) % 8 } => A ${ (E + 60) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) - ${ B >> 32 } => B + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 4))) | B } => B ${ B & ((1 << 32) - 1) } => B B :MSTORE(SP + 931) 24n => A ;; LoadConst32 @@ -27868,75 +27964,91 @@ label_2_7: $ => B :MLOAD(SP) $ => E :ADD $ => C :MLOAD(SP + 9) - ${ E % 8 } => A - 0: ASSERT + ${ (E + 28) % 8 } => A ${ (E + 28) / 8 } => E ${ C & ((1 << 32) - 1) } => C $ => D :MLOAD(MEM:E) - ${ (D & ~(((1 << 32) - 1) << 32)) | (C << 32) } :MSTORE(MEM:E) + ${ (D & ~(((1 << 32) - 1) << (8 * A))) | (C << (8 * A)) } :MSTORE(MEM:E) + ${ (A + 4 > 8) ? (A + 4 - 8) : 0 } => A + $ => D :MLOAD(MEM:E + 1) + ${ (D & ~((1 << (8 * A)) - 1)) | (C & ((1 << (8 * A)) - 1)) } :MSTORE(MEM:E + 1) 0n => A ;; LoadConst32 $ => E :ADD $ => C :MLOAD(SP + 10) - ${ E % 8 } => A - 0: ASSERT + ${ (E + 24) % 8 } => A ${ (E + 24) / 8 } => E ${ C & ((1 << 32) - 1) } => C $ => D :MLOAD(MEM:E) - ${ (D & ~(((1 << 32) - 1) << 0)) | (C << 0) } :MSTORE(MEM:E) + ${ (D & ~(((1 << 32) - 1) << (8 * A))) | (C << (8 * A)) } :MSTORE(MEM:E) + ${ (A + 4 > 8) ? (A + 4 - 8) : 0 } => A + $ => D :MLOAD(MEM:E + 1) + ${ (D & ~((1 << (8 * A)) - 1)) | (C & ((1 << (8 * A)) - 1)) } :MSTORE(MEM:E + 1) 0n => A ;; LoadConst32 $ => E :ADD $ => C :MLOAD(SP + 11) - ${ E % 8 } => A - 0: ASSERT + ${ (E + 20) % 8 } => A ${ (E + 20) / 8 } => E ${ C & ((1 << 32) - 1) } => C $ => D :MLOAD(MEM:E) - ${ (D & ~(((1 << 32) - 1) << 32)) | (C << 32) } :MSTORE(MEM:E) + ${ (D & ~(((1 << 32) - 1) << (8 * A))) | (C << (8 * A)) } :MSTORE(MEM:E) + ${ (A + 4 > 8) ? (A + 4 - 8) : 0 } => A + $ => D :MLOAD(MEM:E + 1) + ${ (D & ~((1 << (8 * A)) - 1)) | (C & ((1 << (8 * A)) - 1)) } :MSTORE(MEM:E + 1) 0n => A ;; LoadConst32 $ => E :ADD $ => C :MLOAD(SP + 12) - ${ E % 8 } => A - 0: ASSERT + ${ (E + 16) % 8 } => A ${ (E + 16) / 8 } => E ${ C & ((1 << 32) - 1) } => C $ => D :MLOAD(MEM:E) - ${ (D & ~(((1 << 32) - 1) << 0)) | (C << 0) } :MSTORE(MEM:E) + ${ (D & ~(((1 << 32) - 1) << (8 * A))) | (C << (8 * A)) } :MSTORE(MEM:E) + ${ (A + 4 > 8) ? (A + 4 - 8) : 0 } => A + $ => D :MLOAD(MEM:E + 1) + ${ (D & ~((1 << (8 * A)) - 1)) | (C & ((1 << (8 * A)) - 1)) } :MSTORE(MEM:E + 1) 0n => A ;; LoadConst32 $ => E :ADD $ => C :MLOAD(SP + 13) - ${ E % 8 } => A - 0: ASSERT + ${ (E + 12) % 8 } => A ${ (E + 12) / 8 } => E ${ C & ((1 << 32) - 1) } => C $ => D :MLOAD(MEM:E) - ${ (D & ~(((1 << 32) - 1) << 32)) | (C << 32) } :MSTORE(MEM:E) + ${ (D & ~(((1 << 32) - 1) << (8 * A))) | (C << (8 * A)) } :MSTORE(MEM:E) + ${ (A + 4 > 8) ? (A + 4 - 8) : 0 } => A + $ => D :MLOAD(MEM:E + 1) + ${ (D & ~((1 << (8 * A)) - 1)) | (C & ((1 << (8 * A)) - 1)) } :MSTORE(MEM:E + 1) 0n => A ;; LoadConst32 $ => E :ADD $ => C :MLOAD(SP + 14) - ${ E % 8 } => A - 0: ASSERT + ${ (E + 8) % 8 } => A ${ (E + 8) / 8 } => E ${ C & ((1 << 32) - 1) } => C $ => D :MLOAD(MEM:E) - ${ (D & ~(((1 << 32) - 1) << 0)) | (C << 0) } :MSTORE(MEM:E) + ${ (D & ~(((1 << 32) - 1) << (8 * A))) | (C << (8 * A)) } :MSTORE(MEM:E) + ${ (A + 4 > 8) ? (A + 4 - 8) : 0 } => A + $ => D :MLOAD(MEM:E + 1) + ${ (D & ~((1 << (8 * A)) - 1)) | (C & ((1 << (8 * A)) - 1)) } :MSTORE(MEM:E + 1) 0n => A ;; LoadConst32 $ => E :ADD $ => C :MLOAD(SP + 15) - ${ E % 8 } => A - 0: ASSERT + ${ (E + 4) % 8 } => A ${ (E + 4) / 8 } => E ${ C & ((1 << 32) - 1) } => C $ => D :MLOAD(MEM:E) - ${ (D & ~(((1 << 32) - 1) << 32)) | (C << 32) } :MSTORE(MEM:E) + ${ (D & ~(((1 << 32) - 1) << (8 * A))) | (C << (8 * A)) } :MSTORE(MEM:E) + ${ (A + 4 > 8) ? (A + 4 - 8) : 0 } => A + $ => D :MLOAD(MEM:E + 1) + ${ (D & ~((1 << (8 * A)) - 1)) | (C & ((1 << (8 * A)) - 1)) } :MSTORE(MEM:E + 1) 0n => A ;; LoadConst32 $ => E :ADD $ => B :MLOAD(SP + 16) - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E ${ B & ((1 << 32) - 1) } => B $ => D :MLOAD(MEM:E) - ${ (D & ~(((1 << 32) - 1) << 0)) | (B << 0) } :MSTORE(MEM:E) + ${ (D & ~(((1 << 32) - 1) << (8 * A))) | (B << (8 * A)) } :MSTORE(MEM:E) + ${ (A + 4 > 8) ? (A + 4 - 8) : 0 } => A + $ => D :MLOAD(MEM:E + 1) + ${ (D & ~((1 << (8 * A)) - 1)) | (B & ((1 << (8 * A)) - 1)) } :MSTORE(MEM:E + 1) SP + 1182 => SP $ => C :MLOAD(SP - 1) $ => D :MLOAD(SP - 2) diff --git a/cranelift/zkasm_data/generated/memory.zkasm b/cranelift/zkasm_data/generated/memory.zkasm index fcd3c1ac387d..f318101c67b6 100644 --- a/cranelift/zkasm_data/generated/memory.zkasm +++ b/cranelift/zkasm_data/generated/memory.zkasm @@ -15,38 +15,46 @@ function_1: 2n => C ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E ${ C & ((1 << 32) - 1) } => C $ => D :MLOAD(MEM:E) - ${ (D & ~(((1 << 32) - 1) << 0)) | (C << 0) } :MSTORE(MEM:E) + ${ (D & ~(((1 << 32) - 1) << (8 * A))) | (C << (8 * A)) } :MSTORE(MEM:E) + ${ (A + 4 > 8) ? (A + 4 - 8) : 0 } => A + $ => D :MLOAD(MEM:E + 1) + ${ (D & ~((1 << (8 * A)) - 1)) | (C & ((1 << (8 * A)) - 1)) } :MSTORE(MEM:E + 1) 8n => B ;; LoadConst32 3n => C ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E ${ C & ((1 << 32) - 1) } => C $ => D :MLOAD(MEM:E) - ${ (D & ~(((1 << 32) - 1) << 0)) | (C << 0) } :MSTORE(MEM:E) + ${ (D & ~(((1 << 32) - 1) << (8 * A))) | (C << (8 * A)) } :MSTORE(MEM:E) + ${ (A + 4 > 8) ? (A + 4 - 8) : 0 } => A + $ => D :MLOAD(MEM:E + 1) + ${ (D & ~((1 << (8 * A)) - 1)) | (C & ((1 << (8 * A)) - 1)) } :MSTORE(MEM:E + 1) 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => E :MLOAD(MEM:E) + ${ E >> (8 * A) } => E + ${ (D << (128 - 8 * (A + 4))) | E } => E ${ E & ((1 << 32) - 1) } => E E => C 8n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 4))) | B } => B ${ B & ((1 << 32) - 1) } => B C => A $ => A :ADD diff --git a/cranelift/zkasm_data/generated/memory_i32.zkasm b/cranelift/zkasm_data/generated/memory_i32.zkasm index 0311d85675ed..cf9e3dddc9f8 100644 --- a/cranelift/zkasm_data/generated/memory_i32.zkasm +++ b/cranelift/zkasm_data/generated/memory_i32.zkasm @@ -19,10 +19,12 @@ function_1: 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 1))) | B } => B ${ B & ((1 << 8) - 1) } => B B => A 97n => B ;; LoadConst32 @@ -30,10 +32,12 @@ function_1: 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => C :MLOAD(MEM:E) + ${ C >> (8 * A) } => C + ${ (D << (128 - 8 * (A + 1))) | C } => C ${ C & ((1 << 8) - 1) } => C C => A 97n => B ;; LoadConst32 @@ -41,11 +45,12 @@ function_1: 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 1) % 8 } => A ${ (E + 1) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => E :MLOAD(MEM:E) - ${ E >> 8 } => E + ${ E >> (8 * A) } => E + ${ (D << (128 - 8 * (A + 1))) | E } => E ${ E & ((1 << 8) - 1) } => E E => A 98n => B ;; LoadConst32 @@ -53,11 +58,12 @@ function_1: 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 2) % 8 } => A ${ (E + 2) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => E :MLOAD(MEM:E) - ${ E >> 16 } => E + ${ E >> (8 * A) } => E + ${ (D << (128 - 8 * (A + 1))) | E } => E ${ E & ((1 << 8) - 1) } => E E => A 99n => B ;; LoadConst32 @@ -65,11 +71,12 @@ function_1: 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 25) % 8 } => A ${ (E + 25) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) - ${ B >> 8 } => B + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 1))) | B } => B ${ B & ((1 << 8) - 1) } => B B => A 122n => B ;; LoadConst32 @@ -77,10 +84,12 @@ function_1: 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 1))) | B } => B ${ B & ((1 << 8) - 1) } => B B => A 97n => B ;; LoadConst32 @@ -88,10 +97,12 @@ function_1: 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => C :MLOAD(MEM:E) + ${ C >> (8 * A) } => C + ${ (D << (128 - 8 * (A + 1))) | C } => C ${ C & ((1 << 8) - 1) } => C C => A 97n => B ;; LoadConst32 @@ -99,11 +110,12 @@ function_1: 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 1) % 8 } => A ${ (E + 1) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => E :MLOAD(MEM:E) - ${ E >> 8 } => E + ${ E >> (8 * A) } => E + ${ (D << (128 - 8 * (A + 1))) | E } => E ${ E & ((1 << 8) - 1) } => E E => A 98n => B ;; LoadConst32 @@ -111,11 +123,12 @@ function_1: 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 2) % 8 } => A ${ (E + 2) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => E :MLOAD(MEM:E) - ${ E >> 16 } => E + ${ E >> (8 * A) } => E + ${ (D << (128 - 8 * (A + 1))) | E } => E ${ E & ((1 << 8) - 1) } => E E => A 99n => B ;; LoadConst32 @@ -123,11 +136,12 @@ function_1: 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 25) % 8 } => A ${ (E + 25) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) - ${ B >> 8 } => B + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 1))) | B } => B ${ B & ((1 << 8) - 1) } => B B => A 122n => B ;; LoadConst32 @@ -135,10 +149,12 @@ function_1: 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 2))) | B } => B ${ B & ((1 << 16) - 1) } => B B => A 25185n => B ;; LoadConst32 @@ -146,10 +162,12 @@ function_1: 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => C :MLOAD(MEM:E) + ${ C >> (8 * A) } => C + ${ (D << (128 - 8 * (A + 2))) | C } => C ${ C & ((1 << 16) - 1) } => C C => A 25185n => B ;; LoadConst32 @@ -157,11 +175,12 @@ function_1: 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 1) % 8 } => A ${ (E + 1) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => E :MLOAD(MEM:E) - ${ E >> 8 } => E + ${ E >> (8 * A) } => E + ${ (D << (128 - 8 * (A + 2))) | E } => E ${ E & ((1 << 16) - 1) } => E E => A 25442n => B ;; LoadConst32 @@ -169,11 +188,12 @@ function_1: 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 2) % 8 } => A ${ (E + 2) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => E :MLOAD(MEM:E) - ${ E >> 16 } => E + ${ E >> (8 * A) } => E + ${ (D << (128 - 8 * (A + 2))) | E } => E ${ E & ((1 << 16) - 1) } => E E => A 25699n => B ;; LoadConst32 @@ -181,11 +201,12 @@ function_1: 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 25) % 8 } => A ${ (E + 25) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) - ${ B >> 8 } => B + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 2))) | B } => B ${ B & ((1 << 16) - 1) } => B B => A 122n => B ;; LoadConst32 @@ -193,10 +214,12 @@ function_1: 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 2))) | B } => B ${ B & ((1 << 16) - 1) } => B B => A 25185n => B ;; LoadConst32 @@ -204,10 +227,12 @@ function_1: 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => C :MLOAD(MEM:E) + ${ C >> (8 * A) } => C + ${ (D << (128 - 8 * (A + 2))) | C } => C ${ C & ((1 << 16) - 1) } => C C => A 25185n => B ;; LoadConst32 @@ -215,11 +240,12 @@ function_1: 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 1) % 8 } => A ${ (E + 1) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => E :MLOAD(MEM:E) - ${ E >> 8 } => E + ${ E >> (8 * A) } => E + ${ (D << (128 - 8 * (A + 2))) | E } => E ${ E & ((1 << 16) - 1) } => E E => A 25442n => B ;; LoadConst32 @@ -227,11 +253,12 @@ function_1: 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 2) % 8 } => A ${ (E + 2) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => E :MLOAD(MEM:E) - ${ E >> 16 } => E + ${ E >> (8 * A) } => E + ${ (D << (128 - 8 * (A + 2))) | E } => E ${ E & ((1 << 16) - 1) } => E E => A 25699n => B ;; LoadConst32 @@ -239,11 +266,12 @@ function_1: 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 25) % 8 } => A ${ (E + 25) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) - ${ B >> 8 } => B + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 2))) | B } => B ${ B & ((1 << 16) - 1) } => B B => A 122n => B ;; LoadConst32 @@ -251,10 +279,12 @@ function_1: 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 4))) | B } => B ${ B & ((1 << 32) - 1) } => B B => A 1684234849n => B ;; LoadConst32 @@ -262,10 +292,12 @@ function_1: 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E) % 8 } => A ${ (E) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => C :MLOAD(MEM:E) + ${ C >> (8 * A) } => C + ${ (D << (128 - 8 * (A + 4))) | C } => C ${ C & ((1 << 32) - 1) } => C C => A 1684234849n => B ;; LoadConst32 @@ -273,11 +305,12 @@ function_1: 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 1) % 8 } => A ${ (E + 1) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => E :MLOAD(MEM:E) - ${ E >> 8 } => E + ${ E >> (8 * A) } => E + ${ (D << (128 - 8 * (A + 4))) | E } => E ${ E & ((1 << 32) - 1) } => E E => A 1701077858n => B ;; LoadConst32 @@ -285,11 +318,12 @@ function_1: 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 2) % 8 } => A ${ (E + 2) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => E :MLOAD(MEM:E) - ${ E >> 16 } => E + ${ E >> (8 * A) } => E + ${ (D << (128 - 8 * (A + 4))) | E } => E ${ E & ((1 << 32) - 1) } => E E => A 1717920867n => B ;; LoadConst32 @@ -297,11 +331,12 @@ function_1: 0n => B ;; LoadConst32 0n => A ;; LoadConst32 $ => E :ADD - ${ E % 8 } => A - 0: ASSERT + ${ (E + 25) % 8 } => A ${ (E + 25) / 8 } => E + $ => D :MLOAD(MEM:E + 1) $ => B :MLOAD(MEM:E) - ${ B >> 8 } => B + ${ B >> (8 * A) } => B + ${ (D << (128 - 8 * (A + 4))) | B } => B ${ B & ((1 << 32) - 1) } => B B => A 122n => B ;; LoadConst32