From 022e07426ccaf33403b789ab3940e4307734dd56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E9=BE=99=E6=88=90?= Date: Wed, 3 Dec 2025 21:22:24 +0800 Subject: [PATCH] add testcases --- tests/4-opt/.gitignore | 5 +- tests/4-opt/cleanup.sh | 2 - tests/4-opt/eval_lab4.sh | 127 --- tests/4-opt/test_perf.sh | 107 --- tests/4-opt/testcases/0_lab2_lv0_1.cminus | 11 + tests/4-opt/testcases/0_lab2_lv0_1.in | 1 + tests/4-opt/testcases/0_lab2_lv0_1.out | 3 + tests/4-opt/testcases/1_lab2_lv0_2.cminus | 75 ++ tests/4-opt/testcases/1_lab2_lv0_2.out | 72 ++ tests/4-opt/testcases/2_lab2_lv1.cminus | 100 +++ tests/4-opt/testcases/2_lab2_lv1.in | 1 + tests/4-opt/testcases/2_lab2_lv1.out | 46 + tests/4-opt/testcases/2_lab2_lv2.cminus | 116 +++ tests/4-opt/testcases/2_lab2_lv2.out | 17 + tests/4-opt/testcases/3_complex1.cminus | 77 ++ tests/4-opt/testcases/3_complex1.out | 801 ++++++++++++++++++ tests/4-opt/testcases/4_complex2.cminus | 59 ++ tests/4-opt/testcases/4_complex2.in | 10 + .../5-while.out => 4_complex2.out} | 0 tests/4-opt/testcases/5_complex3.cminus | 25 + tests/4-opt/testcases/5_complex3.in | 2 + tests/4-opt/testcases/5_complex3.out | 2 + tests/4-opt/testcases/6_complex4.cminus | 122 +++ tests/4-opt/testcases/6_complex4.out | 4 + tests/4-opt/testcases/7_return_early.cminus | 44 + tests/4-opt/testcases/7_return_early.in | 1 + tests/4-opt/testcases/7_return_early.out | 1 + tests/4-opt/testcases/8_licm0.cminus | 104 +++ tests/4-opt/testcases/8_licm0.in | 4 + tests/4-opt/testcases/8_licm0.out | 45 + tests/4-opt/testcases/9_licm_bad.cminus | 27 + .../{loop/loop-1.out => 9_licm_bad.out} | 2 +- .../testcases/functional-cases/0-io.cminus | 4 - .../4-opt/testcases/functional-cases/0-io.in | 1 - .../4-opt/testcases/functional-cases/0-io.out | 2 - .../functional-cases/1-return.cminus | 4 - .../testcases/functional-cases/1-return.out | 2 - .../functional-cases/10-float.cminus | 19 - .../testcases/functional-cases/10-float.out | 2 - .../functional-cases/11-floatcall.cminus | 18 - .../functional-cases/11-floatcall.out | 2 - .../functional-cases/12-global.cminus | 47 - .../testcases/functional-cases/12-global.out | 21 - .../functional-cases/13-complex.cminus | 67 -- .../testcases/functional-cases/13-complex.out | 2 - .../functional-cases/2-calculate.cminus | 11 - .../functional-cases/2-calculate.out | 1 - .../functional-cases/3-output.cminus | 5 - .../testcases/functional-cases/3-output.out | 3 - .../testcases/functional-cases/4-if.cminus | 23 - .../4-opt/testcases/functional-cases/4-if.out | 2 - .../testcases/functional-cases/5-while.cminus | 14 - .../testcases/functional-cases/6-array.cminus | 15 - .../testcases/functional-cases/6-array.out | 4 - .../functional-cases/7-function.cminus | 21 - .../testcases/functional-cases/7-function.out | 4 - .../testcases/functional-cases/8-store.cminus | 26 - .../testcases/functional-cases/8-store.out | 2 - .../functional-cases/9-fibonacci.cminus | 23 - .../functional-cases/9-fibonacci.out | 11 - tests/4-opt/testcases/loop/baseline/loop-1.ll | 60 -- tests/4-opt/testcases/loop/baseline/loop-2.ll | 60 -- tests/4-opt/testcases/loop/baseline/loop-3.ll | 119 --- tests/4-opt/testcases/loop/baseline/loop-4.ll | 132 --- tests/4-opt/testcases/loop/loop-1.cminus | 20 - tests/4-opt/testcases/loop/loop-2.cminus | 23 - tests/4-opt/testcases/loop/loop-2.out | 2 - tests/4-opt/testcases/loop/loop-3.cminus | 46 - tests/4-opt/testcases/loop/loop-3.out | 2 - tests/4-opt/testcases/loop/loop-4.cminus | 50 -- tests/4-opt/testcases/loop/loop-4.out | 2 - .../testcases/mem2reg/baseline/mem2reg-1 | Bin 34168 -> 0 bytes .../testcases/mem2reg/baseline/mem2reg-1.ll | 54 -- .../testcases/mem2reg/baseline/mem2reg-2 | Bin 16840 -> 0 bytes .../testcases/mem2reg/baseline/mem2reg-2.ll | 26 - .../testcases/mem2reg/baseline/mem2reg-3 | Bin 34360 -> 0 bytes .../testcases/mem2reg/baseline/mem2reg-3.ll | 201 ----- tests/4-opt/testcases/mem2reg/mem2reg-1 | Bin 34168 -> 0 bytes .../4-opt/testcases/mem2reg/mem2reg-1.cminus | 23 - tests/4-opt/testcases/mem2reg/mem2reg-1.in | 1 - tests/4-opt/testcases/mem2reg/mem2reg-1.out | 2 - tests/4-opt/testcases/mem2reg/mem2reg-2 | Bin 16840 -> 0 bytes .../4-opt/testcases/mem2reg/mem2reg-2.cminus | 9 - tests/4-opt/testcases/mem2reg/mem2reg-2.out | 1 - tests/4-opt/testcases/mem2reg/mem2reg-3 | Bin 34360 -> 0 bytes .../4-opt/testcases/mem2reg/mem2reg-3.cminus | 70 -- tests/4-opt/testcases/mem2reg/mem2reg-3.in | 32 - tests/4-opt/testcases/mem2reg/mem2reg-3.out | 2 - 88 files changed, 1775 insertions(+), 1531 deletions(-) delete mode 100755 tests/4-opt/cleanup.sh delete mode 100755 tests/4-opt/eval_lab4.sh delete mode 100755 tests/4-opt/test_perf.sh create mode 100644 tests/4-opt/testcases/0_lab2_lv0_1.cminus create mode 100644 tests/4-opt/testcases/0_lab2_lv0_1.in create mode 100644 tests/4-opt/testcases/0_lab2_lv0_1.out create mode 100644 tests/4-opt/testcases/1_lab2_lv0_2.cminus create mode 100644 tests/4-opt/testcases/1_lab2_lv0_2.out create mode 100644 tests/4-opt/testcases/2_lab2_lv1.cminus create mode 100644 tests/4-opt/testcases/2_lab2_lv1.in create mode 100644 tests/4-opt/testcases/2_lab2_lv1.out create mode 100644 tests/4-opt/testcases/2_lab2_lv2.cminus create mode 100644 tests/4-opt/testcases/2_lab2_lv2.out create mode 100644 tests/4-opt/testcases/3_complex1.cminus create mode 100644 tests/4-opt/testcases/3_complex1.out create mode 100755 tests/4-opt/testcases/4_complex2.cminus create mode 100755 tests/4-opt/testcases/4_complex2.in rename tests/4-opt/testcases/{functional-cases/5-while.out => 4_complex2.out} (100%) mode change 100644 => 100755 create mode 100755 tests/4-opt/testcases/5_complex3.cminus create mode 100755 tests/4-opt/testcases/5_complex3.in create mode 100755 tests/4-opt/testcases/5_complex3.out create mode 100755 tests/4-opt/testcases/6_complex4.cminus create mode 100755 tests/4-opt/testcases/6_complex4.out create mode 100644 tests/4-opt/testcases/7_return_early.cminus create mode 100644 tests/4-opt/testcases/7_return_early.in create mode 100644 tests/4-opt/testcases/7_return_early.out create mode 100644 tests/4-opt/testcases/8_licm0.cminus create mode 100644 tests/4-opt/testcases/8_licm0.in create mode 100644 tests/4-opt/testcases/8_licm0.out create mode 100644 tests/4-opt/testcases/9_licm_bad.cminus rename tests/4-opt/testcases/{loop/loop-1.out => 9_licm_bad.out} (50%) delete mode 100644 tests/4-opt/testcases/functional-cases/0-io.cminus delete mode 100644 tests/4-opt/testcases/functional-cases/0-io.in delete mode 100644 tests/4-opt/testcases/functional-cases/0-io.out delete mode 100644 tests/4-opt/testcases/functional-cases/1-return.cminus delete mode 100644 tests/4-opt/testcases/functional-cases/1-return.out delete mode 100644 tests/4-opt/testcases/functional-cases/10-float.cminus delete mode 100644 tests/4-opt/testcases/functional-cases/10-float.out delete mode 100644 tests/4-opt/testcases/functional-cases/11-floatcall.cminus delete mode 100644 tests/4-opt/testcases/functional-cases/11-floatcall.out delete mode 100644 tests/4-opt/testcases/functional-cases/12-global.cminus delete mode 100644 tests/4-opt/testcases/functional-cases/12-global.out delete mode 100644 tests/4-opt/testcases/functional-cases/13-complex.cminus delete mode 100644 tests/4-opt/testcases/functional-cases/13-complex.out delete mode 100644 tests/4-opt/testcases/functional-cases/2-calculate.cminus delete mode 100644 tests/4-opt/testcases/functional-cases/2-calculate.out delete mode 100644 tests/4-opt/testcases/functional-cases/3-output.cminus delete mode 100644 tests/4-opt/testcases/functional-cases/3-output.out delete mode 100644 tests/4-opt/testcases/functional-cases/4-if.cminus delete mode 100644 tests/4-opt/testcases/functional-cases/4-if.out delete mode 100644 tests/4-opt/testcases/functional-cases/5-while.cminus delete mode 100644 tests/4-opt/testcases/functional-cases/6-array.cminus delete mode 100644 tests/4-opt/testcases/functional-cases/6-array.out delete mode 100644 tests/4-opt/testcases/functional-cases/7-function.cminus delete mode 100644 tests/4-opt/testcases/functional-cases/7-function.out delete mode 100644 tests/4-opt/testcases/functional-cases/8-store.cminus delete mode 100644 tests/4-opt/testcases/functional-cases/8-store.out delete mode 100644 tests/4-opt/testcases/functional-cases/9-fibonacci.cminus delete mode 100644 tests/4-opt/testcases/functional-cases/9-fibonacci.out delete mode 100644 tests/4-opt/testcases/loop/baseline/loop-1.ll delete mode 100644 tests/4-opt/testcases/loop/baseline/loop-2.ll delete mode 100644 tests/4-opt/testcases/loop/baseline/loop-3.ll delete mode 100644 tests/4-opt/testcases/loop/baseline/loop-4.ll delete mode 100644 tests/4-opt/testcases/loop/loop-1.cminus delete mode 100644 tests/4-opt/testcases/loop/loop-2.cminus delete mode 100644 tests/4-opt/testcases/loop/loop-2.out delete mode 100644 tests/4-opt/testcases/loop/loop-3.cminus delete mode 100644 tests/4-opt/testcases/loop/loop-3.out delete mode 100644 tests/4-opt/testcases/loop/loop-4.cminus delete mode 100644 tests/4-opt/testcases/loop/loop-4.out delete mode 100755 tests/4-opt/testcases/mem2reg/baseline/mem2reg-1 delete mode 100644 tests/4-opt/testcases/mem2reg/baseline/mem2reg-1.ll delete mode 100755 tests/4-opt/testcases/mem2reg/baseline/mem2reg-2 delete mode 100644 tests/4-opt/testcases/mem2reg/baseline/mem2reg-2.ll delete mode 100755 tests/4-opt/testcases/mem2reg/baseline/mem2reg-3 delete mode 100644 tests/4-opt/testcases/mem2reg/baseline/mem2reg-3.ll delete mode 100755 tests/4-opt/testcases/mem2reg/mem2reg-1 delete mode 100644 tests/4-opt/testcases/mem2reg/mem2reg-1.cminus delete mode 100644 tests/4-opt/testcases/mem2reg/mem2reg-1.in delete mode 100644 tests/4-opt/testcases/mem2reg/mem2reg-1.out delete mode 100755 tests/4-opt/testcases/mem2reg/mem2reg-2 delete mode 100644 tests/4-opt/testcases/mem2reg/mem2reg-2.cminus delete mode 100644 tests/4-opt/testcases/mem2reg/mem2reg-2.out delete mode 100755 tests/4-opt/testcases/mem2reg/mem2reg-3 delete mode 100644 tests/4-opt/testcases/mem2reg/mem2reg-3.cminus delete mode 100644 tests/4-opt/testcases/mem2reg/mem2reg-3.in delete mode 100644 tests/4-opt/testcases/mem2reg/mem2reg-3.out diff --git a/tests/4-opt/.gitignore b/tests/4-opt/.gitignore index acedccc..7f2a8f5 100755 --- a/tests/4-opt/.gitignore +++ b/tests/4-opt/.gitignore @@ -1,2 +1,5 @@ output -log.txt \ No newline at end of file +raw_log.txt +licm_log.txt +all_log.txt +mem2reg_log.txt \ No newline at end of file diff --git a/tests/4-opt/cleanup.sh b/tests/4-opt/cleanup.sh deleted file mode 100755 index 78fecdf..0000000 --- a/tests/4-opt/cleanup.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -rm -rf output log.txt diff --git a/tests/4-opt/eval_lab4.sh b/tests/4-opt/eval_lab4.sh deleted file mode 100755 index d9a314a..0000000 --- a/tests/4-opt/eval_lab4.sh +++ /dev/null @@ -1,127 +0,0 @@ -#!/bin/bash - -project_dir=$(realpath ../../) -io_dir=$(realpath "$project_dir"/src/io) -output_dir=output -suffix=cminus - -LOG=log.txt - -usage() { - cat </dev/null - -mkdir -p $output_dir - -truncate -s 0 $LOG - -if [ $debug_mode = false ]; then - exec 3>/dev/null 4>&1 5>&2 1>&3 2>&3 -else - exec 3>&1 -fi - -if [ $debug_mode = false ]; then - exec 1>&4 2>&5 -fi - -echo "[info] Start testing, using testcase dir: $test_dir" -# asm -for case in $testcases; do - echo "==========$case==========" >>$LOG - case_base_name=$(basename -s .$suffix "$case") - std_out_file=$test_dir/$case_base_name.out - in_file=$test_dir/$case_base_name.in - asm_file=$output_dir/$case_base_name.s - exe_file=$output_dir/$case_base_name - out_file=$output_dir/$case_base_name.out - ll_file=$output_dir/$case_base_name.ll - - echo -n "$case_base_name..." - # if debug mode on, generate .ll also - if [ $debug_mode = true ]; then - bash -c "cminusfc $flag -emit-llvm $case -o $ll_file" >>$LOG 2>&1 - fi - # cminusfc compile to .s - bash -c "cminusfc -S $flag $case -o $asm_file" >>$LOG 2>&1 - check_return_value $? 0 "CE" "cminusfc compiler error" || continue - - # gcc compile asm to executable - - if [ $debug_mode = true ]; then - loongarch64-unknown-linux-gnu-gcc -g -static \ - "$asm_file" "$io_dir"/io.c -o "$exe_file" \ - >>$LOG - else - loongarch64-unknown-linux-gnu-gcc -static \ - "$asm_file" "$io_dir"/io.c -o "$exe_file" \ - >>$LOG - fi - check_return_value $? 0 "CE" "gcc compiler error" || continue - - # qemu run - if [ -e "$in_file" ]; then - exec_cmd="qemu-loongarch64 $exe_file >$out_file <$in_file" - else - exec_cmd="qemu-loongarch64 $exe_file >$out_file" - fi - bash -c "$exec_cmd" - ret=$? - # remove trailing null byte in the end line - sed -i "\$s/\x00*$//" "$out_file" - # append return value - echo $ret >>"$out_file" - - # compare output - diff --strip-trailing-cr "$std_out_file" "$out_file" -y >>$LOG - check_return_value $? 0 "WA" "output differ, check $std_out_file and $out_file" || continue - - # ok - printf "\033[1;32mOK\033[0m\n" -done diff --git a/tests/4-opt/test_perf.sh b/tests/4-opt/test_perf.sh deleted file mode 100755 index bcd3213..0000000 --- a/tests/4-opt/test_perf.sh +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/bash - -project_dir=$(realpath ../../) -io_dir=$(realpath "$project_dir"/src/io) -output_dir=output -suffix=cminus -flag="" -LOG=log.txt - -check_return_value() { - rv=$1 - expected_rv=$2 - fail_msg=$3 - detail=$4 - if [ "$rv" -eq "$expected_rv" ]; then - return 0 - else - printf "\033[1;31m%s: \033[0m%s\n" "$fail_msg" "$detail" - return 1 - fi -} - -usage() { - cat </dev/null - -mkdir -p $output_dir - -truncate -s 0 $LOG - -echo "[info] Start testing, using testcase dir: $test_dir" -# asm -for case in $testcases; do - echo "==========$case==========" >>$LOG - case_base_name=$(basename -s .$suffix "$case") - in_file=$test_dir/$case_base_name.in - asm_mem2reg_on=$output_dir/${case_base_name}-$1-on.s - asm_mem2reg_off=$output_dir/${case_base_name}-$1-off.s - exe_mem2reg_on=$output_dir/${case_base_name}-$1-on - exe_mem2reg_off=$output_dir/${case_base_name}-$1-off - - echo "==========$case==========" - #### mem2reg off - # cminusfc compile to .s - bash -c "cminusfc -S $nflag $case -o $asm_mem2reg_off" >>$LOG 2>&1 - check_return_value $? 0 "CE" "cminusfc compiler error" || continue - # gcc compile asm to executable - loongarch64-unknown-linux-gnu-gcc -static \ - "$asm_mem2reg_off" "$io_dir"/io.c -o "$exe_mem2reg_off" \ - >>$LOG - check_return_value $? 0 "CE" "gcc compiler error" || continue - - #### mem2reg on - # cminusfc compile to .s - bash -c "cminusfc -S $flag $case -o $asm_mem2reg_on" >>$LOG 2>&1 - check_return_value $? 0 "CE" "cminusfc compiler error" || continue - # gcc compile asm to executable - loongarch64-unknown-linux-gnu-gcc -static \ - "$asm_mem2reg_on" "$io_dir"/io.c -o "$exe_mem2reg_on" \ - >>$LOG - check_return_value $? 0 "CE" "gcc compiler error" || continue - - echo "==========$1 off" - if [ -e "$in_file" ]; then - exec_cmd="qemu-loongarch64 $exe_mem2reg_off >/dev/null <$in_file" - else - exec_cmd="qemu-loongarch64 $exe_mem2reg_off >/dev/null" - fi - time bash -c "$exec_cmd" - echo "==========$1 on" - if [ -e "$in_file" ]; then - exec_cmd="qemu-loongarch64 $exe_mem2reg_on >/dev/null <$in_file" - else - exec_cmd="qemu-loongarch64 $exe_mem2reg_on >/dev/null" - fi - time bash -c "$exec_cmd" - -done diff --git a/tests/4-opt/testcases/0_lab2_lv0_1.cminus b/tests/4-opt/testcases/0_lab2_lv0_1.cminus new file mode 100644 index 0000000..f58f1dd --- /dev/null +++ b/tests/4-opt/testcases/0_lab2_lv0_1.cminus @@ -0,0 +1,11 @@ +void main(void) +{ + float a[10]; + float b; + int c[10]; + int d; + input(); + outputFloat(123.4); + output(1234); + return; +} diff --git a/tests/4-opt/testcases/0_lab2_lv0_1.in b/tests/4-opt/testcases/0_lab2_lv0_1.in new file mode 100644 index 0000000..b8626c4 --- /dev/null +++ b/tests/4-opt/testcases/0_lab2_lv0_1.in @@ -0,0 +1 @@ +4 diff --git a/tests/4-opt/testcases/0_lab2_lv0_1.out b/tests/4-opt/testcases/0_lab2_lv0_1.out new file mode 100644 index 0000000..2cc0e3d --- /dev/null +++ b/tests/4-opt/testcases/0_lab2_lv0_1.out @@ -0,0 +1,3 @@ +123.400002 +1234 +0 diff --git a/tests/4-opt/testcases/1_lab2_lv0_2.cminus b/tests/4-opt/testcases/1_lab2_lv0_2.cminus new file mode 100644 index 0000000..f9e9cce --- /dev/null +++ b/tests/4-opt/testcases/1_lab2_lv0_2.cminus @@ -0,0 +1,75 @@ +void main(void) +{ + output(100.0 + 23.4); + output(1000 + 234); + output(1000 + 23.4); + outputFloat(9 + 1.2 / (2 * 2 + 5 - 6) * 3.2 - 55); + output((1 > 2.) < 3); + output((1 > 2) < ((3 == 4) >= 0)); + output(((3 == 4.) >= 0) <= (4 != 4)); + output(((1 > 2) < ((3 == 4) >= 0)) <= (4. != 4)); + output(24.68 / 2.); + output(2468 / 2); + output(24.68 / 2); + output(1. == 2.); + output(2. == 2.); + output(3. == 2.); + output(1 == 2); + output(2 == 2); + output(3 == 2); + output(1. == 2); + output(2. == 2); + output(3 == 2.); + output(1. >= 2.); + output(2. >= 2.); + output(3. >= 2.); + output(1 >= 2); + output(2 >= 2); + output(3 >= 2); + output(1. >= 2); + output(2. >= 2); + output(3 >= 2.); + output(1. > 2.); + output(2. > 2.); + output(3. > 2.); + output(1 > 2); + output(2 > 2); + output(3 > 2); + output(1. > 2); + output(2. > 2); + output(3 > 2.); + output(1. <= 2.); + output(2. <= 2.); + output(3. <= 2.); + output(1 <= 2); + output(2 <= 2); + output(3 <= 2); + output(1. <= 2); + output(2. <= 2); + output(3 <= 2.); + output(1. < 2.); + output(2. < 2.); + output(3. < 2.); + output(1 < 2); + output(2 < 2); + output(3 < 2); + output(1. < 2); + output(2 < 2.); + output(3. < 2); + output(2. * 61.7); + output(2 * 617); + output(2 * 61.7); + output(1. != 2.); + output(2. != 2.); + output(3. != 2.); + output(1 != 2); + output(2 != 2); + output(3 != 2); + output(1. != 2); + output(2 != 2.); + output(3 != 2.); + output(200.0 - 7.66); + output(2000 - 766); + output(2000 - 76.6); + return; +} diff --git a/tests/4-opt/testcases/1_lab2_lv0_2.out b/tests/4-opt/testcases/1_lab2_lv0_2.out new file mode 100644 index 0000000..f36d324 --- /dev/null +++ b/tests/4-opt/testcases/1_lab2_lv0_2.out @@ -0,0 +1,72 @@ +123 +1234 +1023 +-44.720001 +1 +1 +0 +0 +12 +1234 +12 +0 +1 +0 +0 +1 +0 +0 +1 +0 +0 +1 +1 +0 +1 +1 +0 +1 +1 +0 +0 +1 +0 +0 +1 +0 +0 +1 +1 +1 +0 +1 +1 +0 +1 +1 +0 +1 +0 +0 +1 +0 +0 +1 +0 +0 +123 +1234 +123 +1 +0 +1 +1 +0 +1 +1 +0 +1 +192 +1234 +1923 +0 diff --git a/tests/4-opt/testcases/2_lab2_lv1.cminus b/tests/4-opt/testcases/2_lab2_lv1.cminus new file mode 100644 index 0000000..dcfb5c9 --- /dev/null +++ b/tests/4-opt/testcases/2_lab2_lv1.cminus @@ -0,0 +1,100 @@ +float d[10]; +float e; +int f[10]; +int g; + +void main(void) +{ + int a; + int b; + int c; + float h[10]; + float i; + int j[10]; + int k; + int l[10]; + int m; + int n; + int o; + int p; + int q; + int r; + float s; + a = 1 < 3; + b = 2 == 4; + c = 3 > 5; + output(a); + output(b); + output(c); + d[3] = 1234.0; + outputFloat(d[3]); + h[3] = 1234.0; + outputFloat(h[3]); + e = 1234.0; + outputFloat(e); + i = 1234.0; + outputFloat(i); + f[3] = 1234; + output(f[3]); + j[3] = 1234; + output(j[3]); + g = 1234; + output(g); + k = 1234; + output(k); + l[0] = 1024; + output(l[0.1]); + m = input(); + output(m); + n = 10; + while (n) + { + output(n); + n = n - 1; + } + o = 10; + while (o > 0) + { + output(o); + o = o - 1; + } + p = 3; + output(p); + { + int p; + p = 11; + output(p); + } + output(p); + q = 2; + if (q) + output(42); + output(24); + if (2 > 1) + output(42); + output(24); + if (1 > 2) + { + output(1234); + } + if (2 > 1) + { + output(42); + } + else + output(1234); + + output(24); + + if (2 < 1) + output(42); + else + { + output(1234); + } + r = 1.0; + output(r); + s = 1; + outputFloat(s); + return; +} diff --git a/tests/4-opt/testcases/2_lab2_lv1.in b/tests/4-opt/testcases/2_lab2_lv1.in new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/tests/4-opt/testcases/2_lab2_lv1.in @@ -0,0 +1 @@ +9 diff --git a/tests/4-opt/testcases/2_lab2_lv1.out b/tests/4-opt/testcases/2_lab2_lv1.out new file mode 100644 index 0000000..a530fa2 --- /dev/null +++ b/tests/4-opt/testcases/2_lab2_lv1.out @@ -0,0 +1,46 @@ +1 +0 +0 +1234.000000 +1234.000000 +1234.000000 +1234.000000 +1234 +1234 +1234 +1234 +1024 +9 +10 +9 +8 +7 +6 +5 +4 +3 +2 +1 +10 +9 +8 +7 +6 +5 +4 +3 +2 +1 +3 +11 +3 +42 +24 +42 +24 +42 +24 +1234 +1 +1.000000 +0 diff --git a/tests/4-opt/testcases/2_lab2_lv2.cminus b/tests/4-opt/testcases/2_lab2_lv2.cminus new file mode 100644 index 0000000..a96a568 --- /dev/null +++ b/tests/4-opt/testcases/2_lab2_lv2.cminus @@ -0,0 +1,116 @@ +void p(int o[]) +{ + output(o[3]); + return; +} + +void q(int c[]) +{ + output(c[3]); + p(c); + return; +} + +int addone(int a) { return a + 1; } + +void r(float a[]) +{ + output(a[3]); + return; +} + +void s(int a[]) +{ + output(a[3]); + return; +} + +void t(int a) +{ + output(a); + return; +} + +void u(float a) +{ + outputFloat(a); + return; +} + +int v(void) +{ + int i; + if (1) + { + i = 1; + return 0; + } + else + { + i = 2; + } + output(3); + return 3; +} + +int w(void) +{ + int i; + i = 10; + while (i > 0) + { + return 0; + } + output(4); + return 1; +} + +int x(void) { return 233.3; } + +float y(void) { return 7; } + +void main(void) +{ + int a; + int c; + int d; + int e; + int f[10]; + int g; + float h[10]; + int i[10]; + float j; + int l; + int m; + a = 0; + while (a < 65536) + { + int o[32]; + o[0] = a; + a = a + 1; + } + output(0); + c = d = e = 3; + output(c); + output(d); + output(e); + f[3] = 1024; + q(f); + g = addone(addone(addone(addone(1230)))); + output(g); + h[3] = 3.14; + r(h); + i[3] = 10; + s(i); + j = 10; + t(j); + l = 4.5; + u(l); + m = 10; + t(m); + output(v()); + output(w()); + output(x()); + outputFloat(y()); + return; +} diff --git a/tests/4-opt/testcases/2_lab2_lv2.out b/tests/4-opt/testcases/2_lab2_lv2.out new file mode 100644 index 0000000..ebe26c8 --- /dev/null +++ b/tests/4-opt/testcases/2_lab2_lv2.out @@ -0,0 +1,17 @@ +0 +3 +3 +3 +1024 +1024 +1234 +3 +10 +10 +4.000000 +10 +0 +0 +233 +7.000000 +0 diff --git a/tests/4-opt/testcases/3_complex1.cminus b/tests/4-opt/testcases/3_complex1.cminus new file mode 100644 index 0000000..9688277 --- /dev/null +++ b/tests/4-opt/testcases/3_complex1.cminus @@ -0,0 +1,77 @@ +/* + This code is adapted from Dik T. Winter at CWI + It computes pi to 800 decimal digits + */ + +int mod(int a, int b) { return a - a / b * b; } + +void printfour(int input) +{ + int a; + int b; + int c; + int d; + input = mod(input, 10000); + d = mod(input, 10); + input = input / 10; + c = mod(input, 10); + input = input / 10; + b = mod(input, 10); + input = input / 10; + a = input; + output(a); + output(b); + output(c); + output(d); + return; +} + +void main(void) +{ + int r[2801]; + int i; + int k; + int b; + int d; + int c; + c = 0; + d = 1234; + + { + int mod; + mod = 0; + while (mod < 2800) + { + r[mod] = 2000; + mod = mod + 1; + } + } + + k = 2800; + while (k) + { + int d; + d = 0; + i = k; + + while (i != 0) + { + d = d + r[i] * 10000; + b = 2 * i - 1; + r[i] = mod(d, b); + d = d / b; + i = i - 1; + if (i != 0) + { + d = d * i; + } + } + + printfour(c + d / 10000); + c = mod(d, 10000); + + k = k - 14; + } + + return; +} diff --git a/tests/4-opt/testcases/3_complex1.out b/tests/4-opt/testcases/3_complex1.out new file mode 100644 index 0000000..068ee2c --- /dev/null +++ b/tests/4-opt/testcases/3_complex1.out @@ -0,0 +1,801 @@ +3 +1 +4 +1 +5 +9 +2 +6 +5 +3 +5 +8 +9 +7 +9 +3 +2 +3 +8 +4 +6 +2 +6 +4 +3 +3 +8 +3 +2 +7 +9 +5 +0 +2 +8 +8 +4 +1 +9 +7 +1 +6 +9 +3 +9 +9 +3 +7 +5 +1 +0 +5 +8 +2 +0 +9 +7 +4 +9 +4 +4 +5 +9 +2 +3 +0 +7 +8 +1 +6 +4 +0 +6 +2 +8 +6 +2 +0 +8 +9 +9 +8 +6 +2 +8 +0 +3 +4 +8 +2 +5 +3 +4 +2 +1 +1 +7 +0 +6 +7 +9 +8 +2 +1 +4 +8 +0 +8 +6 +5 +1 +3 +2 +8 +2 +3 +0 +6 +6 +4 +7 +0 +9 +3 +8 +4 +4 +6 +0 +9 +5 +5 +0 +5 +8 +2 +2 +3 +1 +7 +2 +5 +3 +5 +9 +4 +0 +8 +1 +2 +8 +4 +8 +1 +1 +1 +7 +4 +5 +0 +2 +8 +4 +1 +0 +2 +7 +0 +1 +9 +3 +8 +5 +2 +1 +1 +0 +5 +5 +5 +9 +6 +4 +4 +6 +2 +2 +9 +4 +8 +9 +5 +4 +9 +3 +0 +3 +8 +1 +9 +6 +4 +4 +2 +8 +8 +1 +0 +9 +7 +5 +6 +6 +5 +9 +3 +3 +4 +4 +6 +1 +2 +8 +4 +7 +5 +6 +4 +8 +2 +3 +3 +7 +8 +6 +7 +8 +3 +1 +6 +5 +2 +7 +1 +2 +0 +1 +9 +0 +9 +1 +4 +5 +6 +4 +8 +5 +6 +6 +9 +2 +3 +4 +6 +0 +3 +4 +8 +6 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1 +4 +5 +2 +6 +3 +5 +6 +0 +8 +2 +7 +7 +8 +5 +7 +7 +1 +3 +4 +2 +7 +5 +7 +7 +8 +9 +6 +0 +9 +1 +7 +3 +6 +3 +7 +1 +7 +8 +7 +2 +1 +4 +6 +8 +4 +4 +0 +9 +0 +1 +2 +2 +4 +9 +5 +3 +4 +3 +0 +1 +4 +6 +5 +4 +9 +5 +8 +5 +3 +7 +1 +0 +5 +0 +7 +9 +2 +2 +7 +9 +6 +8 +9 +2 +5 +8 +9 +2 +3 +5 +4 +2 +0 +1 +9 +9 +5 +6 +1 +1 +2 +1 +2 +9 +0 +2 +1 +9 +6 +0 +8 +6 +4 +0 +3 +4 +4 +1 +8 +1 +5 +9 +8 +1 +3 +6 +2 +9 +7 +7 +4 +7 +7 +1 +3 +0 +9 +9 +6 +0 +5 +1 +8 +7 +0 +7 +2 +1 +1 +3 +4 +9 +9 +9 +9 +9 +9 +8 +3 +7 +2 +9 +7 +8 +0 +4 +9 +9 +5 +1 +0 +5 +9 +7 +3 +1 +7 +3 +2 +8 +1 +6 +0 +9 +6 +3 +1 +8 +5 +0 diff --git a/tests/4-opt/testcases/4_complex2.cminus b/tests/4-opt/testcases/4_complex2.cminus new file mode 100755 index 0000000..f44dd25 --- /dev/null +++ b/tests/4-opt/testcases/4_complex2.cminus @@ -0,0 +1,59 @@ +/* this is the sample program in C- in the book "Compiler Construction" */ +/* A program to perform selection sort on a 10 element array. */ +float x[10]; + +int minloc(float a[], float low, int high) +{ + int i; + int x; + int k; + k = low; + x = a[low]; + i = low + 1; + while (i < high) + { + if (a[i] < x) + { + x = a[i]; + k = i; + } + i = i + 1; + } + return k; +} + +void sort(float a[], int low, float high) +{ + int i; + int k; + i = low; + while (i < high - 1) + { + int t; + k = minloc(a, i, high); + t = a[k]; + a[k] = a[i]; + a[i] = t; + i = i + 1; + } + return; +} + +void main(void) +{ + int i; + i = 0; + while (i < 10) + { + x[i] = input(); + i = i + 1; + } + sort(x, 0, 10); + i = 0; + while (i < 10) + { + output(x[i]); + i = i + 1; + } + return; +} diff --git a/tests/4-opt/testcases/4_complex2.in b/tests/4-opt/testcases/4_complex2.in new file mode 100755 index 0000000..ba6e481 --- /dev/null +++ b/tests/4-opt/testcases/4_complex2.in @@ -0,0 +1,10 @@ +9 +8 +7 +6 +5 +4 +3 +2 +1 +0 diff --git a/tests/4-opt/testcases/functional-cases/5-while.out b/tests/4-opt/testcases/4_complex2.out old mode 100644 new mode 100755 similarity index 100% rename from tests/4-opt/testcases/functional-cases/5-while.out rename to tests/4-opt/testcases/4_complex2.out diff --git a/tests/4-opt/testcases/5_complex3.cminus b/tests/4-opt/testcases/5_complex3.cminus new file mode 100755 index 0000000..e5285c7 --- /dev/null +++ b/tests/4-opt/testcases/5_complex3.cminus @@ -0,0 +1,25 @@ +int gcd(int u, int v) +{ + if (v == 0) + return u; + else + return gcd(v, u - u / v * v); +} + +void main(void) +{ + int x; + int y; + int temp; + x = input(); + y = input(); + if (x < y) + { + temp = x; + x = y; + y = temp; + } + temp = gcd(x, y); + output(temp); + return; +} diff --git a/tests/4-opt/testcases/5_complex3.in b/tests/4-opt/testcases/5_complex3.in new file mode 100755 index 0000000..50a3a30 --- /dev/null +++ b/tests/4-opt/testcases/5_complex3.in @@ -0,0 +1,2 @@ +78 +117 diff --git a/tests/4-opt/testcases/5_complex3.out b/tests/4-opt/testcases/5_complex3.out new file mode 100755 index 0000000..435a54d --- /dev/null +++ b/tests/4-opt/testcases/5_complex3.out @@ -0,0 +1,2 @@ +39 +0 diff --git a/tests/4-opt/testcases/6_complex4.cminus b/tests/4-opt/testcases/6_complex4.cminus new file mode 100755 index 0000000..cbd8f94 --- /dev/null +++ b/tests/4-opt/testcases/6_complex4.cminus @@ -0,0 +1,122 @@ +float get(float a[], int x, int y, int row) { return a[x * row + y]; } + +float abs(float x) +{ + if (x > 0) + return x; + else + return 0 - x; +} + +float isZero(float t) { return abs(t) < 0.000001; } + +int gauss(float vars[], float equ[], int var) +{ + int i; + int j; + int k; + int varone; + int maxr; + int col; + float temp; + varone = var + 1; + + i = 0; + while (i < var) + { + vars[i] = 0; + i = i + 1; + } + + col = 0; + k = 0; + while (k < var) + { + maxr = k; + i = k + 1; + while (i < var) + { + if (abs(get(equ, i, col, varone)) > abs(get(equ, maxr, col, varone))) + maxr = i; + i = i + 1; + } + if (maxr != k) + { + j = k; + + while (j < varone) + { + temp = get(equ, k, j, varone); + equ[k * varone + j] = get(equ, maxr, j, varone); + equ[maxr * varone + j] = temp; + j = j + 1; + } + } + if (isZero(get(equ, k, col, varone))) + { + k = k - 1; + } + else + { + i = k + 1; + while (i < var) + { + if (1 - isZero(get(equ, i, col, varone))) + { + temp = get(equ, i, col, varone) / get(equ, k, col, varone); + j = col; + while (j < varone) + { + equ[i * varone + j] = equ[i * varone + j] - get(equ, k, j, varone) * temp; + j = j + 1; + } + } + i = i + 1; + } + } + k = k + 1; + col = col + 1; + } + + i = var - 1; + while (i >= 0) + { + temp = get(equ, i, var, varone); + j = i + 1; + while (j < var) + { + if (1 - isZero(get(equ, i, j, varone))) + temp = temp - get(equ, i, j, varone) * vars[j]; + j = j + 1; + } + vars[i] = temp / get(equ, i, i, varone); + i = i - 1; + } + return 0; +} + +void main(void) +{ + int num; + float vars[3]; + float equ[12]; + equ[0] = 1; + equ[1] = 2; + equ[2] = 1; + equ[3] = 1; + equ[1 * 4 + 0] = 2; + equ[1 * 4 + 1] = 3; + equ[1 * 4 + 2] = 4; + equ[1 * 4 + 3] = 3; + equ[2 * 4 + 0] = 1; + equ[2 * 4 + 1] = 1; + equ[2 * 4 + 2] = 0 - 2; + equ[2 * 4 + 3] = 0; + gauss(vars, equ, 3); + num = 0; + while (num < 3) + { + outputFloat(vars[num]); + num = num + 1; + } +} diff --git a/tests/4-opt/testcases/6_complex4.out b/tests/4-opt/testcases/6_complex4.out new file mode 100755 index 0000000..02d2205 --- /dev/null +++ b/tests/4-opt/testcases/6_complex4.out @@ -0,0 +1,4 @@ +1.000000 +-0.200000 +0.400000 +0 diff --git a/tests/4-opt/testcases/7_return_early.cminus b/tests/4-opt/testcases/7_return_early.cminus new file mode 100644 index 0000000..69ca5c1 --- /dev/null +++ b/tests/4-opt/testcases/7_return_early.cminus @@ -0,0 +1,44 @@ +int main(void) +{ + int b; + int a; + int flags[10]; + a = 0; + b = input(); + while (a < 10) + { + flags[a] = b * 2; + a = a + 1; + } + if (a > 1) + { + if (a < 10) + { + return 7; + } + else + { + return 2; + } + } + else + { + return 3; + } + while (a < 10) + { + int b; + b = 0; + while (b < 10) + { + b = b + 1; + flags[b] = flags[a]; + if (flags[a + b] < flags[a * b]) + { + return 4; + } + } + a = a + 1; + } + return 5; +} diff --git a/tests/4-opt/testcases/7_return_early.in b/tests/4-opt/testcases/7_return_early.in new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/tests/4-opt/testcases/7_return_early.in @@ -0,0 +1 @@ +3 diff --git a/tests/4-opt/testcases/7_return_early.out b/tests/4-opt/testcases/7_return_early.out new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/tests/4-opt/testcases/7_return_early.out @@ -0,0 +1 @@ +2 diff --git a/tests/4-opt/testcases/8_licm0.cminus b/tests/4-opt/testcases/8_licm0.cminus new file mode 100644 index 0000000..9334110 --- /dev/null +++ b/tests/4-opt/testcases/8_licm0.cminus @@ -0,0 +1,104 @@ +int ga; +int gb; + +int pure(int m, int n) { return m * n; } +int f(int m, int n) { return m * n + ga; } + +int g(int m, int n) +{ + ga = m + n; + return m * n + gb; +} + +int notsopure(void) +{ + return input(); +} + +int main(void) +{ + int t; + int a; + int b; + int c; + int d; + int ar[4]; + int br[4]; + int cr[4]; + t = 0; + while (t < 4) + { + cr[t] = notsopure(); + t = t + 1; + } + t = 0; + c = 1; + while (t < 10) + { + a = pure(c, c); + b = pure(a, c); + d = pure(b, t); + output(a + b + d); + t = t + 1; + } + t = 0; + while (t < 10) + { + a = pure(ga, c); + b = f(gb, c); + output(a + b); + t = t + 1; + } + t = 0; + while (t < 10) + { + a = f(gb, c); + b = f(c, c); + d = pure(gb, c); + d = d + g(c, c); + output(a + b + d); + t = t + 1; + } + t = 0; + while (t < 10) + { + if (t < 5) + { + a = c * 2; + } + else + { + a = c * 3; + } + output(a); + t = t + 1; + } + t = 0; + while (t < 4) + { + ar[t] = 1 + t; + br[t] = 1 - t; + t = t + 1; + } + t = 0; + while (t < 4) + { + int s; + s = 0; + while (s < 4) + { + cr[t] = cr[t] + ar[t] * br[s] + ga + gb; + s = s + 1; + gb = gb + 1; + } + t = t + 1; + ga = ga + 1; + } + t = 0; + while (t < 4) + { + output(cr[t]); + t = t + 1; + } + return 0; +} diff --git a/tests/4-opt/testcases/8_licm0.in b/tests/4-opt/testcases/8_licm0.in new file mode 100644 index 0000000..94ebaf9 --- /dev/null +++ b/tests/4-opt/testcases/8_licm0.in @@ -0,0 +1,4 @@ +1 +2 +3 +4 diff --git a/tests/4-opt/testcases/8_licm0.out b/tests/4-opt/testcases/8_licm0.out new file mode 100644 index 0000000..55a2cc3 --- /dev/null +++ b/tests/4-opt/testcases/8_licm0.out @@ -0,0 +1,45 @@ +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +2 +6 +6 +6 +6 +6 +6 +6 +6 +6 +2 +2 +2 +2 +2 +3 +3 +3 +3 +3 +13 +32 +51 +70 +0 diff --git a/tests/4-opt/testcases/9_licm_bad.cminus b/tests/4-opt/testcases/9_licm_bad.cminus new file mode 100644 index 0000000..1ce2a95 --- /dev/null +++ b/tests/4-opt/testcases/9_licm_bad.cminus @@ -0,0 +1,27 @@ + + +int main(void) { + int t; + int a; + int b; + t = 0; + b = 1; + while (t < 0) { + a = b / b + b * b + a; + a = b / b + b * b + a; + t = t + 1; + } + while (t < 1) { + if (b > 2) { + a = b / b + b * b + a; + a = b / b + b * b + a; + } else + output(t); + t = t + 1; + } + while (t < 3) { + a = b / b + b * b + a; + t = t + 1; + } + return a; +} diff --git a/tests/4-opt/testcases/loop/loop-1.out b/tests/4-opt/testcases/9_licm_bad.out similarity index 50% rename from tests/4-opt/testcases/loop/loop-1.out rename to tests/4-opt/testcases/9_licm_bad.out index aa47d0d..4f1d7cd 100644 --- a/tests/4-opt/testcases/loop/loop-1.out +++ b/tests/4-opt/testcases/9_licm_bad.out @@ -1,2 +1,2 @@ 0 -0 +4 diff --git a/tests/4-opt/testcases/functional-cases/0-io.cminus b/tests/4-opt/testcases/functional-cases/0-io.cminus deleted file mode 100644 index b73460e..0000000 --- a/tests/4-opt/testcases/functional-cases/0-io.cminus +++ /dev/null @@ -1,4 +0,0 @@ -int main(void) { - output(input()); - return 0; -} diff --git a/tests/4-opt/testcases/functional-cases/0-io.in b/tests/4-opt/testcases/functional-cases/0-io.in deleted file mode 100644 index 81c545e..0000000 --- a/tests/4-opt/testcases/functional-cases/0-io.in +++ /dev/null @@ -1 +0,0 @@ -1234 diff --git a/tests/4-opt/testcases/functional-cases/0-io.out b/tests/4-opt/testcases/functional-cases/0-io.out deleted file mode 100644 index 2b8eb81..0000000 --- a/tests/4-opt/testcases/functional-cases/0-io.out +++ /dev/null @@ -1,2 +0,0 @@ -1234 -0 diff --git a/tests/4-opt/testcases/functional-cases/1-return.cminus b/tests/4-opt/testcases/functional-cases/1-return.cminus deleted file mode 100644 index 91e77f2..0000000 --- a/tests/4-opt/testcases/functional-cases/1-return.cminus +++ /dev/null @@ -1,4 +0,0 @@ -int main(void) { - output(111); - return 111; -} diff --git a/tests/4-opt/testcases/functional-cases/1-return.out b/tests/4-opt/testcases/functional-cases/1-return.out deleted file mode 100644 index 2bbe845..0000000 --- a/tests/4-opt/testcases/functional-cases/1-return.out +++ /dev/null @@ -1,2 +0,0 @@ -111 -111 diff --git a/tests/4-opt/testcases/functional-cases/10-float.cminus b/tests/4-opt/testcases/functional-cases/10-float.cminus deleted file mode 100644 index 8de09f6..0000000 --- a/tests/4-opt/testcases/functional-cases/10-float.cminus +++ /dev/null @@ -1,19 +0,0 @@ -int main(void) { - float a; - float b; - float c; - - a = 1.1; - b = 1.5; - c = 1.2; - - outputFloat(a * b + c); - return 0; -} - -/* - 用 gcc 编译此文件生成汇编代码时,命令为 gcc -include io.h -S 10-float.c - 其中 io.h 位于 src/io/io.h, - - 也可以在本文件开头加上 void outputFloat(float x); -*/ diff --git a/tests/4-opt/testcases/functional-cases/10-float.out b/tests/4-opt/testcases/functional-cases/10-float.out deleted file mode 100644 index 28c52e7..0000000 --- a/tests/4-opt/testcases/functional-cases/10-float.out +++ /dev/null @@ -1,2 +0,0 @@ -2.850000 -0 diff --git a/tests/4-opt/testcases/functional-cases/11-floatcall.cminus b/tests/4-opt/testcases/functional-cases/11-floatcall.cminus deleted file mode 100644 index 23f73d7..0000000 --- a/tests/4-opt/testcases/functional-cases/11-floatcall.cminus +++ /dev/null @@ -1,18 +0,0 @@ -/* float function call */ - -float mod(float x, float y) { - int div; - div = x / y; - return x - div * y; -} - -int main(void) { - float a; - float b; - - a = 11.2; - b = 2.2; - - outputFloat(mod(a, b)); - return 0; -} diff --git a/tests/4-opt/testcases/functional-cases/11-floatcall.out b/tests/4-opt/testcases/functional-cases/11-floatcall.out deleted file mode 100644 index e176519..0000000 --- a/tests/4-opt/testcases/functional-cases/11-floatcall.out +++ /dev/null @@ -1,2 +0,0 @@ -0.200000 -0 diff --git a/tests/4-opt/testcases/functional-cases/12-global.cminus b/tests/4-opt/testcases/functional-cases/12-global.cminus deleted file mode 100644 index 63bddbb..0000000 --- a/tests/4-opt/testcases/functional-cases/12-global.cminus +++ /dev/null @@ -1,47 +0,0 @@ -int seed; - -int randomLCG(void) { - seed = seed * 1103515245 + 12345; - return seed; -} - -int randBin(void) { - if (randomLCG() > 0) - return 1; - else - return 0; -} - -/* random walk */ -int returnToZeroSteps(void) { - int x; - int steps; - - x = 0; - steps = 0; - - while (steps < 20) { - if (randBin()) - x = x + 1; - else - x = x - 1; - - steps = steps + 1; - if (x == 0) - return steps; - } - return 20; -} - -int main(void) { - int i; - i = 0; - - seed = 3407; - - while (i < 20) { - output(returnToZeroSteps()); - i = i + 1; - } - return 0; -} diff --git a/tests/4-opt/testcases/functional-cases/12-global.out b/tests/4-opt/testcases/functional-cases/12-global.out deleted file mode 100644 index 66bb323..0000000 --- a/tests/4-opt/testcases/functional-cases/12-global.out +++ /dev/null @@ -1,21 +0,0 @@ -4 -2 -2 -4 -8 -2 -2 -2 -2 -2 -6 -2 -10 -8 -4 -2 -20 -2 -2 -8 -0 diff --git a/tests/4-opt/testcases/functional-cases/13-complex.cminus b/tests/4-opt/testcases/functional-cases/13-complex.cminus deleted file mode 100644 index 22232fb..0000000 --- a/tests/4-opt/testcases/functional-cases/13-complex.cminus +++ /dev/null @@ -1,67 +0,0 @@ -/* 01 背包问题 */ - -int n; -int m; - -int w[5]; -int v[5]; - -int dp[66]; /* dp[n * 11 + size] 表示前 n 个物品放入容量为 size 的背包中的最大价值,初始化为 -1 */ - -int max(int a, int b) { - if (a > b) - return a; - else - return b; -} - -/* 状态转移方程: - dp[n][size] = max(dp[n - 1][size], dp[n - 1][size - w[n]] + v[n]) - 边界条件: - dp[n][size <= 0] = 0 - dp[0][size] = 0 */ - -int knapsack(int n, int size) { - int result; - if (size <= 0) - return 0; - if (n == 0) - return 0; - if (dp[n * 11 + size] >= 0) - return dp[n * 11 + size]; - - if (size < w[n - 1]) - result = knapsack(n - 1, size); - else - result = max(knapsack(n - 1, size), knapsack(n - 1, size - w[n - 1]) + v[n - 1]); - - dp[n * 11 + size] = result; - return result; -} - -int main(void) { - int i; - i = 0; - - n = 5; - m = 10; - w[0] = 2; - w[1] = 2; - w[2] = 6; - w[3] = 5; - w[4] = 4; - - v[0] = 6; - v[1] = 3; - v[2] = 5; - v[3] = 4; - v[4] = 6; - - while (i < 66) { - dp[i] = 0 - 1; - i = i + 1; - } - - output(knapsack(n, m)); - return 0; -} diff --git a/tests/4-opt/testcases/functional-cases/13-complex.out b/tests/4-opt/testcases/functional-cases/13-complex.out deleted file mode 100644 index 227eae2..0000000 --- a/tests/4-opt/testcases/functional-cases/13-complex.out +++ /dev/null @@ -1,2 +0,0 @@ -15 -0 diff --git a/tests/4-opt/testcases/functional-cases/2-calculate.cminus b/tests/4-opt/testcases/functional-cases/2-calculate.cminus deleted file mode 100644 index fa4c9a1..0000000 --- a/tests/4-opt/testcases/functional-cases/2-calculate.cminus +++ /dev/null @@ -1,11 +0,0 @@ -int main(void) { - int a; - int b; - int c; - - a = 23; - b = 25; - c = 4; - - return a + b * c; -} diff --git a/tests/4-opt/testcases/functional-cases/2-calculate.out b/tests/4-opt/testcases/functional-cases/2-calculate.out deleted file mode 100644 index 190a180..0000000 --- a/tests/4-opt/testcases/functional-cases/2-calculate.out +++ /dev/null @@ -1 +0,0 @@ -123 diff --git a/tests/4-opt/testcases/functional-cases/3-output.cminus b/tests/4-opt/testcases/functional-cases/3-output.cminus deleted file mode 100644 index abe3222..0000000 --- a/tests/4-opt/testcases/functional-cases/3-output.cminus +++ /dev/null @@ -1,5 +0,0 @@ -int main(void) { - output(11); - output(22222); - return 0; -} diff --git a/tests/4-opt/testcases/functional-cases/3-output.out b/tests/4-opt/testcases/functional-cases/3-output.out deleted file mode 100644 index 1983173..0000000 --- a/tests/4-opt/testcases/functional-cases/3-output.out +++ /dev/null @@ -1,3 +0,0 @@ -11 -22222 -0 diff --git a/tests/4-opt/testcases/functional-cases/4-if.cminus b/tests/4-opt/testcases/functional-cases/4-if.cminus deleted file mode 100644 index a4ba887..0000000 --- a/tests/4-opt/testcases/functional-cases/4-if.cminus +++ /dev/null @@ -1,23 +0,0 @@ -int main(void) { - int a; - int b; - int c; - - a = 11; - b = 22; - c = 33; - - /* max value */ - if (a > b) { - if (a > c) - output(a); - else - output(c); - } else { - if (c < b) - output(b); - else - output(c); - } - return 0; -} diff --git a/tests/4-opt/testcases/functional-cases/4-if.out b/tests/4-opt/testcases/functional-cases/4-if.out deleted file mode 100644 index 54a647c..0000000 --- a/tests/4-opt/testcases/functional-cases/4-if.out +++ /dev/null @@ -1,2 +0,0 @@ -33 -0 diff --git a/tests/4-opt/testcases/functional-cases/5-while.cminus b/tests/4-opt/testcases/functional-cases/5-while.cminus deleted file mode 100644 index da3313b..0000000 --- a/tests/4-opt/testcases/functional-cases/5-while.cminus +++ /dev/null @@ -1,14 +0,0 @@ -int main(void) { - int n; - int i; - - n = 10; - i = 0; - - while (i < n) { - output(i); - i = i + 1; - } - - return 0; -} diff --git a/tests/4-opt/testcases/functional-cases/6-array.cminus b/tests/4-opt/testcases/functional-cases/6-array.cminus deleted file mode 100644 index 3383fca..0000000 --- a/tests/4-opt/testcases/functional-cases/6-array.cminus +++ /dev/null @@ -1,15 +0,0 @@ -int main(void) { - int a[10]; - int i; - - i = 0; - a[0] = 11; - a[4] = 22; - a[9] = 33; - - output(a[0]); - output(a[4]); - output(a[9]); - - return 0; -} diff --git a/tests/4-opt/testcases/functional-cases/6-array.out b/tests/4-opt/testcases/functional-cases/6-array.out deleted file mode 100644 index d7fcd8c..0000000 --- a/tests/4-opt/testcases/functional-cases/6-array.out +++ /dev/null @@ -1,4 +0,0 @@ -11 -22 -33 -0 diff --git a/tests/4-opt/testcases/functional-cases/7-function.cminus b/tests/4-opt/testcases/functional-cases/7-function.cminus deleted file mode 100644 index 2eb2620..0000000 --- a/tests/4-opt/testcases/functional-cases/7-function.cminus +++ /dev/null @@ -1,21 +0,0 @@ -int min(int a, int b) { - if (a <= b) - return a; - else - return b; -} - -int main(void) { - int a; - int b; - int c; - - a = 11; - b = 22; - c = 33; - - output(min(a, b)); - output(min(b, c)); - output(min(c, a)); - return 0; -} diff --git a/tests/4-opt/testcases/functional-cases/7-function.out b/tests/4-opt/testcases/functional-cases/7-function.out deleted file mode 100644 index 38ea323..0000000 --- a/tests/4-opt/testcases/functional-cases/7-function.out +++ /dev/null @@ -1,4 +0,0 @@ -11 -22 -11 -0 diff --git a/tests/4-opt/testcases/functional-cases/8-store.cminus b/tests/4-opt/testcases/functional-cases/8-store.cminus deleted file mode 100644 index 15a438d..0000000 --- a/tests/4-opt/testcases/functional-cases/8-store.cminus +++ /dev/null @@ -1,26 +0,0 @@ -int store(int arr[], int index, int value) { - arr[index] = value; - return value; -} - -int main(void) { - int a[10]; - int i; - int sum; - - i = 0; - while (i < 10) { - store(a, i, i * 2); - i = i + 1; - } - - sum = 0; - i = 0; - while (i < 10) { - sum = sum + a[i]; - i = i + 1; - } - - output(sum); - return 0; -} diff --git a/tests/4-opt/testcases/functional-cases/8-store.out b/tests/4-opt/testcases/functional-cases/8-store.out deleted file mode 100644 index d2044a0..0000000 --- a/tests/4-opt/testcases/functional-cases/8-store.out +++ /dev/null @@ -1,2 +0,0 @@ -90 -0 diff --git a/tests/4-opt/testcases/functional-cases/9-fibonacci.cminus b/tests/4-opt/testcases/functional-cases/9-fibonacci.cminus deleted file mode 100644 index df0ee72..0000000 --- a/tests/4-opt/testcases/functional-cases/9-fibonacci.cminus +++ /dev/null @@ -1,23 +0,0 @@ -int fibonacci(int n) { - if (n == 0) - return 0; - else if (n == 1) - return 1; - else - return fibonacci(n - 1) + fibonacci(n - 2); -} - -int main(void) { - int n; - int i; - - n = 10; - i = 0; - - while (i < n) { - output(fibonacci(i)); - i = i + 1; - } - - return 0; -} diff --git a/tests/4-opt/testcases/functional-cases/9-fibonacci.out b/tests/4-opt/testcases/functional-cases/9-fibonacci.out deleted file mode 100644 index f53d098..0000000 --- a/tests/4-opt/testcases/functional-cases/9-fibonacci.out +++ /dev/null @@ -1,11 +0,0 @@ -0 -1 -1 -2 -3 -5 -8 -13 -21 -34 -0 diff --git a/tests/4-opt/testcases/loop/baseline/loop-1.ll b/tests/4-opt/testcases/loop/baseline/loop-1.ll deleted file mode 100644 index 5b37e40..0000000 --- a/tests/4-opt/testcases/loop/baseline/loop-1.ll +++ /dev/null @@ -1,60 +0,0 @@ -; ModuleID = 'cminus' -source_filename = "/home/haiqwa/2020fall-compiler_cminus/tests/lab5/./testcases/LoopInvHoist/testcase-5.cminus" - -declare i32 @input() - -declare void @output(i32) - -declare void @outputFloat(float) - -declare void @neg_idx_except() - -define void @main() { -label_entry: - br label %label3 -label3: ; preds = %label_entry, %label58 - %op61 = phi i32 [ %op64, %label58 ], [ undef, %label_entry ] - %op62 = phi i32 [ 1, %label_entry ], [ %op60, %label58 ] - %op63 = phi i32 [ %op65, %label58 ], [ undef, %label_entry ] - %op5 = icmp slt i32 %op62, 10000 - %op6 = zext i1 %op5 to i32 - %op7 = icmp ne i32 %op6, 0 - br i1 %op7, label %label8, label %label9 -label8: ; preds = %label3 - %op19 = mul i32 %op62, %op62 - %op21 = mul i32 %op19, %op62 - %op23 = mul i32 %op21, %op62 - %op25 = mul i32 %op23, %op62 - %op27 = mul i32 %op25, %op62 - %op29 = mul i32 %op27, %op62 - %op31 = mul i32 %op29, %op62 - %op33 = mul i32 %op31, %op62 - %op35 = mul i32 %op33, %op62 - %op37 = sdiv i32 %op35, %op62 - %op39 = sdiv i32 %op37, %op62 - %op41 = sdiv i32 %op39, %op62 - %op43 = sdiv i32 %op41, %op62 - %op45 = sdiv i32 %op43, %op62 - %op47 = sdiv i32 %op45, %op62 - %op49 = sdiv i32 %op47, %op62 - %op51 = sdiv i32 %op49, %op62 - %op53 = sdiv i32 %op51, %op62 - %op55 = sdiv i32 %op53, %op62 - br label %label11 -label9: ; preds = %label3 - call void @output(i32 %op61) - ret void -label11: ; preds = %label8, %label16 - %op64 = phi i32 [ %op61, %label8 ], [ %op55, %label16 ] - %op65 = phi i32 [ 0, %label8 ], [ %op57, %label16 ] - %op13 = icmp slt i32 %op65, 10000 - %op14 = zext i1 %op13 to i32 - %op15 = icmp ne i32 %op14, 0 - br i1 %op15, label %label16, label %label58 -label16: ; preds = %label11 - %op57 = add i32 %op65, 1 - br label %label11 -label58: ; preds = %label11 - %op60 = add i32 %op62, 1 - br label %label3 -} diff --git a/tests/4-opt/testcases/loop/baseline/loop-2.ll b/tests/4-opt/testcases/loop/baseline/loop-2.ll deleted file mode 100644 index d0983dd..0000000 --- a/tests/4-opt/testcases/loop/baseline/loop-2.ll +++ /dev/null @@ -1,60 +0,0 @@ -; ModuleID = 'cminus' -source_filename = "/home/haiqwa/2020fall-compiler_cminus/tests/lab5/./testcases/LoopInvHoist/testcase-6.cminus" - -declare i32 @input() - -declare void @output(i32) - -declare void @outputFloat(float) - -declare void @neg_idx_except() - -define void @main() { -label_entry: - %op20 = mul i32 2, 2 - %op22 = mul i32 %op20, 2 - %op24 = mul i32 %op22, 2 - %op26 = mul i32 %op24, 2 - %op28 = mul i32 %op26, 2 - %op30 = mul i32 %op28, 2 - %op32 = mul i32 %op30, 2 - %op34 = mul i32 %op32, 2 - %op36 = mul i32 %op34, 2 - %op38 = sdiv i32 %op36, 2 - %op40 = sdiv i32 %op38, 2 - %op42 = sdiv i32 %op40, 2 - %op44 = sdiv i32 %op42, 2 - %op46 = sdiv i32 %op44, 2 - %op48 = sdiv i32 %op46, 2 - %op50 = sdiv i32 %op48, 2 - %op52 = sdiv i32 %op50, 2 - %op54 = sdiv i32 %op52, 2 - %op56 = sdiv i32 %op54, 2 - br label %label4 -label4: ; preds = %label_entry, %label59 - %op62 = phi i32 [ %op65, %label59 ], [ undef, %label_entry ] - %op63 = phi i32 [ 0, %label_entry ], [ %op61, %label59 ] - %op64 = phi i32 [ %op66, %label59 ], [ undef, %label_entry ] - %op6 = icmp slt i32 %op63, 10000000 - %op7 = zext i1 %op6 to i32 - %op8 = icmp ne i32 %op7, 0 - br i1 %op8, label %label9, label %label10 -label9: ; preds = %label4 - br label %label12 -label10: ; preds = %label4 - call void @output(i32 %op62) - ret void -label12: ; preds = %label9, %label17 - %op65 = phi i32 [ %op62, %label9 ], [ %op56, %label17 ] - %op66 = phi i32 [ 0, %label9 ], [ %op58, %label17 ] - %op14 = icmp slt i32 %op66, 2 - %op15 = zext i1 %op14 to i32 - %op16 = icmp ne i32 %op15, 0 - br i1 %op16, label %label17, label %label59 -label17: ; preds = %label12 - %op58 = add i32 %op66, 1 - br label %label12 -label59: ; preds = %label12 - %op61 = add i32 %op63, 1 - br label %label4 -} diff --git a/tests/4-opt/testcases/loop/baseline/loop-3.ll b/tests/4-opt/testcases/loop/baseline/loop-3.ll deleted file mode 100644 index 257f877..0000000 --- a/tests/4-opt/testcases/loop/baseline/loop-3.ll +++ /dev/null @@ -1,119 +0,0 @@ -declare i32 @input() - -declare void @output(i32) - -declare void @outputFloat(float) - -declare void @neg_idx_except() - -define void @main() { -label_entry: - %op60 = mul i32 2, 2 - %op62 = mul i32 %op60, 2 - %op64 = mul i32 %op62, 2 - %op66 = mul i32 %op64, 2 - %op68 = mul i32 %op66, 2 - %op70 = mul i32 %op68, 2 - %op72 = mul i32 %op70, 2 - %op74 = mul i32 %op72, 2 - %op76 = mul i32 %op74, 2 - %op78 = sdiv i32 %op76, 2 - %op80 = sdiv i32 %op78, 2 - %op82 = sdiv i32 %op80, 2 - %op84 = sdiv i32 %op82, 2 - %op86 = sdiv i32 %op84, 2 - %op88 = sdiv i32 %op86, 2 - %op90 = sdiv i32 %op88, 2 - %op92 = sdiv i32 %op90, 2 - %op94 = sdiv i32 %op92, 2 - %op96 = sdiv i32 %op94, 2 - br label %label8 -label8: ; preds = %label_entry, %label22 - %op102 = phi i32 [ %op109, %label22 ], [ undef, %label_entry ] - %op103 = phi i32 [ %op110, %label22 ], [ undef, %label_entry ] - %op104 = phi i32 [ %op111, %label22 ], [ undef, %label_entry ] - %op105 = phi i32 [ %op112, %label22 ], [ undef, %label_entry ] - %op106 = phi i32 [ %op113, %label22 ], [ undef, %label_entry ] - %op107 = phi i32 [ 0, %label_entry ], [ %op24, %label22 ] - %op108 = phi i32 [ %op114, %label22 ], [ undef, %label_entry ] - %op10 = icmp slt i32 %op107, 1000000 - %op11 = zext i1 %op10 to i32 - %op12 = icmp ne i32 %op11, 0 - br i1 %op12, label %label13, label %label14 -label13: ; preds = %label8 - br label %label16 -label14: ; preds = %label8 - call void @output(i32 %op102) - ret void -label16: ; preds = %label13, %label31 - %op109 = phi i32 [ %op102, %label13 ], [ %op115, %label31 ] - %op110 = phi i32 [ %op103, %label13 ], [ %op116, %label31 ] - %op111 = phi i32 [ %op104, %label13 ], [ %op117, %label31 ] - %op112 = phi i32 [ %op105, %label13 ], [ %op118, %label31 ] - %op113 = phi i32 [ %op106, %label13 ], [ %op119, %label31 ] - %op114 = phi i32 [ 0, %label13 ], [ %op33, %label31 ] - %op18 = icmp slt i32 %op114, 2 - %op19 = zext i1 %op18 to i32 - %op20 = icmp ne i32 %op19, 0 - br i1 %op20, label %label21, label %label22 -label21: ; preds = %label16 - br label %label25 -label22: ; preds = %label16 - %op24 = add i32 %op107, 1 - br label %label8 -label25: ; preds = %label21, %label40 - %op115 = phi i32 [ %op109, %label21 ], [ %op120, %label40 ] - %op116 = phi i32 [ %op110, %label21 ], [ %op121, %label40 ] - %op117 = phi i32 [ %op111, %label21 ], [ %op122, %label40 ] - %op118 = phi i32 [ %op112, %label21 ], [ %op123, %label40 ] - %op119 = phi i32 [ 0, %label21 ], [ %op42, %label40 ] - %op27 = icmp slt i32 %op119, 2 - %op28 = zext i1 %op27 to i32 - %op29 = icmp ne i32 %op28, 0 - br i1 %op29, label %label30, label %label31 -label30: ; preds = %label25 - br label %label34 -label31: ; preds = %label25 - %op33 = add i32 %op114, 1 - br label %label16 -label34: ; preds = %label30, %label49 - %op120 = phi i32 [ %op115, %label30 ], [ %op124, %label49 ] - %op121 = phi i32 [ %op116, %label30 ], [ %op125, %label49 ] - %op122 = phi i32 [ %op117, %label30 ], [ %op126, %label49 ] - %op123 = phi i32 [ 0, %label30 ], [ %op51, %label49 ] - %op36 = icmp slt i32 %op123, 2 - %op37 = zext i1 %op36 to i32 - %op38 = icmp ne i32 %op37, 0 - br i1 %op38, label %label39, label %label40 -label39: ; preds = %label34 - br label %label43 -label40: ; preds = %label34 - %op42 = add i32 %op119, 1 - br label %label25 -label43: ; preds = %label39, %label99 - %op124 = phi i32 [ %op120, %label39 ], [ %op127, %label99 ] - %op125 = phi i32 [ %op121, %label39 ], [ %op128, %label99 ] - %op126 = phi i32 [ 0, %label39 ], [ %op101, %label99 ] - %op45 = icmp slt i32 %op126, 2 - %op46 = zext i1 %op45 to i32 - %op47 = icmp ne i32 %op46, 0 - br i1 %op47, label %label48, label %label49 -label48: ; preds = %label43 - br label %label52 -label49: ; preds = %label43 - %op51 = add i32 %op123, 1 - br label %label34 -label52: ; preds = %label48, %label57 - %op127 = phi i32 [ %op124, %label48 ], [ %op96, %label57 ] - %op128 = phi i32 [ 0, %label48 ], [ %op98, %label57 ] - %op54 = icmp slt i32 %op128, 2 - %op55 = zext i1 %op54 to i32 - %op56 = icmp ne i32 %op55, 0 - br i1 %op56, label %label57, label %label99 -label57: ; preds = %label52 - %op98 = add i32 %op128, 1 - br label %label52 -label99: ; preds = %label52 - %op101 = add i32 %op126, 1 - br label %label43 -} diff --git a/tests/4-opt/testcases/loop/baseline/loop-4.ll b/tests/4-opt/testcases/loop/baseline/loop-4.ll deleted file mode 100644 index 838371a..0000000 --- a/tests/4-opt/testcases/loop/baseline/loop-4.ll +++ /dev/null @@ -1,132 +0,0 @@ -declare i32 @input() - -declare void @output(i32) - -declare void @outputFloat(float) - -declare void @neg_idx_except() - -define void @main() { -label_entry: - %op71 = mul i32 2, 2 - %op73 = mul i32 %op71, 2 - %op75 = mul i32 %op73, 2 - %op77 = mul i32 %op75, 2 - %op79 = mul i32 %op77, 2 - %op81 = mul i32 %op79, 2 - %op83 = mul i32 %op81, 2 - %op85 = mul i32 %op83, 2 - %op87 = mul i32 %op85, 2 - %op89 = sdiv i32 %op87, 2 - %op91 = sdiv i32 %op89, 2 - %op93 = sdiv i32 %op91, 2 - %op95 = sdiv i32 %op93, 2 - %op97 = sdiv i32 %op95, 2 - %op99 = sdiv i32 %op97, 2 - %op101 = sdiv i32 %op99, 2 - %op103 = sdiv i32 %op101, 2 - %op105 = sdiv i32 %op103, 2 - %op107 = sdiv i32 %op105, 2 - %op59 = icmp sgt i32 2, 1 - %op60 = zext i1 %op59 to i32 - %op61 = icmp ne i32 %op60, 0 - br label %label8 -label8: ; preds = %label_entry, %label22 - %op110 = phi i32 [ %op117, %label22 ], [ undef, %label_entry ] - %op111 = phi i32 [ %op118, %label22 ], [ undef, %label_entry ] - %op112 = phi i32 [ %op119, %label22 ], [ undef, %label_entry ] - %op113 = phi i32 [ %op120, %label22 ], [ undef, %label_entry ] - %op114 = phi i32 [ %op121, %label22 ], [ undef, %label_entry ] - %op115 = phi i32 [ 0, %label_entry ], [ %op24, %label22 ] - %op116 = phi i32 [ %op122, %label22 ], [ undef, %label_entry ] - %op10 = icmp slt i32 %op115, 1000000 - %op11 = zext i1 %op10 to i32 - %op12 = icmp ne i32 %op11, 0 - br i1 %op12, label %label13, label %label14 -label13: ; preds = %label8 - br label %label16 -label14: ; preds = %label8 - call void @output(i32 %op110) - ret void -label16: ; preds = %label13, %label31 - %op117 = phi i32 [ %op110, %label13 ], [ %op123, %label31 ] - %op118 = phi i32 [ %op111, %label13 ], [ %op124, %label31 ] - %op119 = phi i32 [ %op112, %label13 ], [ %op125, %label31 ] - %op120 = phi i32 [ %op113, %label13 ], [ %op126, %label31 ] - %op121 = phi i32 [ %op114, %label13 ], [ %op127, %label31 ] - %op122 = phi i32 [ 0, %label13 ], [ %op33, %label31 ] - %op18 = icmp slt i32 %op122, 2 - %op19 = zext i1 %op18 to i32 - %op20 = icmp ne i32 %op19, 0 - br i1 %op20, label %label21, label %label22 -label21: ; preds = %label16 - br label %label25 -label22: ; preds = %label16 - %op24 = add i32 %op115, 1 - br label %label8 -label25: ; preds = %label21, %label40 - %op123 = phi i32 [ %op117, %label21 ], [ %op129, %label40 ] - %op124 = phi i32 [ %op118, %label21 ], [ %op130, %label40 ] - %op125 = phi i32 [ %op119, %label21 ], [ %op131, %label40 ] - %op126 = phi i32 [ %op120, %label21 ], [ %op132, %label40 ] - %op127 = phi i32 [ 0, %label21 ], [ %op42, %label40 ] - %op128 = phi i32 [ %op122, %label21 ], [ %op133, %label40 ] - %op27 = icmp slt i32 %op127, 2 - %op28 = zext i1 %op27 to i32 - %op29 = icmp ne i32 %op28, 0 - br i1 %op29, label %label30, label %label31 -label30: ; preds = %label25 - br label %label34 -label31: ; preds = %label25 - %op33 = add i32 %op128, 1 - br label %label16 -label34: ; preds = %label30, %label49 - %op129 = phi i32 [ %op123, %label30 ], [ %op134, %label49 ] - %op130 = phi i32 [ %op124, %label30 ], [ %op135, %label49 ] - %op131 = phi i32 [ %op125, %label30 ], [ %op136, %label49 ] - %op132 = phi i32 [ 0, %label30 ], [ %op51, %label49 ] - %op133 = phi i32 [ %op128, %label30 ], [ %op137, %label49 ] - %op36 = icmp slt i32 %op132, 2 - %op37 = zext i1 %op36 to i32 - %op38 = icmp ne i32 %op37, 0 - br i1 %op38, label %label39, label %label40 -label39: ; preds = %label34 - br label %label43 -label40: ; preds = %label34 - %op42 = add i32 %op127, 1 - br label %label25 -label43: ; preds = %label39, %label62 - %op134 = phi i32 [ %op129, %label39 ], [ %op138, %label62 ] - %op135 = phi i32 [ %op130, %label39 ], [ %op139, %label62 ] - %op136 = phi i32 [ 0, %label39 ], [ %op64, %label62 ] - %op137 = phi i32 [ %op133, %label39 ], [ %op140, %label62 ] - %op45 = icmp slt i32 %op136, 2 - %op46 = zext i1 %op45 to i32 - %op47 = icmp ne i32 %op46, 0 - br i1 %op47, label %label48, label %label49 -label48: ; preds = %label43 - br label %label52 -label49: ; preds = %label43 - %op51 = add i32 %op132, 1 - br label %label34 -label52: ; preds = %label48, %label68 - %op138 = phi i32 [ %op134, %label48 ], [ %op107, %label68 ] - %op139 = phi i32 [ 0, %label48 ], [ %op109, %label68 ] - %op140 = phi i32 [ %op137, %label48 ], [ %op141, %label68 ] - %op54 = icmp slt i32 %op139, 2 - %op55 = zext i1 %op54 to i32 - %op56 = icmp ne i32 %op55, 0 - br i1 %op56, label %label57, label %label62 -label57: ; preds = %label52 - br i1 %op61, label %label65, label %label68 -label62: ; preds = %label52 - %op64 = add i32 %op136, 1 - br label %label43 -label65: ; preds = %label57 - %op67 = add i32 %op140, 1 - br label %label68 -label68: ; preds = %label57, %label65 - %op141 = phi i32 [ %op140, %label57 ], [ %op67, %label65 ] - %op109 = add i32 %op139, 1 - br label %label52 -} diff --git a/tests/4-opt/testcases/loop/loop-1.cminus b/tests/4-opt/testcases/loop/loop-1.cminus deleted file mode 100644 index 82ce6d3..0000000 --- a/tests/4-opt/testcases/loop/loop-1.cminus +++ /dev/null @@ -1,20 +0,0 @@ -void main(void){ - int i; - int j; - int ret; - - i = 1; - - while(i<10000) - { - j = 0; - while(j<10000) - { - ret = (i*i*i*i*i*i*i*i*i*i)/i/i/i/i/i/i/i/i/i/i; - j=j+1; - } - i=i+1; - } - output(ret); - return ; -} \ No newline at end of file diff --git a/tests/4-opt/testcases/loop/loop-2.cminus b/tests/4-opt/testcases/loop/loop-2.cminus deleted file mode 100644 index 920c1ad..0000000 --- a/tests/4-opt/testcases/loop/loop-2.cminus +++ /dev/null @@ -1,23 +0,0 @@ -void main(void){ - int i; - int j; - int a; - int ret; - - i = 0; - a = 2; - - while(i<10000000) - { - j = 0; - - while(j<2) - { - ret = (a*a*a*a*a*a*a*a*a*a)/a/a/a/a/a/a/a/a/a/a; - j=j+1; - } - i=i+1; - } - output(ret); - return ; -} \ No newline at end of file diff --git a/tests/4-opt/testcases/loop/loop-2.out b/tests/4-opt/testcases/loop/loop-2.out deleted file mode 100644 index b261da1..0000000 --- a/tests/4-opt/testcases/loop/loop-2.out +++ /dev/null @@ -1,2 +0,0 @@ -1 -0 diff --git a/tests/4-opt/testcases/loop/loop-3.cminus b/tests/4-opt/testcases/loop/loop-3.cminus deleted file mode 100644 index 8858c83..0000000 --- a/tests/4-opt/testcases/loop/loop-3.cminus +++ /dev/null @@ -1,46 +0,0 @@ -void main(void){ - int i; - int j; - int k; - int o; - int p; - int q; - int a; - int ret; - - a = 2; - - i = 0; - while(i<1000000) - { - j = 0; - while(j<2) - { - k = 0; - while(k<2) - { - o = 0; - while(o<2) - { - p = 0; - while(p<2) - { - q = 0; - while(q<2) - { - ret = (a*a*a*a*a*a*a*a*a*a)/a/a/a/a/a/a/a/a/a/a; - q=q+1; - } - p=p+1; - } - o=o+1; - } - k=k+1; - } - j=j+1; - } - i=i+1; - } - output(ret); - return ; -} \ No newline at end of file diff --git a/tests/4-opt/testcases/loop/loop-3.out b/tests/4-opt/testcases/loop/loop-3.out deleted file mode 100644 index b261da1..0000000 --- a/tests/4-opt/testcases/loop/loop-3.out +++ /dev/null @@ -1,2 +0,0 @@ -1 -0 diff --git a/tests/4-opt/testcases/loop/loop-4.cminus b/tests/4-opt/testcases/loop/loop-4.cminus deleted file mode 100644 index 287098a..0000000 --- a/tests/4-opt/testcases/loop/loop-4.cminus +++ /dev/null @@ -1,50 +0,0 @@ -void main(void){ - int i; - int j; - int k; - int o; - int p; - int q; - int a; - int ret; - - a = 2; - - i = 0; - while(i<1000000) - { - j = 0; - while(j<2) - { - k = 0; - while(k<2) - { - o = 0; - while(o<2) - { - p = 0; - while(p<2) - { - q = 0; - while(q<2) - { - if( a > 1 ) - { - j = j+1; - } - ret = (a*a*a*a*a*a*a*a*a*a)/a/a/a/a/a/a/a/a/a/a; - q=q+1; - } - p=p+1; - } - o=o+1; - } - k=k+1; - } - j=j+1; - } - i=i+1; - } - output(ret); - return ; -} \ No newline at end of file diff --git a/tests/4-opt/testcases/loop/loop-4.out b/tests/4-opt/testcases/loop/loop-4.out deleted file mode 100644 index b261da1..0000000 --- a/tests/4-opt/testcases/loop/loop-4.out +++ /dev/null @@ -1,2 +0,0 @@ -1 -0 diff --git a/tests/4-opt/testcases/mem2reg/baseline/mem2reg-1 b/tests/4-opt/testcases/mem2reg/baseline/mem2reg-1 deleted file mode 100755 index 60e63e1726a9637f28dca2ff7a88d79bc99ba30e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 34168 zcmeI5Z)_Ar6u@V%t+Yp_#a2r#wuiP*2)%>S#wJj_0+lvkA*Gl`CByY@+b;C>>fN3k zw8#OHpfsju8U)iSDuy0PB!om75lcu+;}@tO(D*Os7t5Lsq()F>za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Q4U>nef#gk8lV0Cj-D+)4HjK~L++C=SS@G8{#O@XU-;OVsd2w*h k4?|C`xE`Bxqh`TZN6+m2c>Uf#-xF6ZeyifsmGCkA4Q}^OasU7T diff --git a/tests/4-opt/testcases/mem2reg/baseline/mem2reg-1.ll b/tests/4-opt/testcases/mem2reg/baseline/mem2reg-1.ll deleted file mode 100644 index 00b6e15..0000000 --- a/tests/4-opt/testcases/mem2reg/baseline/mem2reg-1.ll +++ /dev/null @@ -1,54 +0,0 @@ -; ModuleID = 'cminus' -source_filename = "/home/zox/compiler/2024ustc-jianmu-compiler-ta/tests/4-mem2reg/performance-cases/testcase-1.cminus" - -declare i32 @input() - -declare void @output(i32) - -declare void @outputFloat(float) - -declare void @neg_idx_except() - -define void @main() { -label_entry: - %op0 = call i32 @input() - br label %label1 -label1: ; preds = %label_entry, %label7 - %op2 = phi i32 [ 0, %label_entry ], [ %op33, %label7 ] - %op3 = phi i32 [ 0, %label_entry ], [ %op32, %label7 ] - %op4 = icmp slt i32 %op2, %op0 - %op5 = zext i1 %op4 to i32 - %op6 = icmp ne i32 %op5, 0 - br i1 %op6, label %label7, label %label34 -label7: ; preds = %label1 - %op8 = fmul float 0x3ff3c0c200000000, 0x4016f06a20000000 - %op9 = fmul float %op8, 0x4002aa9940000000 - %op10 = fmul float %op9, 0x4011781d80000000 - %op11 = fmul float %op10, 0x401962ac40000000 - %op12 = fptosi float %op11 to i32 - %op13 = mul i32 %op12, %op12 - %op14 = mul i32 %op13, %op12 - %op15 = mul i32 %op14, %op12 - %op16 = mul i32 %op15, %op12 - %op17 = mul i32 %op16, %op12 - %op18 = mul i32 %op17, %op17 - %op19 = mul i32 %op18, %op17 - %op20 = mul i32 %op19, %op17 - %op21 = mul i32 %op20, %op17 - %op22 = mul i32 %op21, %op17 - %op23 = mul i32 %op22, %op22 - %op24 = mul i32 %op23, %op22 - %op25 = mul i32 %op24, %op22 - %op26 = mul i32 %op25, %op22 - %op27 = mul i32 %op26, %op22 - %op28 = mul i32 %op27, %op27 - %op29 = mul i32 %op28, %op27 - %op30 = mul i32 %op29, %op27 - %op31 = mul i32 %op30, %op27 - %op32 = mul i32 %op31, %op27 - %op33 = add i32 %op2, 1 - br label %label1 -label34: ; preds = %label1 - call void @output(i32 %op3) - ret void -} diff --git a/tests/4-opt/testcases/mem2reg/baseline/mem2reg-2 b/tests/4-opt/testcases/mem2reg/baseline/mem2reg-2 deleted file mode 100755 index 4a905ff6e89117910fab4c7a5bba89c800190b55..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16840 zcmeI3T}V@L6u|%cuo=!~F|5?!_JOPqKTsd+MX%LRQFF~vqZt3R-RW?fH7Cs&WgkLi zMNy=^6eVSZfru}AD1^YI!We`_MEJNp_z?BvgX^4o?{Lc~=rPWLbI-^Bp0o4+-Myao zON+}!#xx8>3z`QS2WOB8;4!utv;mZJTV1{NsMX$z*-Vj(GgGS~>=Os&++lS(GLPkY zF*C>1I1AFKI2#J*At@YEd?n88=d4vOV^d$jI8`gB^lU&qk`3p5fz#fAn|lME9?1MU z-&3`pQ!THy&)V9%xM6Ra7B^l|{9)Dm*ml9IF@`z;A&Zs=-vMaW%x{ z5aSG+Ku^LabU-2FZ`#3+TJIEU-f z&`{~S%2U^jHrHFXWk&_%1W@HpCh$zMuLDnKIHunPR=yut6bsxB`{4IV7yMnkKb|Rf zsE5CUW@Q$br>(y?B>7ACmBL)!4yC#n4EFC58OsK{Q;m@q$`(*OpAez9G9*MKM1Tko z0U|&IhyW2F0z`la5CI}U1c(3;AOb{y2oM1xKm>>Y5g-CYfCvx)B0vO)01+SpM1Tko z0U|&IhyW2F0z`la5CI}U1c(3;AOb{y2oM1xKm>>Y5g-CYfC&7L1d{t%%)$ojaTANe zda*fS5~B$Ni^gm3*&BMtf)-77cYN$YK_Z7mXBn%)cj5*ynw`bgW6h6ba^pgd7==E! zrgeNCSCorXQ0W$TqH$+h1dEFM=_sQ7TzTN$wGsBF^VE%OaIjPs0iNZmVj_JV8tZ;5 z8qPN00d~=`PiMj7{w^+sr4xN2iFZluZYjvt`rEw$mdoT9Qm>md%H}uzPClp!oYdaF z02}zL+ik&f|{{UmsrdyqVf|f46aA*fqM<@T}AK&2>Ka^7C`!lg^%*glAg+ zF&69AwmP$tk*Ua;!Ot&-8m{aa``dZ=$syOHCUbGoa@aTd&~oSX!jX~umYIup_c}^G pw6?`+JS~xe(V3Sw>_+qaT!gQ=Q2EMu)pC2jrf_`w+?Nr?egZF^(!>A& diff --git a/tests/4-opt/testcases/mem2reg/baseline/mem2reg-2.ll b/tests/4-opt/testcases/mem2reg/baseline/mem2reg-2.ll deleted file mode 100644 index 0fcadf5..0000000 --- a/tests/4-opt/testcases/mem2reg/baseline/mem2reg-2.ll +++ /dev/null @@ -1,26 +0,0 @@ -; ModuleID = 'cminus' -source_filename = "/home/zox/compiler/2024ustc-jianmu-compiler-ta/tests/4-mem2reg/performance-cases/testcase-2.cminus" - -declare i32 @input() - -declare void @output(i32) - -declare void @outputFloat(float) - -declare void @neg_idx_except() - -define i32 @main() { -label_entry: - br label %label0 -label0: ; preds = %label_entry, %label5 - %op1 = phi i32 [ 1, %label_entry ], [ %op6, %label5 ] - %op2 = icmp slt i32 %op1, 999999999 - %op3 = zext i1 %op2 to i32 - %op4 = icmp ne i32 %op3, 0 - br i1 %op4, label %label5, label %label7 -label5: ; preds = %label0 - %op6 = add i32 %op1, 1 - br label %label0 -label7: ; preds = %label0 - ret i32 %op1 -} diff --git a/tests/4-opt/testcases/mem2reg/baseline/mem2reg-3 b/tests/4-opt/testcases/mem2reg/baseline/mem2reg-3 deleted file mode 100755 index 477a8f55a2a2daf6bf8b2bb3b313aae93c139582..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 34360 zcmeI5Yiv}<701urHL!k!N9@)CH?TZo*Wiu7)TBmXT}*;W0u~R&rBN?y?=`;0yX)*D zSpqIg0}_xnjVoHx52UDx6r7i=s%pJb3T|oBD9{#EDXkky4NBErNUEw|icwt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jM@LO=)z0U;m+gn$qb0zyCt2mv7=1cZPP5CTF#2nYcoAOwVf5D)@FKnMr{ zAs_^VfDjM@LO=)zf&Uu;FJ@{**@eRQ7T8w=ph~!hB`16rfh|VekJ}ggc8h7J-~s^! zmo_N#t#(yQ>Tyzgqk1^rNouSk5boqIMWsji%@+<#qg3YjGR*yr{aio!I@e!I;_8GH zUr6B6!{m)e^&~BI(_kO^Ztllpc)#*MPb3hhwQjl)L&HT}NK&kZx-g~Ik%((*mlgIn}}0Ij~1r6p#at5_6JoDCNY+;eV~R&BF+PvqOb`>qk+BjNIV({$9f|% zjkaQfL&|0MsJnj68jjjv6m)>%yBUH;kNG%PpyNIo>V(y^2U>RX2sW+5qYU>)aD5&M z?%K)e+_nUz9)*SV%?15z@3-um(a-j_&g0qMjCRuA+0XV#%l=`@-qt_P-r3LggO)wV z$@AN~ZExS5!8*t9?053xG?=BBw_xzt&$2!PkNRI0vCe#Ep>jz%@VO!*_Z0B&%?=M~2YXvL04>(0)*p6Ok8`9#~bs*>#|zx}6IUwkh*GkfA6(*}m- zHkH?1|JgeS-@Y{XYDG)sOLLd~vp9R~%;+ci|6luScU^m5S6&)g`-_GvSGym0vGrGf VK0p1+&hp<)|K5Ag9$r6(=-=;@{F?v( diff --git a/tests/4-opt/testcases/mem2reg/baseline/mem2reg-3.ll b/tests/4-opt/testcases/mem2reg/baseline/mem2reg-3.ll deleted file mode 100644 index c92c71e..0000000 --- a/tests/4-opt/testcases/mem2reg/baseline/mem2reg-3.ll +++ /dev/null @@ -1,201 +0,0 @@ -; ModuleID = 'cminus' -source_filename = "/home/zox/compiler/2024ustc-jianmu-compiler-ta/tests/4-mem2reg/performance-cases/testcase-3.cminus" - -@matrix = global [20000000 x i32] zeroinitializer -@ad = global [100000 x i32] zeroinitializer -@len = global i32 zeroinitializer -declare i32 @input() - -declare void @output(i32) - -declare void @outputFloat(float) - -declare void @neg_idx_except() - -define void @readarray() { -label_entry: - br label %label0 -label0: ; preds = %label_entry, %label11 - %op1 = phi i32 [ 0, %label_entry ], [ %op13, %label11 ] - %op2 = load i32, i32* @len - %op3 = icmp slt i32 %op1, %op2 - %op4 = zext i1 %op3 to i32 - %op5 = icmp ne i32 %op4, 0 - br i1 %op5, label %label6, label %label9 -label6: ; preds = %label0 - %op7 = call i32 @input() - %op8 = icmp slt i32 %op1, 0 - br i1 %op8, label %label10, label %label11 -label9: ; preds = %label0 - ret void -label10: ; preds = %label6 - call void @neg_idx_except() - ret void -label11: ; preds = %label6 - %op12 = getelementptr [100000 x i32], [100000 x i32]* @ad, i32 0, i32 %op1 - store i32 %op7, i32* %op12 - %op13 = add i32 %op1, 1 - br label %label0 -} -define i32 @transpose(i32 %arg0, i32* %arg1, i32 %arg2) { -label_entry: - %op3 = sdiv i32 %arg0, %arg2 - br label %label4 -label4: ; preds = %label_entry, %label21 - %op5 = phi i32 [ 0, %label_entry ], [ %op22, %label21 ] - %op6 = icmp slt i32 %op5, %op3 - %op7 = zext i1 %op6 to i32 - %op8 = icmp ne i32 %op7, 0 - br i1 %op8, label %label9, label %label10 -label9: ; preds = %label4 - br label %label12 -label10: ; preds = %label4 - %op11 = sub i32 0, 1 - ret i32 %op11 -label12: ; preds = %label9, %label25 - %op13 = phi i32 [ 0, %label9 ], [ %op26, %label25 ] - %op14 = icmp slt i32 %op13, %arg2 - %op15 = zext i1 %op14 to i32 - %op16 = icmp ne i32 %op15, 0 - br i1 %op16, label %label17, label %label21 -label17: ; preds = %label12 - %op18 = icmp slt i32 %op5, %op13 - %op19 = zext i1 %op18 to i32 - %op20 = icmp ne i32 %op19, 0 - br i1 %op20, label %label23, label %label27 -label21: ; preds = %label12 - %op22 = add i32 %op5, 1 - br label %label4 -label23: ; preds = %label17 - %op24 = add i32 %op13, 1 - br label %label25 -label25: ; preds = %label23, %label52 - %op26 = phi i32 [ %op24, %label23 ], [ %op54, %label52 ] - br label %label12 -label27: ; preds = %label17 - %op28 = mul i32 %op5, %arg2 - %op29 = add i32 %op28, %op13 - %op30 = icmp slt i32 %op29, 0 - br i1 %op30, label %label31, label %label32 -label31: ; preds = %label27 - call void @neg_idx_except() - ret i32 0 -label32: ; preds = %label27 - %op33 = getelementptr i32, i32* %arg1, i32 %op29 - %op34 = load i32, i32* %op33 - %op35 = mul i32 %op5, %arg2 - %op36 = add i32 %op35, %op13 - %op37 = icmp slt i32 %op36, 0 - br i1 %op37, label %label38, label %label39 -label38: ; preds = %label32 - call void @neg_idx_except() - ret i32 0 -label39: ; preds = %label32 - %op40 = getelementptr i32, i32* %arg1, i32 %op36 - %op41 = load i32, i32* %op40 - %op42 = mul i32 %op13, %op3 - %op43 = add i32 %op42, %op5 - %op44 = icmp slt i32 %op43, 0 - br i1 %op44, label %label45, label %label46 -label45: ; preds = %label39 - call void @neg_idx_except() - ret i32 0 -label46: ; preds = %label39 - %op47 = getelementptr i32, i32* %arg1, i32 %op43 - store i32 %op41, i32* %op47 - %op48 = mul i32 %op5, %arg2 - %op49 = add i32 %op48, %op13 - %op50 = icmp slt i32 %op49, 0 - br i1 %op50, label %label51, label %label52 -label51: ; preds = %label46 - call void @neg_idx_except() - ret i32 0 -label52: ; preds = %label46 - %op53 = getelementptr i32, i32* %arg1, i32 %op49 - store i32 %op34, i32* %op53 - %op54 = add i32 %op13, 1 - br label %label25 -} -define i32 @main() { -label_entry: - %op0 = call i32 @input() - %op1 = call i32 @input() - store i32 %op1, i32* @len - call void @readarray() - br label %label2 -label2: ; preds = %label_entry, %label11 - %op3 = phi i32 [ 0, %label_entry ], [ %op13, %label11 ] - %op4 = icmp slt i32 %op3, %op0 - %op5 = zext i1 %op4 to i32 - %op6 = icmp ne i32 %op5, 0 - br i1 %op6, label %label7, label %label9 -label7: ; preds = %label2 - %op8 = icmp slt i32 %op3, 0 - br i1 %op8, label %label10, label %label11 -label9: ; preds = %label2 - br label %label14 -label10: ; preds = %label7 - call void @neg_idx_except() - ret i32 0 -label11: ; preds = %label7 - %op12 = getelementptr [20000000 x i32], [20000000 x i32]* @matrix, i32 0, i32 %op3 - store i32 %op3, i32* %op12 - %op13 = add i32 %op3, 1 - br label %label2 -label14: ; preds = %label9, %label25 - %op15 = phi i32 [ 0, %label9 ], [ %op29, %label25 ] - %op16 = load i32, i32* @len - %op17 = icmp slt i32 %op15, %op16 - %op18 = zext i1 %op17 to i32 - %op19 = icmp ne i32 %op18, 0 - br i1 %op19, label %label20, label %label23 -label20: ; preds = %label14 - %op21 = getelementptr [20000000 x i32], [20000000 x i32]* @matrix, i32 0, i32 0 - %op22 = icmp slt i32 %op15, 0 - br i1 %op22, label %label24, label %label25 -label23: ; preds = %label14 - br label %label30 -label24: ; preds = %label20 - call void @neg_idx_except() - ret i32 0 -label25: ; preds = %label20 - %op26 = getelementptr [100000 x i32], [100000 x i32]* @ad, i32 0, i32 %op15 - %op27 = load i32, i32* %op26 - %op28 = call i32 @transpose(i32 %op0, i32* %op21, i32 %op27) - %op29 = add i32 %op15, 1 - br label %label14 -label30: ; preds = %label23, %label45 - %op31 = phi i32 [ 0, %label23 ], [ %op49, %label45 ] - %op32 = phi i32 [ 0, %label23 ], [ %op50, %label45 ] - %op33 = load i32, i32* @len - %op34 = icmp slt i32 %op32, %op33 - %op35 = zext i1 %op34 to i32 - %op36 = icmp ne i32 %op35, 0 - br i1 %op36, label %label37, label %label40 -label37: ; preds = %label30 - %op38 = mul i32 %op32, %op32 - %op39 = icmp slt i32 %op32, 0 - br i1 %op39, label %label44, label %label45 -label40: ; preds = %label30 - %op41 = icmp slt i32 %op31, 0 - %op42 = zext i1 %op41 to i32 - %op43 = icmp ne i32 %op42, 0 - br i1 %op43, label %label51, label %label53 -label44: ; preds = %label37 - call void @neg_idx_except() - ret i32 0 -label45: ; preds = %label37 - %op46 = getelementptr [20000000 x i32], [20000000 x i32]* @matrix, i32 0, i32 %op32 - %op47 = load i32, i32* %op46 - %op48 = mul i32 %op38, %op47 - %op49 = add i32 %op31, %op48 - %op50 = add i32 %op32, 1 - br label %label30 -label51: ; preds = %label40 - %op52 = sub i32 0, %op31 - br label %label53 -label53: ; preds = %label40, %label51 - %op54 = phi i32 [ %op31, %label40 ], [ %op52, %label51 ] - call void @output(i32 %op54) - ret i32 0 -} diff --git a/tests/4-opt/testcases/mem2reg/mem2reg-1 b/tests/4-opt/testcases/mem2reg/mem2reg-1 deleted file mode 100755 index ce0bb68c231d0534080201a8f6809d8aedc6194b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 34168 zcmeI5Z){XW5Wx3cTl$B}6$``E~G(@Gw7_KBHM1u3?_x3*S-e*^TzLv?D#6V1-vq3wO8QaAy&|+*JXe}t`YpPb)tgmToz}|Qf z!SP+!S(xV=aOAwHrnxD8Sj5}o`0#q0J7J3e2VmTx0EgP@(5Lmg2|&gC}l_B%YXZpY^v(ehPjL1-r#63m1t z45m0A`=EpKl~qkuyt<)&t@?HC+M$A4NJ5P{QSmcnfpXsJGkn&Y=9>$?LhSMDngN~0 zbxxhzN9yVyu31^9pSeiFy1+&W;~@jV^=L;&*yW5xaD8}c!cg6#*-$}H%xfZ{o`g#vzCyV7EFZEbgfje>b` z9qV>o{%OPP<(Ky#9saZW(WO6>L7xRw-IEzwX3-Y>Q=dp)3O!CRE+OrY@ZRl z7^Q*;5CI}U1c(3;AOb{y2oM1xKm>>Y5g-CYfCvx)B0vO)01+SpM1Tko0U|&IhyW2F z0z`la5CI}U1c(3;AOb{y2oM1xKm>>Y5g-CYfCvx)B0vO)01+Spe@|fIG#ia|nFbzW ztZyup4NVk)=7G*+LvVF5Ct6@18c($krAg_Vqeotw-ywr zt>Ay?G(QpRsu}>_>tYU_E;um&;r{ZE=9}dLO2iH_w*$a1X```*}BYd|$xR*MZWwKvkrh>DgJ;Tt>P}_wr zR_MxLh3*XIm0KM_t@2u+Z<4oQi(}9>Q&-ov|)Whq|Qbrh4ZDX%mQYC9=xwx8=DXUF{;$gDm^G2 zP!oxstcW_47125)nkQ96fCvx)B0vO)01+SpM1Tko0U|&IhyW2F0z`la5CI}U1c(3; zAOb{y2oM1xKm>>Y5g-CYfCvx)B0vO)01+SpM1Tko0U|&IhyW2F0z`la5CI}U1c(3; zAOb{y2oM1xKm>@u|3tt7^Q-~g2#W6v=+6W|lZnR#umOT^3Fso)c6cqpuJ@>M5Kri^rjO*&KL$fh(>sIN_@cEY}wb;^@L- zor9+GiVCqOmtkWYU|RjZ({UO56YRrayCLeu?RBj7xQ7faUA1EwD{#(yl&qt-Z+l&4BnT(>P{_QxAl1a zZ3?t;e&e{2AAUBoq`o?VZpgz74V@4EuRGfKwgrykd}!_N&4{TgJ&TDL27{9^U;p*Ap;_UE*v%|Hsqt)seyx}pntqaKhfNj&(O#$0V zpEKl4N@oi@d1V~Wq}WdAZp zOGs&V+1iyBr$_OI0vvKV7GpxIZwVlnl&jxo4go$pBU<-^l zYeDIZ?Hse1;JJ~1B+@0#P4dW|GQZqfayOfC<~MKheV5x_-ICw%M$e~}Znn4M*`~ce z&YkmR`6~Nv^YQJ+-fs4NGVUHu{(5wDv#FsuWup6??#^B3-rrOEeDRU##*;5za~7R1 zetco^;lWG&dCeEzT6X*;`yOw}dvlA5f=%!GXN|w|OUl5Bc~#lgiyxhNW@L2mXii=3 z>+_0!Pal8bgR$xI|JU)*sb%w@b9aBf?Ea5!U*&yq@2WZbf3>8Y@6TO-&V2Af#dnPT E1q*I{^Z)<= diff --git a/tests/4-opt/testcases/mem2reg/mem2reg-1.cminus b/tests/4-opt/testcases/mem2reg/mem2reg-1.cminus deleted file mode 100644 index 93d726f..0000000 --- a/tests/4-opt/testcases/mem2reg/mem2reg-1.cminus +++ /dev/null @@ -1,23 +0,0 @@ -void main(void) { - int c; - int a; - int b; - int d; - int f; - int g; - int loopCnt; - loopCnt = input(); - c = 0; - a = 0; - g = 0; - while (c < loopCnt) { - a = 1.23456 * 5.73478 * 2.3333 * 4.3673 * 6.34636; - b = a * a * a * a * a * a; - d = b * b * b * b * b * b; - f = d * d * d * d * d * d; - g = f * f * f * f * f * f; - c = c + 1; - } - output(g); - return; -} \ No newline at end of file diff --git a/tests/4-opt/testcases/mem2reg/mem2reg-1.in b/tests/4-opt/testcases/mem2reg/mem2reg-1.in deleted file mode 100644 index ea600cb..0000000 --- a/tests/4-opt/testcases/mem2reg/mem2reg-1.in +++ /dev/null @@ -1 +0,0 @@ -100000000 diff --git a/tests/4-opt/testcases/mem2reg/mem2reg-1.out b/tests/4-opt/testcases/mem2reg/mem2reg-1.out deleted file mode 100644 index f422395..0000000 --- a/tests/4-opt/testcases/mem2reg/mem2reg-1.out +++ /dev/null @@ -1,2 +0,0 @@ -711082625 -0 diff --git a/tests/4-opt/testcases/mem2reg/mem2reg-2 b/tests/4-opt/testcases/mem2reg/mem2reg-2 deleted file mode 100755 index a3e30a3b90c21e6680b087bc7d9fa0d26656e7c5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16840 zcmeI4Ur3Wt6u|GdO;a*wA(ff&J(!r~AJhjQDnHBNMxmlc9~InO`=&!TWt*iXC6ZJG zk&=W@QV=Fgkm$ug+LIYZA<`dw5TOTW&{HHS(K_e*!?uiq9^)K1_ndR@J!j|sw%4;a z8=rrqF(xn&6KDo#1e^gTg2z}Es2!B^`l=e+8Cydg?k0+woVc|q!a5O9&YNs4oM;?{6<)DSHNG~?r|2odfHtOqhy0(A9FKn z>!*^B+_@Pz`q5rpvQ`RvBB=HzD|lAbH-l&1a@JA+R(&5>lzey}*1_*9Uhs4A{dlIm zp$2{qLaZ0)r?DpxRJ=vUil8r#Q_Ic+gY{b_#!|o@&|~CX{nuLgi2oM1x zKm>>Y5g-CYfCvx)B0vO)01+SpM1Tko0U|&IhyW2F0z`la5CI}U1c(3;AOb{y2oM1x zKm>>Y5g-CYfCvx)B0vO)01+SpM1Tko0U|&IhyW2F0z`la5P|=hK=e49&u4uN5i6U5 zG2_gLRhn9@9BFU_#{4NlYFlJ%bk8hf<;Gb`65Eb<*P_u~%WxO+2g7Fm4o8&t>Y(B+ z&P3zPv;-Cv=hIOnb&V}Jcbx`v(;50iHaM87i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em2reg/mem2reg-3.cminus deleted file mode 100644 index 0aff64f..0000000 --- a/tests/4-opt/testcases/mem2reg/mem2reg-3.cminus +++ /dev/null @@ -1,70 +0,0 @@ -int matrix[20000000]; -int ad[100000]; - -int len; - -void readarray(void) { - int cnt; - cnt = 0; - while (cnt < len) { - ad[cnt] = input(); - cnt = cnt + 1; - } -} - -int transpose(int n, int matrix[], int rowsize) { - int colsize; - int i; - int j; - int curr; - colsize = n / rowsize; - i = 0; - j = 0; - while (i < colsize) { - j = 0; - while (j < rowsize) { - if (i < j) { - j = j + 1; - } else { - curr = matrix[i * rowsize + j]; - matrix[j * colsize + i] = matrix[i * rowsize + j]; - matrix[i * rowsize + j] = curr; - j = j + 1; - } - } - i = i + 1; - } - return 0 - 1; -} - -int main(void) { - int n; - int i; - int ans; - n = input(); - len = input(); - readarray(); - i = 0; - - while (i < n) { - matrix[i] = i; - i = i + 1; - } - i = 0; - while (i < len) { - transpose(n, matrix, ad[i]); - i = i + 1; - } - - ans = 0; - i = 0; - while (i < len) { - ans = ans + i * i * matrix[i]; - i = i + 1; - } - if (ans < 0) { - ans = 0 - ans; - } - output(ans); - return 0; -} diff --git a/tests/4-opt/testcases/mem2reg/mem2reg-3.in b/tests/4-opt/testcases/mem2reg/mem2reg-3.in deleted file mode 100644 index f37548b..0000000 --- a/tests/4-opt/testcases/mem2reg/mem2reg-3.in +++ /dev/null @@ -1,32 +0,0 @@ -10000000 -30 -2 -5 -4 -25 -8 -125 -16 -625 -32 -3125 -2 -5 -4 -25 -8 -125 -16 -625 -32 -3125 -2 -5 -4 -25 -8 -125 -16 -625 -32 -3125 diff --git a/tests/4-opt/testcases/mem2reg/mem2reg-3.out b/tests/4-opt/testcases/mem2reg/mem2reg-3.out deleted file mode 100644 index 72f8a54..0000000 --- a/tests/4-opt/testcases/mem2reg/mem2reg-3.out +++ /dev/null @@ -1,2 +0,0 @@ -1042523985 -0 -- GitLab