Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: unchecked math operations in SSA #7011

Merged
merged 28 commits into from
Jan 10, 2025
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6331a91
Add some unchecked math operations
asterite Jan 9, 2025
3bb465a
Use unchecked add in `make_offset`
asterite Jan 9, 2025
41ee955
Use correct names when printing
asterite Jan 9, 2025
63af351
Parse unchecked ops
asterite Jan 9, 2025
a308767
Induction variable now uses unchecked add
asterite Jan 9, 2025
199a980
A few more cases where we need to check for unchecked ops
asterite Jan 9, 2025
f279e3d
A few more
asterite Jan 9, 2025
a2beb78
Use a boolean instead of another variant
asterite Jan 9, 2025
84de854
increment and decrement slice length
asterite Jan 9, 2025
20b323e
Merge branch 'master' into ab/unchecked-math
TomAFrench Jan 10, 2025
d230098
Merge branch 'master' into ab/unchecked-math
TomAFrench Jan 10, 2025
7dff466
Handle some TODOs
asterite Jan 10, 2025
626f0a2
Merge branch 'ab/unchecked-math' of github.com:noir-lang/noir into ab…
asterite Jan 10, 2025
dfad378
chore: address some todos
TomAFrench Jan 10, 2025
7840ced
Handle more TODOs
asterite Jan 10, 2025
c10520c
Merge branch 'ab/unchecked-math' of github.com:noir-lang/noir into ab…
asterite Jan 10, 2025
0df89c0
Handle one more TODO
asterite Jan 10, 2025
6f9d1c7
Fix tests
asterite Jan 10, 2025
f34fb51
Handle the final TODO
asterite Jan 10, 2025
e0ff78f
Don't emit unchecked operations for Fields, or when multiplying bools
asterite Jan 10, 2025
bacccc2
Add missing cast in remove_bit_shifts
asterite Jan 10, 2025
83f1fd8
Extract `self.check_binary_instruction`
asterite Jan 10, 2025
820c16c
Check binary instruction before simplification
asterite Jan 10, 2025
4683b0d
clippy
asterite Jan 10, 2025
cf1a9e7
Do cast in both cases
asterite Jan 10, 2025
ef30d7c
Only check and simplify binary instructions in `Binary::simplify`
asterite Jan 10, 2025
63cfd12
Fix comptime to_le_bits returning `[u8; N]` instead of `[u1; N]`
asterite Jan 10, 2025
9b42fd8
Allow casting u1 in comptime
asterite Jan 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Induction variable now uses unchecked add
  • Loading branch information
asterite committed Jan 9, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit a3087673e2ab26198544f48f015f1c186c016c10
15 changes: 11 additions & 4 deletions compiler/noirc_evaluator/src/ssa/opt/unrolling.rs
Original file line number Diff line number Diff line change
@@ -619,10 +619,17 @@
let header = &function.dfg[self.header];
let induction_var = header.parameters()[0];

back.instructions().iter().filter(|instruction| {
let instruction = &function.dfg[**instruction];
matches!(instruction, Instruction::Binary(Binary { lhs, operator: BinaryOp::Add, rhs: _ }) if *lhs == induction_var)
}).count()
back.instructions()
.iter()
.filter(|instruction| {
let instruction = &function.dfg[**instruction];
matches!(instruction,
Instruction::Binary(Binary { lhs, operator: BinaryOp::Add, rhs: _ }) |
Instruction::Binary(Binary { lhs, operator: BinaryOp::UncheckedAdd, rhs: _ })
if *lhs == induction_var
)
})
.count()
}

/// Decide if this loop is small enough that it can be inlined in a way that the number
@@ -1010,7 +1017,7 @@
use super::{is_new_size_ok, BoilerplateStats, Loops};

/// Tries to unroll all loops in each SSA function once, calling the `Function` directly,
/// bypassing the iterative loop done by the SSA which does further optimisations.

Check warning on line 1020 in compiler/noirc_evaluator/src/ssa/opt/unrolling.rs

GitHub Actions / Code

Unknown word (optimisations)
///
/// If any loop cannot be unrolled, it is left as-is or in a partially unrolled state.
fn try_unroll_loops(mut ssa: Ssa) -> (Ssa, Vec<RuntimeError>) {
Loading