Skip to content

Commit

Permalink
Refactor StoreBucket to avoid generating call to "llvm.donothing"
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-hoffman committed Oct 30, 2023
1 parent 1b35ba8 commit fc48ec5
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 14 deletions.
1 change: 0 additions & 1 deletion circom/tests/subcmps/subcmps0A.circom
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ component main = SubCmps0A(2);
//CHECK-NEXT: br label %fold_true3
//CHECK-EMPTY:
//CHECK-NEXT: fold_true3:
//CHECK-NEXT: call void @llvm.donothing()
//CHECK-NEXT: call void @IsZero_0_run([0 x i256]* %sub_[[X4]])
//CHECK-NEXT: br label %store4
//CHECK-EMPTY:
Expand Down
1 change: 0 additions & 1 deletion circom/tests/subcmps/subcmps0B.circom
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ component main = SubCmps0B(2);
//CHECK-NEXT: br label %fold_true3
//CHECK-EMPTY:
//CHECK-NEXT: fold_true3:
//CHECK-NEXT: call void @llvm.donothing()
//CHECK-NEXT: call void @IsZero_0_run([0 x i256]* %sub_[[X5]])
//CHECK-NEXT: br label %store4
//CHECK-EMPTY:
Expand Down
1 change: 0 additions & 1 deletion circom/tests/subcmps/subcmps0C.circom
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ component main = SubCmps0C(2);
//CHECK-NEXT: br label %fold_true3
//CHECK-EMPTY:
//CHECK-NEXT: fold_true3:
//CHECK-NEXT: call void @llvm.donothing()
//CHECK-NEXT: call void @IsZero_0_run([0 x i256]* %sub_[[X4]])
//CHECK-NEXT: br label %store4
//CHECK-EMPTY:
Expand Down
1 change: 0 additions & 1 deletion circom/tests/subcmps/subcmps0D.circom
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ component main = SubCmps0D(3);
//CHECK-NEXT: br label %fold_true6
//CHECK-EMPTY:
//CHECK-NEXT: fold_true6:
//CHECK-NEXT: call void @llvm.donothing()
//CHECK-NEXT: call void @Add_0_run([0 x i256]* %sub_[[X6]])
//CHECK-NEXT: br label %store7
//CHECK-EMPTY:
Expand Down
1 change: 0 additions & 1 deletion circom/tests/subcmps/subcmps1.circom
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ component main = SubCmps1(3);
//CHECK-NEXT: br label %fold_true3
//CHECK-EMPTY:
//CHECK-NEXT: fold_true3:
//CHECK-NEXT: call void @llvm.donothing()
//CHECK-NEXT: call void @IsZero_0_run([0 x i256]* %sub_[[X4]])
//CHECK-NEXT: br label %store4
//CHECK-EMPTY:
Expand Down
1 change: 0 additions & 1 deletion circom/tests/subcmps/subcmps2.circom
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ component main = Caller();
//CHECK-NEXT: br label %fold_true3
//CHECK-EMPTY:
//CHECK-NEXT: fold_true3:
//CHECK-NEXT: call void @llvm.donothing()
//CHECK-NEXT: call void @Sum_0_run([0 x i256]* %sub_[[X3]])
//CHECK-NEXT: br label %store4
//CHECK-EMPTY:
Expand Down
15 changes: 7 additions & 8 deletions compiler/src/intermediate_representation/store_bucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ impl StoreBucket {
Some(name) => {
assert_eq!(1, context.size, "unhandled array store");
if name == LLVM_DONOTHING_FN_NAME {
//LLVM equivalent of a "nop" instruction
create_call(producer, LLVM_DONOTHING_FN_NAME, &[])
None
} else {
let arr_ptr = match &dest_address_type {
AddressType::Variable => producer.body_ctx().get_variable_array(producer),
Expand All @@ -128,11 +127,11 @@ impl StoreBucket {
}
.into_pointer_value();
let arr_ptr = pointer_cast(producer, arr_ptr, array_ptr_ty(producer));
create_call(
Some(create_call(
producer,
name.as_str(),
&[arr_ptr.into(), dest_index.into(), source.into_int_value().into()],
)
))
}
}
None => {
Expand Down Expand Up @@ -181,18 +180,18 @@ impl StoreBucket {
};
}
}
create_call(
Some(create_call(
producer,
FR_ARRAY_COPY_FN_NAME,
&[
source.into_pointer_value().into(),
dest_gep.into(),
create_literal_u32(producer, context.size as u64).into(),
],
)
))
} else {
// In the scalar case, just produce a store from the source value that was given
create_store(producer, dest_gep, source)
Some(create_store(producer, dest_gep, source))
}
}
};
Expand Down Expand Up @@ -256,7 +255,7 @@ impl StoreBucket {
}
}
}
Some(store)
store
}
}

Expand Down

0 comments on commit fc48ec5

Please sign in to comment.