Skip to content

Conversation

@DiegoCivi
Copy link
Contributor

Fix BoundedInt is_zero libfunc

When using bounded_int_is_zero() libfunc with bounded ints that had a lower bound different than 0, we were not taking into account the offset used so it was not working properly.

Closes #NA

Introduces Breaking Changes?

Yes/No.

These PRs should be merged after this one right away, in that order.

Checklist

  • Linked to Github Issue.
  • Unit tests added.
  • Integration tests added.
  • This change requires new documentation.
    • Documentation has been added/updated.

@DiegoCivi DiegoCivi changed the title Fix BoundedInt is_zero libfunc [0.6.x] Fix BoundedInt is_zero libfunc Nov 14, 2025
@DiegoCivi DiegoCivi marked this pull request as ready for review November 14, 2025 21:51
@codecov-commenter
Copy link

codecov-commenter commented Nov 14, 2025

Codecov Report

❌ Patch coverage is 85.71429% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.97%. Comparing base (661ce60) to head (bfcaa6f).

Files with missing lines Patch % Lines
src/libfuncs/bounded_int.rs 85.71% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             v0.6    #1467      +/-   ##
==========================================
+ Coverage   76.86%   76.97%   +0.10%     
==========================================
  Files         111      111              
  Lines       26689    26716      +27     
==========================================
+ Hits        20515    20564      +49     
+ Misses       6174     6152      -22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@JulianGCalderon JulianGCalderon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

gabrielbosio
gabrielbosio previously approved these changes Nov 17, 2025
let k0 = if src_ty.is_bounded_int(registry)? {
// We can do the substraction since the lower bound of the bounded int will
// always be less or equal than 0.
entry.const_int_from_type(context, location, 0 - src_range.lower, src_value.r#type())?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just -src_range.lower?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in fcab1bb

Copy link
Contributor

@JulianGCalderon JulianGCalderon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@github-actions
Copy link

Benchmark results Main vs HEAD.

Base

Command Mean [s] Min [s] Max [s] Relative
base dict_insert.cairo (JIT) 2.569 ± 0.026 2.540 2.617 1.05 ± 0.01
base dict_insert.cairo (AOT) 2.440 ± 0.017 2.403 2.464 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head dict_insert.cairo (JIT) 2.636 ± 0.025 2.594 2.684 1.03 ± 0.01
head dict_insert.cairo (AOT) 2.565 ± 0.015 2.543 2.589 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base dict_snapshot.cairo (JIT) 2.233 ± 0.014 2.216 2.256 1.05 ± 0.01
base dict_snapshot.cairo (AOT) 2.123 ± 0.016 2.095 2.143 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head dict_snapshot.cairo (JIT) 2.373 ± 0.024 2.345 2.432 1.04 ± 0.01
head dict_snapshot.cairo (AOT) 2.279 ± 0.011 2.263 2.293 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base factorial_2M.cairo (JIT) 2.613 ± 0.018 2.577 2.648 1.01 ± 0.01
base factorial_2M.cairo (AOT) 2.577 ± 0.025 2.543 2.612 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head factorial_2M.cairo (JIT) 2.670 ± 0.010 2.660 2.690 1.02 ± 0.00
head factorial_2M.cairo (AOT) 2.628 ± 0.008 2.613 2.639 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base fib_2M.cairo (JIT) 2.149 ± 0.033 2.120 2.214 1.01 ± 0.02
base fib_2M.cairo (AOT) 2.124 ± 0.019 2.097 2.150 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head fib_2M.cairo (JIT) 2.280 ± 0.011 2.265 2.303 1.02 ± 0.01
head fib_2M.cairo (AOT) 2.234 ± 0.009 2.220 2.249 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base linear_search.cairo (JIT) 2.397 ± 0.052 2.324 2.468 1.08 ± 0.03
base linear_search.cairo (AOT) 2.228 ± 0.041 2.183 2.330 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head linear_search.cairo (JIT) 2.435 ± 0.023 2.411 2.470 1.06 ± 0.01
head linear_search.cairo (AOT) 2.304 ± 0.012 2.283 2.320 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base logistic_map.cairo (JIT) 2.459 ± 0.035 2.415 2.517 1.08 ± 0.02
base logistic_map.cairo (AOT) 2.267 ± 0.017 2.248 2.299 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head logistic_map.cairo (JIT) 2.572 ± 0.014 2.553 2.602 1.08 ± 0.01
head logistic_map.cairo (AOT) 2.387 ± 0.014 2.371 2.415 1.00

@github-actions
Copy link

Benchmarking results

Benchmark for program dict_insert

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 11.091 ± 0.092 11.011 11.296 4.51 ± 0.05
cairo-native (embedded AOT) 2.461 ± 0.018 2.448 2.509 1.00
cairo-native (embedded JIT using LLVM's ORC Engine) 2.545 ± 0.014 2.528 2.571 1.03 ± 0.01

Benchmark for program dict_snapshot

Open benchmarks
Command Mean [ms] Min [ms] Max [ms] Relative
Cairo-vm (Rust, Cairo 1) 521.5 ± 10.3 511.0 547.3 1.00
cairo-native (embedded AOT) 2144.2 ± 16.7 2126.7 2184.8 4.11 ± 0.09
cairo-native (embedded JIT using LLVM's ORC Engine) 2246.0 ± 10.2 2231.5 2262.3 4.31 ± 0.09

Benchmark for program factorial_2M

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 4.789 ± 0.008 4.777 4.799 1.86 ± 0.02
cairo-native (embedded AOT) 2.577 ± 0.025 2.546 2.629 1.00
cairo-native (embedded JIT using LLVM's ORC Engine) 2.667 ± 0.096 2.596 2.824 1.03 ± 0.04

Benchmark for program fib_2M

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 4.741 ± 0.015 4.716 4.765 2.26 ± 0.01
cairo-native (embedded AOT) 2.094 ± 0.011 2.079 2.106 1.00
cairo-native (embedded JIT using LLVM's ORC Engine) 2.141 ± 0.012 2.119 2.160 1.02 ± 0.01

Benchmark for program linear_search

Open benchmarks
Command Mean [ms] Min [ms] Max [ms] Relative
Cairo-vm (Rust, Cairo 1) 563.0 ± 6.8 552.8 573.7 1.00
cairo-native (embedded AOT) 2181.4 ± 14.3 2150.1 2208.3 3.87 ± 0.05
cairo-native (embedded JIT using LLVM's ORC Engine) 2312.3 ± 10.2 2301.3 2332.0 4.11 ± 0.05

Benchmark for program logistic_map

Open benchmarks
Command Mean [ms] Min [ms] Max [ms] Relative
Cairo-vm (Rust, Cairo 1) 375.5 ± 5.8 367.1 387.1 1.00
cairo-native (embedded AOT) 2262.6 ± 24.8 2239.3 2321.3 6.03 ± 0.11
cairo-native (embedded JIT using LLVM's ORC Engine) 2424.8 ± 11.5 2402.3 2439.9 6.46 ± 0.10

Copy link
Contributor

@JulianGCalderon JulianGCalderon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants