Skip to content

Commit

Permalink
Merge branch 'master' into kh-goto-def-func
Browse files Browse the repository at this point in the history
  • Loading branch information
kobyhallx authored Dec 1, 2023
2 parents af97a21 + 36844fa commit 8359f69
Show file tree
Hide file tree
Showing 274 changed files with 45 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Rebuild ACIR artifacts
name: Build ACIR artifacts

on:
pull_request:
Expand Down Expand Up @@ -93,11 +93,6 @@ jobs:
chmod +x ${{ github.workspace }}/nargo/nargo
echo "${{ github.workspace }}/nargo" >> $GITHUB_PATH
- name: Set up Git user (Github Action)
run: |
git config --local user.name kevaundray
git config --local user.email [email protected]
- name: Run rebuild script
working-directory: test_programs
run: |
Expand All @@ -110,21 +105,3 @@ jobs:
name: acir-artifacts
path: ./test_programs/acir_artifacts
retention-days: 10

- name: Check for changes in acir_artifacts directory
id: check_changes
if: ${{ github.ref_name }} == "master"
run: |
git diff --quiet test_programs/acir_artifacts/ || echo "::set-output name=changes::true"
- name: Create or Update PR
if: steps.check_changes.outputs.changes == 'true'
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.NOIR_REPO_TOKEN }}
commit-message: "chore: update acir artifacts"
title: "chore: Update ACIR artifacts"
body: "Automatic PR to update acir artifacts"
add-paths: test_programs/acir_artifacts/*.gz
labels: "auto-pr"
branch: "auto-pr-rebuild-script-branch"
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,8 @@ impl AcirContext {
/// Converts the `AcirVar` to a `Witness` if it hasn't been already, and appends it to the
/// `GeneratedAcir`'s return witnesses.
pub(crate) fn return_var(&mut self, acir_var: AcirVar) -> Result<(), InternalError> {
let witness = self.var_to_witness(acir_var)?;
let return_var = self.get_or_create_witness_var(acir_var)?;
let witness = self.var_to_witness(return_var)?;
self.acir_ir.push_return_witness(witness);
Ok(())
}
Expand Down Expand Up @@ -1425,7 +1426,8 @@ impl AcirContext {
index: &AcirVar,
) -> Result<AcirVar, InternalError> {
// Fetch the witness corresponding to the index
let index_witness = self.var_to_witness(*index)?;
let index_var = self.get_or_create_witness_var(*index)?;
let index_witness = self.var_to_witness(index_var)?;

// Create a Variable to hold the result of the read and extract the corresponding Witness
let value_read_var = self.add_variable();
Expand All @@ -1446,11 +1448,12 @@ impl AcirContext {
value: &AcirVar,
) -> Result<(), InternalError> {
// Fetch the witness corresponding to the index
//
let index_witness = self.var_to_witness(*index)?;
let index_var = self.get_or_create_witness_var(*index)?;
let index_witness = self.var_to_witness(index_var)?;

// Fetch the witness corresponding to the value to be written
let value_write_witness = self.var_to_witness(*value)?;
let value_write_var = self.get_or_create_witness_var(*value)?;
let value_write_witness = self.var_to_witness(value_write_var)?;

// Add the memory write operation to the list of opcodes
let op = MemOp::write_to_mem_index(index_witness.into(), value_write_witness.into());
Expand Down Expand Up @@ -1492,6 +1495,7 @@ impl AcirContext {
) -> Result<(), InternalError> {
match input {
AcirValue::Var(var, _) => {
let var = self.get_or_create_witness_var(var)?;
witnesses.push(self.var_to_witness(var)?);
}
AcirValue::Array(values) => {
Expand Down
64 changes: 34 additions & 30 deletions compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2128,9 +2128,9 @@ impl Context {
)?;

// Read from the original slice the value we want to insert into our new slice.
// We need to make sure of two things:
// 1. That we read the previous element for when we have an index greater than insertion index.
// 2. That the index we are reading from is within the array bounds
// We need to make sure that we read the previous element when our current index is greater than insertion index.
// If the index for the previous element is out of the array bounds we can avoid the check for whether
// the current index is over the insertion index.
let shifted_index = if i < inner_elem_size_usize {
current_index
} else {
Expand Down Expand Up @@ -2279,41 +2279,45 @@ impl Context {
// can lead to a potential out of bounds error. In this case we just fetch from the original slice
// at the current index. As we are decreasing the slice in length, this is a safe operation.
let result_block_id = self.block_id(&result_ids[1]);
self.initialize_array(result_block_id, slice_size, None)?;
self.initialize_array(
result_block_id,
slice_size,
Some(AcirValue::Array(new_slice.clone())),
)?;
for i in 0..slice_size {
let current_index = self.acir_context.add_constant(i);

let shifted_index = if (i + popped_elements_size) >= slice_size {
current_index
} else {
self.acir_context.add_constant(i + popped_elements_size)
};
let value_current_index = &new_slice[i].borrow_var()?;

let value_shifted_index =
self.acir_context.read_from_memory(block_id, &shifted_index)?;
let value_current_index = new_slice[i].borrow_var()?;
if slice_size > (i + popped_elements_size) {
let shifted_index =
self.acir_context.add_constant(i + popped_elements_size);

let use_shifted_value = self.acir_context.more_than_eq_var(
current_index,
flat_user_index,
64,
self.current_side_effects_enabled_var,
)?;
let value_shifted_index =
self.acir_context.read_from_memory(block_id, &shifted_index)?;

let shifted_value_pred =
self.acir_context.mul_var(value_shifted_index, use_shifted_value)?;
let not_pred = self.acir_context.sub_var(one, use_shifted_value)?;
let current_value_pred =
self.acir_context.mul_var(not_pred, value_current_index)?;
let use_shifted_value = self.acir_context.more_than_eq_var(
current_index,
flat_user_index,
64,
self.current_side_effects_enabled_var,
)?;

let new_value =
self.acir_context.add_var(shifted_value_pred, current_value_pred)?;
let shifted_value_pred =
self.acir_context.mul_var(value_shifted_index, use_shifted_value)?;
let not_pred = self.acir_context.sub_var(one, use_shifted_value)?;
let current_value_pred =
self.acir_context.mul_var(not_pred, *value_current_index)?;

self.acir_context.write_to_memory(
result_block_id,
&current_index,
&new_value,
)?;
let new_value =
self.acir_context.add_var(shifted_value_pred, current_value_pred)?;

self.acir_context.write_to_memory(
result_block_id,
&current_index,
&new_value,
)?;
};
}

let new_slice_val = AcirValue::Array(new_slice);
Expand Down
1 change: 1 addition & 0 deletions test_programs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
acir_artifacts
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/1_mul/target/acir.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/1_mul/target/witness.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/2_div/target/acir.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/2_div/target/witness.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/3_add/target/acir.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/3_add/target/witness.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/4_sub/target/acir.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/4_sub/target/witness.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/5_over/target/acir.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/5_over/target/witness.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/6/target/acir.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/6/target/witness.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/6_array/target/acir.gz
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/7/target/acir.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/7/target/witness.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/array_eq/target/acir.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/array_eq/target/witness.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/array_len/target/acir.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/array_sort/target/acir.gz
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/assert/target/acir.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/assert/target/witness.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/assign_ex/target/acir.gz
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/bit_and/target/acir.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/bit_and/target/witness.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/bool_not/target/acir.gz
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/bool_or/target/acir.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/bool_or/target/witness.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/brillig_not/target/acir.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/cast_bool/target/acir.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/eddsa/target/acir.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/eddsa/target/witness.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/generics/target/acir.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/import/target/acir.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/import/target/witness.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/keccak256/target/acir.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/modules/target/acir.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/modules/target/witness.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/modulus/target/acir.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/modulus/target/witness.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/pred_eq/target/acir.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/pred_eq/target/witness.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/references/target/acir.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/scalar_mul/target/acir.gz
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/schnorr/target/acir.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/schnorr/target/witness.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/sha256/target/acir.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/sha256/target/witness.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/simple_mut/target/acir.gz
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/simple_not/target/acir.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/slices/target/acir.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/strings/target/witness.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/struct/target/acir.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/struct/target/witness.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/submodules/target/acir.gz
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/to_be_bytes/target/acir.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/to_le_bytes/target/acir.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/tuples/target/acir.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/tuples/target/witness.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed test_programs/acir_artifacts/xor/target/acir.gz
Binary file not shown.
Binary file removed test_programs/acir_artifacts/xor/target/witness.gz
Binary file not shown.

0 comments on commit 8359f69

Please sign in to comment.