Skip to content

Commit

Permalink
added unused test4 assembly for loopoverhead
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantJiang committed Mar 12, 2021
1 parent ddebcaf commit a89dc95
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions c/loopoverhead/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ int main(void){

printf("Test 4: Always taken\n");
for(int i = 0; i < 32; i++){
/*
//li, mv, j
//lw, beqz taken, addi, beqz not taken
volatile int temp = 0;
Expand All @@ -94,8 +95,32 @@ int main(void){
printf("Not supposed to be not taken\n");
}
}
*/

#ifdef __arm__
printf("Arm: test4 not done\n");
break;
#else
int counter=3, temp=11;
start = perf_cycles();
asm ("#test 4 asm start");
asm volatile("\
li %0,12\n\
li %1,1000\n\
startloop:\n\
bnez %0,skipped#skip addi-12\n\
addi %0,%0,-12\n\
skipped:\n\
addi %1,%1,-1\n\
bnez %1,startloop#back to bnez %0\
"
: "=r"(temp), "=r" (counter)
);
asm ("#test 4 asm end");
end = perf_cycles();
//printf("check%d,%d\n", counter, temp);
printf("\t%d,\t%d\n", i, end - start);
#endif
}

return 0;
Expand Down

0 comments on commit a89dc95

Please sign in to comment.