You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for { leti:u32 :=0 } lt(i, 10) { i :=add(i, 1)}
{
c :=add(a,b)
a :=bb :=c
}
Should be transpiled down to a statement which utilizes the Miden Assembly instruction
repeat.{}
Rather than the current while based implementation of for loops
Testcases
Input Yul
for { let i:u32 := 0 } lt(i, 10) { i := add(i, 1)}
{
c := add(a,b)
a := b
b := c
}
Assembly Output
use.std::math::u256
begin
# Assigning to a #
# u32 literal 10 #
push.10
# Assigning to b #
# u32 literal 5 #
push.5
# Assigning to c #
# u32 literal 0 #
push.0
repeat.10
# -- interior block -- #
# Assigning to c #
# add() #
# pushing a to the top #
dup.3
# pushing b to the top #
dup.3
add
# Assigning to a #
# pushing b to the top #
dup.3
# Assigning to b #
# pushing c to the top #
dup.1
end
end
Input Yul
{
let a:u32 := 10
let b:u32 := 5
let c:u32 := 0
for { let i:u32 := 10 } gt(i, 0) { i := sub(i, 5)}
{
let c := add(a,b)
let a := b
let b := c
}
}
Assembly Output
use.std::math::u256
begin
# Assigning to a #
# u32 literal 10 #
push.10
# Assigning to b #
# u32 literal 5 #
push.5
# Assigning to c #
# u32 literal 0 #
push.0
repeat.2
# -- interior block -- #
# Assigning to c #
# add() #
# pushing a to the top #
dup.3
# pushing b to the top #
dup.3
add
# Assigning to a #
# pushing b to the top #
dup.3
# Assigning to b #
# pushing c to the top #
dup.1
end
end
Input Yul
{
let a:u32 := 10
let b:u32 := 5
let c:u32 := 0
for { let i:u32 := 10 } lt(i, 0) { i := sub(i, 5)}
{
let c := add(a,b)
let a := b
let b := c
}
}
Activity
ControlCplusControlV commentedon Dec 17, 2022
For Loop to Repeat Statement
Given a loop statement like
Should be transpiled down to a statement which utilizes the Miden Assembly instruction
Rather than the current
whilebased implementation of for loopsTestcases