65816-llvm-mos/benchmarks/globalArrSum.c
2026-05-18 14:43:35 -05:00

10 lines
390 B
C

// Sum the first n elements of a global i16 array. Exercises the
// `arr[i]` indexed-access pattern that the W65816UnLSR pass converts
// back to `lda <global>, X` after LSR turns it into pointer-walking.
unsigned short globalArr[100];
unsigned short globalArrSum(unsigned short n) {
unsigned short s = 0;
for (unsigned short i = 0; i < n; i++) s += globalArr[i];
return s;
}