aboutsummaryrefslogtreecommitdiff
path: root/tests/performance/17_loop_unroll2.sy
diff options
context:
space:
mode:
authorRichard Qin <richard.qin.001@gmail.com>2026-09-15 08:16:43 +0800
committerRichard Qin <richard.qin.001@gmail.com>2026-09-15 08:16:43 +0800
commit4022e5c95210631e4aceb08eaf9d9071aa5aefc4 (patch)
treea5922559836e45fb3459a3d070367912e1035b1a /tests/performance/17_loop_unroll2.sy
downloadrcc-master.tar.gz
rcc-master.tar.xz
Set up a git repoHEADmaster
Diffstat (limited to 'tests/performance/17_loop_unroll2.sy')
-rw-r--r--tests/performance/17_loop_unroll2.sy124
1 files changed, 124 insertions, 0 deletions
diff --git a/tests/performance/17_loop_unroll2.sy b/tests/performance/17_loop_unroll2.sy
new file mode 100644
index 0000000..9720a97
--- /dev/null
+++ b/tests/performance/17_loop_unroll2.sy
@@ -0,0 +1,124 @@
+void f1(int x[]) {
+ int a[3] = {};
+ int i = x[0];
+ while (i < x[1]) {
+ a[i] = a[i] + 2 * i; i = i + 1;
+ }
+ i = x[0];
+ while (i < x[1]) {
+ a[i] = a[i] - i; i = i + 1;
+ }
+ putarray(3, a);
+}
+
+void f2(int x[]) {
+ int a[3] = {};
+ int i = x[0];
+ while (i <= x[1] - 1) {
+ a[i] = a[i] + 2 * i; i = i + 1;
+ }
+ i = x[0];
+ while (i <= x[1] - 1) {
+ a[i] = a[i] - i; i = i + 1;
+ }
+ putarray(3, a);
+}
+
+void f3(int x[]) {
+ int a[3] = {};
+ int i = x[0];
+ while (x[1] > i) {
+ a[i] = a[i] + 2 * i; i = i + 1;
+ }
+ i = x[0];
+ while (x[1] > i) {
+ a[i] = a[i] - i; i = i + 1;
+ }
+ putarray(3, a);
+}
+
+void f4(int x[]) {
+ int a[3] = {};
+ int i = x[0];
+ while (x[1] - 1 >= i) {
+ a[i] = a[i] + 2 * i; i = i + 1;
+ }
+ i = x[0];
+ while (x[1] - 1 >= i) {
+ a[i] = a[i] - i; i = i + 1;
+ }
+ putarray(3, a);
+}
+
+void f5(int x[]) {
+ int a[3] = {};
+ int i = x[1] - 1;
+ while (i >= x[0]) {
+ a[i] = a[i] + 2 * i; i = i - 1;
+ }
+ i = x[1] - 1;
+ while (i >= x[0]) {
+ a[i] = a[i] - i; i = i - 1;
+ }
+ putarray(3, a);
+}
+
+void f6(int x[]) {
+ int a[3] = {};
+ int i = x[1] - 1;
+ while (i > x[0] - 1) {
+ a[i] = a[i] + 2 * i; i = i - 1;
+ }
+ i = x[1] - 1;
+ while (i > x[0] - 1) {
+ a[i] = a[i] - i; i = i - 1;
+ }
+ putarray(3, a);
+}
+
+void f7(int x[]) {
+ int a[3] = {};
+ int i = x[1] - 1;
+ while (x[0] <= i) {
+ a[i] = a[i] + 2 * i; i = i - 1;
+ }
+ i = x[1] - 1;
+ while (x[0] <= i) {
+ a[i] = a[i] - i; i = i - 1;
+ }
+ putarray(3, a);
+}
+
+void f8(int x[]) {
+ int a[3] = {};
+ int i = x[1] - 1;
+ while (x[0] - 1 < i) {
+ a[i] = a[i] + 2 * i; i = i - 1;
+ }
+ i = x[1] - 1;
+ while (x[0] - 1 < i) {
+ a[i] = a[i] - i; i = i - 1;
+ }
+ putarray(3, a);
+}
+
+int main() {
+ int x[2];
+ x[0] = 0;
+ while (x[0] <= 3) {
+ x[1] = x[0];
+ while (x[1] <= 3) {
+ f1(x);
+ f2(x);
+ f3(x);
+ f4(x);
+ f5(x);
+ f6(x);
+ f7(x);
+ f8(x);
+ x[1] = x[1] + 1;
+ }
+ x[0] = x[0] + 1;
+ }
+ return 0;
+} \ No newline at end of file