/* m4 loop.c -- an ordinary -O2 loop test. The driver wrapper disables * IndVarSimplify's exit-value replacement (-replexitval=never): this target has * no i64, and the closed form of sumto turns into an i33 multiply that llc * cannot select. The loops themselves must survive and run. * * Markers (0x20 bits apart, written by loop_test): * 018A8100 sumto(10) == 55 * 018A8120 squares(5) == 30 */ #define MARK(n) (*(volatile unsigned int *)(0x018A8000u + (n)*0x20u)) int sumto(int n) { int s = 0, i; for (i = 1; i <= n; i++) s += i; return s; } int squares(int n) { int s = 0, i; for (i = 0; i < n; i++) s += i * i; return s; } int loop_test(void) { MARK(8) = (unsigned)sumto(10); MARK(9) = (unsigned)squares(5); return 0; }