Skip to content

Commit

Permalink
Armv7m: Add vmov cmp loop example
Browse files Browse the repository at this point in the history
  • Loading branch information
dop-amin committed Dec 2, 2024
1 parent 00b2a6f commit 528321c
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 19 deletions.
18 changes: 18 additions & 0 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,23 @@ def core(self,slothy):
slothy.config.variable_size=True
slothy.config.outputs = ["r6"]
slothy.optimize_loop("start")

class Armv7mLoopVmovCmp(Example):
def __init__(self, var="", arch=Arch_Armv7M, target=Target_CortexM7):
name = "loop_vmov_cmp"
infile = name

if var != "":
name += f"_{var}"
infile += f"_{var}"
name += f"_{target_label_dict[target]}"

super().__init__(infile, name, rename=True, arch=arch, target=target)

def core(self,slothy):
slothy.config.variable_size=True
slothy.config.outputs = ["r6"]
slothy.optimize_loop("start")

class ntt_kyber_123_4567(Example):
def __init__(self, var="", arch=AArch64_Neon, target=Target_CortexA55, timeout=None):
Expand Down Expand Up @@ -1486,6 +1503,7 @@ def main():
LoopLe(),
Armv7mLoopSubs(),
Armv7mLoopCmp(),
Armv7mLoopVmovCmp(),

CRT(),

Expand Down
38 changes: 19 additions & 19 deletions examples/opt/armv7m/armv7m_simple0_opt_m7.s
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@

start:
// Instructions: 6
// Expected cycles: 5
// Expected IPC: 1.20
//
// Cycle bound: 5.0
// IPC bound: 1.20
//
// Wall time: 0.01s
// User time: 0.01s
//
// ----- cycle (expected) ------>
// 0 25
// |------------------------|----
ldr r7, [r0, #4] // *.............................
add r7, r2, r7 // .*............................
eor.w r12, r7, r3 // ..*...........................
smlabt r12, r2, r2, r12 // ..*...........................
asrs r3, r12, #1 // ....*.........................
str r3, [r0, #4] // ....*.........................
// Instructions: 6
// Expected cycles: 5
// Expected IPC: 1.20
//
// Cycle bound: 5.0
// IPC bound: 1.20
//
// Wall time: 0.02s
// User time: 0.02s
//
// ----- cycle (expected) ------>
// 0 25
// |------------------------|----
ldr r6, [r0, #4] // *.............................
add r6, r2, r6 // .*............................
eor.w r3, r6, r3 // ..*...........................
smlabt r12, r2, r2, r3 // ..*...........................
asrs r3, r12, #1 // ....*.........................
str r3, [r0, #4] // ....*.........................

// ------ cycle (expected) ------>
// 0 25
Expand Down
31 changes: 31 additions & 0 deletions examples/opt/armv7m/loop_vmov_cmp_opt_m7.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* For example, r5 represents an address where we will stop iterating and r6 is
the actual pointer which is incremented inside the loop. */

mov.w r6, #0
add.w r5, r6, #64
vmov s0, r5

start:
// Instructions: 1
// Expected cycles: 1
// Expected IPC: 1.00
//
// Cycle bound: 1.0
// IPC bound: 1.00
//
// Wall time: 0.02s
// User time: 0.02s
//
// ----- cycle (expected) ------>
// 0 25
// |------------------------|----
add r6, r6, #4 // *.............................

// ------ cycle (expected) ------>
// 0 25
// |------------------------|-----
// add r6, r6, #4 // *..............................

vmov r5, s0
cmp r6, r5
bne start

0 comments on commit 528321c

Please sign in to comment.