Skip to content

Commit

Permalink
chore(avm): remove some parentheses in codegen relations (#11766)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanmon authored Feb 6, 2025
1 parent 753f505 commit f2f2634
Show file tree
Hide file tree
Showing 23 changed files with 1,941 additions and 2,048 deletions.
238 changes: 108 additions & 130 deletions barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/alu.hpp

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,71 +23,68 @@ template <typename FF_> class binaryImpl {

{
using Accumulator = typename std::tuple_element_t<0, ContainerOverSubrelations>;
auto tmp = (new_term.binary_sel_bin * (FF(1) - new_term.binary_sel_bin));
auto tmp = new_term.binary_sel_bin * (FF(1) - new_term.binary_sel_bin);
tmp *= scaling_factor;
std::get<0>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<1, ContainerOverSubrelations>;
auto tmp = ((new_term.binary_op_id_shift - new_term.binary_op_id) * new_term.binary_mem_tag_ctr);
auto tmp = (new_term.binary_op_id_shift - new_term.binary_op_id) * new_term.binary_mem_tag_ctr;
tmp *= scaling_factor;
std::get<1>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<2, ContainerOverSubrelations>;
auto tmp = (((new_term.binary_mem_tag_ctr_shift - new_term.binary_mem_tag_ctr) + FF(1)) *
new_term.binary_mem_tag_ctr);
auto tmp = ((new_term.binary_mem_tag_ctr_shift - new_term.binary_mem_tag_ctr) + FF(1)) *
new_term.binary_mem_tag_ctr;
tmp *= scaling_factor;
std::get<2>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<3, ContainerOverSubrelations>;
auto tmp = ((new_term.binary_mem_tag_ctr *
(((FF(1) - new_term.binary_sel_bin) * (FF(1) - new_term.binary_mem_tag_ctr_inv)) +
new_term.binary_mem_tag_ctr_inv)) -
auto tmp = (new_term.binary_mem_tag_ctr *
((FF(1) - new_term.binary_sel_bin) * (FF(1) - new_term.binary_mem_tag_ctr_inv) +
new_term.binary_mem_tag_ctr_inv) -
new_term.binary_sel_bin);
tmp *= scaling_factor;
std::get<3>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<4, ContainerOverSubrelations>;
auto tmp = ((FF(1) - new_term.binary_sel_bin) * new_term.binary_acc_ia);
auto tmp = (FF(1) - new_term.binary_sel_bin) * new_term.binary_acc_ia;
tmp *= scaling_factor;
std::get<4>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<5, ContainerOverSubrelations>;
auto tmp = ((FF(1) - new_term.binary_sel_bin) * new_term.binary_acc_ib);
auto tmp = (FF(1) - new_term.binary_sel_bin) * new_term.binary_acc_ib;
tmp *= scaling_factor;
std::get<5>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<6, ContainerOverSubrelations>;
auto tmp = ((FF(1) - new_term.binary_sel_bin) * new_term.binary_acc_ic);
auto tmp = (FF(1) - new_term.binary_sel_bin) * new_term.binary_acc_ic;
tmp *= scaling_factor;
std::get<6>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<7, ContainerOverSubrelations>;
auto tmp =
(((new_term.binary_acc_ia - new_term.binary_ia_bytes) - (FF(256) * new_term.binary_acc_ia_shift)) *
new_term.binary_mem_tag_ctr);
auto tmp = ((new_term.binary_acc_ia - new_term.binary_ia_bytes) - FF(256) * new_term.binary_acc_ia_shift) *
new_term.binary_mem_tag_ctr;
tmp *= scaling_factor;
std::get<7>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<8, ContainerOverSubrelations>;
auto tmp =
(((new_term.binary_acc_ib - new_term.binary_ib_bytes) - (FF(256) * new_term.binary_acc_ib_shift)) *
new_term.binary_mem_tag_ctr);
auto tmp = ((new_term.binary_acc_ib - new_term.binary_ib_bytes) - FF(256) * new_term.binary_acc_ib_shift) *
new_term.binary_mem_tag_ctr;
tmp *= scaling_factor;
std::get<8>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<9, ContainerOverSubrelations>;
auto tmp =
(((new_term.binary_acc_ic - new_term.binary_ic_bytes) - (FF(256) * new_term.binary_acc_ic_shift)) *
new_term.binary_mem_tag_ctr);
auto tmp = ((new_term.binary_acc_ic - new_term.binary_ic_bytes) - FF(256) * new_term.binary_acc_ic_shift) *
new_term.binary_mem_tag_ctr;
tmp *= scaling_factor;
std::get<9>(evals) += typename Accumulator::View(tmp);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ template <typename FF_> class bytecodeImpl {

{
using Accumulator = typename std::tuple_element_t<0, ContainerOverSubrelations>;
auto tmp = (new_term.bytecode_end_latch * (FF(1) - new_term.bytecode_end_latch));
auto tmp = new_term.bytecode_end_latch * (FF(1) - new_term.bytecode_end_latch);
tmp *= scaling_factor;
std::get<0>(evals) += typename Accumulator::View(tmp);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,119 +28,118 @@ template <typename FF_> class cmpImpl {
const auto cmp_P_LO = FF(uint256_t{ 4891460686036598784UL, 2896914383306846353UL, 0UL, 0UL });
const auto cmp_P_HI = FF(uint256_t{ 13281191951274694749UL, 3486998266802970665UL, 0UL, 0UL });
const auto cmp_A_SUB_B_LO =
(((new_term.cmp_a_lo - new_term.cmp_b_lo) - FF(1)) + (new_term.cmp_borrow * cmp_POW_128));
((new_term.cmp_a_lo - new_term.cmp_b_lo) - FF(1)) + new_term.cmp_borrow * cmp_POW_128;
const auto cmp_A_SUB_B_HI = ((new_term.cmp_a_hi - new_term.cmp_b_hi) - new_term.cmp_borrow);
const auto cmp_B_SUB_A_LO = ((new_term.cmp_b_lo - new_term.cmp_a_lo) + (new_term.cmp_borrow * cmp_POW_128));
const auto cmp_B_SUB_A_LO = (new_term.cmp_b_lo - new_term.cmp_a_lo) + new_term.cmp_borrow * cmp_POW_128;
const auto cmp_B_SUB_A_HI = ((new_term.cmp_b_hi - new_term.cmp_a_hi) - new_term.cmp_borrow);
const auto cmp_IS_GT = (new_term.cmp_op_gt * new_term.cmp_result);
const auto cmp_IS_GT = new_term.cmp_op_gt * new_term.cmp_result;

{
using Accumulator = typename std::tuple_element_t<0, ContainerOverSubrelations>;
auto tmp = (new_term.cmp_sel_rng_chk *
(new_term.cmp_range_chk_clk - ((new_term.cmp_clk * FF(256)) + new_term.cmp_cmp_rng_ctr)));
auto tmp = new_term.cmp_sel_rng_chk *
(new_term.cmp_range_chk_clk - (new_term.cmp_clk * FF(256) + new_term.cmp_cmp_rng_ctr));
tmp *= scaling_factor;
std::get<0>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<1, ContainerOverSubrelations>;
auto tmp = (new_term.cmp_op_non_ff_gt * ((new_term.cmp_diff - (cmp_A_GT_B * new_term.cmp_result)) -
(cmp_B_GTE_A * (FF(1) - new_term.cmp_result))));
auto tmp = new_term.cmp_op_non_ff_gt * ((new_term.cmp_diff - cmp_A_GT_B * new_term.cmp_result) -
cmp_B_GTE_A * (FF(1) - new_term.cmp_result));
tmp *= scaling_factor;
std::get<1>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<2, ContainerOverSubrelations>;
auto tmp = (new_term.cmp_sel_cmp - ((new_term.cmp_op_eq + new_term.cmp_op_gt) + new_term.cmp_op_non_ff_gt));
auto tmp = (new_term.cmp_sel_cmp - (new_term.cmp_op_eq + new_term.cmp_op_gt + new_term.cmp_op_non_ff_gt));
tmp *= scaling_factor;
std::get<2>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<3, ContainerOverSubrelations>;
auto tmp = (new_term.cmp_result * (FF(1) - new_term.cmp_result));
auto tmp = new_term.cmp_result * (FF(1) - new_term.cmp_result);
tmp *= scaling_factor;
std::get<3>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<4, ContainerOverSubrelations>;
auto tmp =
(new_term.cmp_op_eq * (((cmp_DIFF * ((new_term.cmp_result * (FF(1) - new_term.cmp_op_eq_diff_inv)) +
new_term.cmp_op_eq_diff_inv)) -
FF(1)) +
new_term.cmp_result));
auto tmp = new_term.cmp_op_eq * ((cmp_DIFF * (new_term.cmp_result * (FF(1) - new_term.cmp_op_eq_diff_inv) +
new_term.cmp_op_eq_diff_inv) -
FF(1)) +
new_term.cmp_result);
tmp *= scaling_factor;
std::get<4>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<5, ContainerOverSubrelations>;
auto tmp =
(new_term.cmp_op_gt * (new_term.cmp_input_a - (new_term.cmp_a_lo + (cmp_POW_128 * new_term.cmp_a_hi))));
new_term.cmp_op_gt * (new_term.cmp_input_a - (new_term.cmp_a_lo + cmp_POW_128 * new_term.cmp_a_hi));
tmp *= scaling_factor;
std::get<5>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<6, ContainerOverSubrelations>;
auto tmp =
(new_term.cmp_op_gt * (new_term.cmp_input_b - (new_term.cmp_b_lo + (cmp_POW_128 * new_term.cmp_b_hi))));
new_term.cmp_op_gt * (new_term.cmp_input_b - (new_term.cmp_b_lo + cmp_POW_128 * new_term.cmp_b_hi));
tmp *= scaling_factor;
std::get<6>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<7, ContainerOverSubrelations>;
auto tmp = (new_term.cmp_p_a_borrow * (FF(1) - new_term.cmp_p_a_borrow));
auto tmp = new_term.cmp_p_a_borrow * (FF(1) - new_term.cmp_p_a_borrow);
tmp *= scaling_factor;
std::get<7>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<8, ContainerOverSubrelations>;
auto tmp = (new_term.cmp_op_gt * (new_term.cmp_p_sub_a_lo - ((cmp_P_LO - new_term.cmp_a_lo) +
(new_term.cmp_p_a_borrow * cmp_POW_128))));
auto tmp = new_term.cmp_op_gt * (new_term.cmp_p_sub_a_lo -
((cmp_P_LO - new_term.cmp_a_lo) + new_term.cmp_p_a_borrow * cmp_POW_128));
tmp *= scaling_factor;
std::get<8>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<9, ContainerOverSubrelations>;
auto tmp = (new_term.cmp_op_gt *
(new_term.cmp_p_sub_a_hi - ((cmp_P_HI - new_term.cmp_a_hi) - new_term.cmp_p_a_borrow)));
auto tmp = new_term.cmp_op_gt *
(new_term.cmp_p_sub_a_hi - ((cmp_P_HI - new_term.cmp_a_hi) - new_term.cmp_p_a_borrow));
tmp *= scaling_factor;
std::get<9>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<10, ContainerOverSubrelations>;
auto tmp = (new_term.cmp_p_b_borrow * (FF(1) - new_term.cmp_p_b_borrow));
auto tmp = new_term.cmp_p_b_borrow * (FF(1) - new_term.cmp_p_b_borrow);
tmp *= scaling_factor;
std::get<10>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<11, ContainerOverSubrelations>;
auto tmp = (new_term.cmp_op_gt * (new_term.cmp_p_sub_b_lo - ((cmp_P_LO - new_term.cmp_b_lo) +
(new_term.cmp_p_b_borrow * cmp_POW_128))));
auto tmp = new_term.cmp_op_gt * (new_term.cmp_p_sub_b_lo -
((cmp_P_LO - new_term.cmp_b_lo) + new_term.cmp_p_b_borrow * cmp_POW_128));
tmp *= scaling_factor;
std::get<11>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<12, ContainerOverSubrelations>;
auto tmp = (new_term.cmp_op_gt *
(new_term.cmp_p_sub_b_hi - ((cmp_P_HI - new_term.cmp_b_hi) - new_term.cmp_p_b_borrow)));
auto tmp = new_term.cmp_op_gt *
(new_term.cmp_p_sub_b_hi - ((cmp_P_HI - new_term.cmp_b_hi) - new_term.cmp_p_b_borrow));
tmp *= scaling_factor;
std::get<12>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<13, ContainerOverSubrelations>;
auto tmp = (new_term.cmp_op_gt * (new_term.cmp_res_lo -
((cmp_A_SUB_B_LO * cmp_IS_GT) + (cmp_B_SUB_A_LO * (FF(1) - cmp_IS_GT)))));
auto tmp = new_term.cmp_op_gt *
(new_term.cmp_res_lo - (cmp_A_SUB_B_LO * cmp_IS_GT + cmp_B_SUB_A_LO * (FF(1) - cmp_IS_GT)));
tmp *= scaling_factor;
std::get<13>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<14, ContainerOverSubrelations>;
auto tmp = (new_term.cmp_op_gt * (new_term.cmp_res_hi -
((cmp_A_SUB_B_HI * cmp_IS_GT) + (cmp_B_SUB_A_HI * (FF(1) - cmp_IS_GT)))));
auto tmp = new_term.cmp_op_gt *
(new_term.cmp_res_hi - (cmp_A_SUB_B_HI * cmp_IS_GT + cmp_B_SUB_A_HI * (FF(1) - cmp_IS_GT)));
tmp *= scaling_factor;
std::get<14>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<15, ContainerOverSubrelations>;
auto tmp = (new_term.cmp_sel_rng_chk * (FF(1) - new_term.cmp_sel_rng_chk));
auto tmp = new_term.cmp_sel_rng_chk * (FF(1) - new_term.cmp_sel_rng_chk);
tmp *= scaling_factor;
std::get<15>(evals) += typename Accumulator::View(tmp);
}
Expand All @@ -152,71 +151,70 @@ template <typename FF_> class cmpImpl {
}
{
using Accumulator = typename std::tuple_element_t<17, ContainerOverSubrelations>;
auto tmp =
(((new_term.cmp_cmp_rng_ctr_shift - new_term.cmp_cmp_rng_ctr) + FF(1)) * new_term.cmp_cmp_rng_ctr);
auto tmp = ((new_term.cmp_cmp_rng_ctr_shift - new_term.cmp_cmp_rng_ctr) + FF(1)) * new_term.cmp_cmp_rng_ctr;
tmp *= scaling_factor;
std::get<17>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<18, ContainerOverSubrelations>;
auto tmp = (new_term.cmp_op_gt * (new_term.cmp_cmp_rng_ctr - FF(4)));
auto tmp = new_term.cmp_op_gt * (new_term.cmp_cmp_rng_ctr - FF(4));
tmp *= scaling_factor;
std::get<18>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<19, ContainerOverSubrelations>;
auto tmp = ((new_term.cmp_cmp_rng_ctr *
(((FF(1) - new_term.cmp_shift_sel) * (FF(1) - new_term.cmp_op_eq_diff_inv)) +
new_term.cmp_op_eq_diff_inv)) -
new_term.cmp_shift_sel);
auto tmp =
(new_term.cmp_cmp_rng_ctr * ((FF(1) - new_term.cmp_shift_sel) * (FF(1) - new_term.cmp_op_eq_diff_inv) +
new_term.cmp_op_eq_diff_inv) -
new_term.cmp_shift_sel);
tmp *= scaling_factor;
std::get<19>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<20, ContainerOverSubrelations>;
auto tmp = ((new_term.cmp_a_lo_shift - new_term.cmp_b_lo) * new_term.cmp_shift_sel);
auto tmp = (new_term.cmp_a_lo_shift - new_term.cmp_b_lo) * new_term.cmp_shift_sel;
tmp *= scaling_factor;
std::get<20>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<21, ContainerOverSubrelations>;
auto tmp = ((new_term.cmp_a_hi_shift - new_term.cmp_b_hi) * new_term.cmp_shift_sel);
auto tmp = (new_term.cmp_a_hi_shift - new_term.cmp_b_hi) * new_term.cmp_shift_sel;
tmp *= scaling_factor;
std::get<21>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<22, ContainerOverSubrelations>;
auto tmp = ((new_term.cmp_b_lo_shift - new_term.cmp_p_sub_a_lo) * new_term.cmp_shift_sel);
auto tmp = (new_term.cmp_b_lo_shift - new_term.cmp_p_sub_a_lo) * new_term.cmp_shift_sel;
tmp *= scaling_factor;
std::get<22>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<23, ContainerOverSubrelations>;
auto tmp = ((new_term.cmp_b_hi_shift - new_term.cmp_p_sub_a_hi) * new_term.cmp_shift_sel);
auto tmp = (new_term.cmp_b_hi_shift - new_term.cmp_p_sub_a_hi) * new_term.cmp_shift_sel;
tmp *= scaling_factor;
std::get<23>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<24, ContainerOverSubrelations>;
auto tmp = ((new_term.cmp_p_sub_a_lo_shift - new_term.cmp_p_sub_b_lo) * new_term.cmp_shift_sel);
auto tmp = (new_term.cmp_p_sub_a_lo_shift - new_term.cmp_p_sub_b_lo) * new_term.cmp_shift_sel;
tmp *= scaling_factor;
std::get<24>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<25, ContainerOverSubrelations>;
auto tmp = ((new_term.cmp_p_sub_a_hi_shift - new_term.cmp_p_sub_b_hi) * new_term.cmp_shift_sel);
auto tmp = (new_term.cmp_p_sub_a_hi_shift - new_term.cmp_p_sub_b_hi) * new_term.cmp_shift_sel;
tmp *= scaling_factor;
std::get<25>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<26, ContainerOverSubrelations>;
auto tmp = ((new_term.cmp_p_sub_b_lo_shift - new_term.cmp_res_lo) * new_term.cmp_shift_sel);
auto tmp = (new_term.cmp_p_sub_b_lo_shift - new_term.cmp_res_lo) * new_term.cmp_shift_sel;
tmp *= scaling_factor;
std::get<26>(evals) += typename Accumulator::View(tmp);
}
{
using Accumulator = typename std::tuple_element_t<27, ContainerOverSubrelations>;
auto tmp = ((new_term.cmp_p_sub_b_hi_shift - new_term.cmp_res_hi) * new_term.cmp_shift_sel);
auto tmp = (new_term.cmp_p_sub_b_hi_shift - new_term.cmp_res_hi) * new_term.cmp_shift_sel;
tmp *= scaling_factor;
std::get<27>(evals) += typename Accumulator::View(tmp);
}
Expand Down
Loading

0 comments on commit f2f2634

Please sign in to comment.