Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
2
2025ustc-jianmu-compiler
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
43
Merge Requests
43
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
compiler_staff
2025ustc-jianmu-compiler
Commits
022e0742
Commit
022e0742
authored
Dec 03, 2025
by
Yang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add testcases
parent
f40efe88
Changes
85
Show whitespace changes
Inline
Side-by-side
Showing
85 changed files
with
1775 additions
and
1516 deletions
+1775
-1516
tests/4-opt/.gitignore
tests/4-opt/.gitignore
+4
-1
tests/4-opt/cleanup.sh
tests/4-opt/cleanup.sh
+0
-2
tests/4-opt/eval_lab4.sh
tests/4-opt/eval_lab4.sh
+0
-127
tests/4-opt/test_perf.sh
tests/4-opt/test_perf.sh
+0
-107
tests/4-opt/testcases/0_lab2_lv0_1.cminus
tests/4-opt/testcases/0_lab2_lv0_1.cminus
+11
-0
tests/4-opt/testcases/0_lab2_lv0_1.in
tests/4-opt/testcases/0_lab2_lv0_1.in
+1
-0
tests/4-opt/testcases/0_lab2_lv0_1.out
tests/4-opt/testcases/0_lab2_lv0_1.out
+3
-0
tests/4-opt/testcases/1_lab2_lv0_2.cminus
tests/4-opt/testcases/1_lab2_lv0_2.cminus
+75
-0
tests/4-opt/testcases/1_lab2_lv0_2.out
tests/4-opt/testcases/1_lab2_lv0_2.out
+72
-0
tests/4-opt/testcases/2_lab2_lv1.cminus
tests/4-opt/testcases/2_lab2_lv1.cminus
+100
-0
tests/4-opt/testcases/2_lab2_lv1.in
tests/4-opt/testcases/2_lab2_lv1.in
+1
-0
tests/4-opt/testcases/2_lab2_lv1.out
tests/4-opt/testcases/2_lab2_lv1.out
+46
-0
tests/4-opt/testcases/2_lab2_lv2.cminus
tests/4-opt/testcases/2_lab2_lv2.cminus
+116
-0
tests/4-opt/testcases/2_lab2_lv2.out
tests/4-opt/testcases/2_lab2_lv2.out
+17
-0
tests/4-opt/testcases/3_complex1.cminus
tests/4-opt/testcases/3_complex1.cminus
+77
-0
tests/4-opt/testcases/3_complex1.out
tests/4-opt/testcases/3_complex1.out
+801
-0
tests/4-opt/testcases/4_complex2.cminus
tests/4-opt/testcases/4_complex2.cminus
+59
-0
tests/4-opt/testcases/4_complex2.in
tests/4-opt/testcases/4_complex2.in
+10
-0
tests/4-opt/testcases/4_complex2.out
tests/4-opt/testcases/4_complex2.out
+0
-0
tests/4-opt/testcases/5_complex3.cminus
tests/4-opt/testcases/5_complex3.cminus
+25
-0
tests/4-opt/testcases/5_complex3.in
tests/4-opt/testcases/5_complex3.in
+2
-0
tests/4-opt/testcases/5_complex3.out
tests/4-opt/testcases/5_complex3.out
+2
-0
tests/4-opt/testcases/6_complex4.cminus
tests/4-opt/testcases/6_complex4.cminus
+122
-0
tests/4-opt/testcases/6_complex4.out
tests/4-opt/testcases/6_complex4.out
+4
-0
tests/4-opt/testcases/7_return_early.cminus
tests/4-opt/testcases/7_return_early.cminus
+44
-0
tests/4-opt/testcases/7_return_early.in
tests/4-opt/testcases/7_return_early.in
+1
-0
tests/4-opt/testcases/7_return_early.out
tests/4-opt/testcases/7_return_early.out
+1
-0
tests/4-opt/testcases/8_licm0.cminus
tests/4-opt/testcases/8_licm0.cminus
+104
-0
tests/4-opt/testcases/8_licm0.in
tests/4-opt/testcases/8_licm0.in
+4
-0
tests/4-opt/testcases/8_licm0.out
tests/4-opt/testcases/8_licm0.out
+45
-0
tests/4-opt/testcases/9_licm_bad.cminus
tests/4-opt/testcases/9_licm_bad.cminus
+27
-0
tests/4-opt/testcases/9_licm_bad.out
tests/4-opt/testcases/9_licm_bad.out
+1
-1
tests/4-opt/testcases/functional-cases/0-io.cminus
tests/4-opt/testcases/functional-cases/0-io.cminus
+0
-4
tests/4-opt/testcases/functional-cases/0-io.in
tests/4-opt/testcases/functional-cases/0-io.in
+0
-1
tests/4-opt/testcases/functional-cases/1-return.cminus
tests/4-opt/testcases/functional-cases/1-return.cminus
+0
-4
tests/4-opt/testcases/functional-cases/1-return.out
tests/4-opt/testcases/functional-cases/1-return.out
+0
-2
tests/4-opt/testcases/functional-cases/10-float.cminus
tests/4-opt/testcases/functional-cases/10-float.cminus
+0
-19
tests/4-opt/testcases/functional-cases/10-float.out
tests/4-opt/testcases/functional-cases/10-float.out
+0
-2
tests/4-opt/testcases/functional-cases/11-floatcall.cminus
tests/4-opt/testcases/functional-cases/11-floatcall.cminus
+0
-18
tests/4-opt/testcases/functional-cases/11-floatcall.out
tests/4-opt/testcases/functional-cases/11-floatcall.out
+0
-2
tests/4-opt/testcases/functional-cases/12-global.cminus
tests/4-opt/testcases/functional-cases/12-global.cminus
+0
-47
tests/4-opt/testcases/functional-cases/12-global.out
tests/4-opt/testcases/functional-cases/12-global.out
+0
-21
tests/4-opt/testcases/functional-cases/13-complex.cminus
tests/4-opt/testcases/functional-cases/13-complex.cminus
+0
-67
tests/4-opt/testcases/functional-cases/13-complex.out
tests/4-opt/testcases/functional-cases/13-complex.out
+0
-2
tests/4-opt/testcases/functional-cases/2-calculate.cminus
tests/4-opt/testcases/functional-cases/2-calculate.cminus
+0
-11
tests/4-opt/testcases/functional-cases/2-calculate.out
tests/4-opt/testcases/functional-cases/2-calculate.out
+0
-1
tests/4-opt/testcases/functional-cases/3-output.cminus
tests/4-opt/testcases/functional-cases/3-output.cminus
+0
-5
tests/4-opt/testcases/functional-cases/3-output.out
tests/4-opt/testcases/functional-cases/3-output.out
+0
-3
tests/4-opt/testcases/functional-cases/4-if.cminus
tests/4-opt/testcases/functional-cases/4-if.cminus
+0
-23
tests/4-opt/testcases/functional-cases/5-while.cminus
tests/4-opt/testcases/functional-cases/5-while.cminus
+0
-14
tests/4-opt/testcases/functional-cases/6-array.cminus
tests/4-opt/testcases/functional-cases/6-array.cminus
+0
-15
tests/4-opt/testcases/functional-cases/6-array.out
tests/4-opt/testcases/functional-cases/6-array.out
+0
-4
tests/4-opt/testcases/functional-cases/7-function.cminus
tests/4-opt/testcases/functional-cases/7-function.cminus
+0
-21
tests/4-opt/testcases/functional-cases/7-function.out
tests/4-opt/testcases/functional-cases/7-function.out
+0
-4
tests/4-opt/testcases/functional-cases/8-store.cminus
tests/4-opt/testcases/functional-cases/8-store.cminus
+0
-26
tests/4-opt/testcases/functional-cases/8-store.out
tests/4-opt/testcases/functional-cases/8-store.out
+0
-2
tests/4-opt/testcases/functional-cases/9-fibonacci.cminus
tests/4-opt/testcases/functional-cases/9-fibonacci.cminus
+0
-23
tests/4-opt/testcases/loop/baseline/loop-1.ll
tests/4-opt/testcases/loop/baseline/loop-1.ll
+0
-60
tests/4-opt/testcases/loop/baseline/loop-2.ll
tests/4-opt/testcases/loop/baseline/loop-2.ll
+0
-60
tests/4-opt/testcases/loop/baseline/loop-3.ll
tests/4-opt/testcases/loop/baseline/loop-3.ll
+0
-119
tests/4-opt/testcases/loop/baseline/loop-4.ll
tests/4-opt/testcases/loop/baseline/loop-4.ll
+0
-132
tests/4-opt/testcases/loop/loop-1.cminus
tests/4-opt/testcases/loop/loop-1.cminus
+0
-20
tests/4-opt/testcases/loop/loop-2.cminus
tests/4-opt/testcases/loop/loop-2.cminus
+0
-23
tests/4-opt/testcases/loop/loop-2.out
tests/4-opt/testcases/loop/loop-2.out
+0
-2
tests/4-opt/testcases/loop/loop-3.cminus
tests/4-opt/testcases/loop/loop-3.cminus
+0
-46
tests/4-opt/testcases/loop/loop-3.out
tests/4-opt/testcases/loop/loop-3.out
+0
-2
tests/4-opt/testcases/loop/loop-4.cminus
tests/4-opt/testcases/loop/loop-4.cminus
+0
-50
tests/4-opt/testcases/loop/loop-4.out
tests/4-opt/testcases/loop/loop-4.out
+0
-2
tests/4-opt/testcases/mem2reg/baseline/mem2reg-1
tests/4-opt/testcases/mem2reg/baseline/mem2reg-1
+0
-0
tests/4-opt/testcases/mem2reg/baseline/mem2reg-1.ll
tests/4-opt/testcases/mem2reg/baseline/mem2reg-1.ll
+0
-54
tests/4-opt/testcases/mem2reg/baseline/mem2reg-2
tests/4-opt/testcases/mem2reg/baseline/mem2reg-2
+0
-0
tests/4-opt/testcases/mem2reg/baseline/mem2reg-2.ll
tests/4-opt/testcases/mem2reg/baseline/mem2reg-2.ll
+0
-26
tests/4-opt/testcases/mem2reg/baseline/mem2reg-3
tests/4-opt/testcases/mem2reg/baseline/mem2reg-3
+0
-0
tests/4-opt/testcases/mem2reg/baseline/mem2reg-3.ll
tests/4-opt/testcases/mem2reg/baseline/mem2reg-3.ll
+0
-201
tests/4-opt/testcases/mem2reg/mem2reg-1
tests/4-opt/testcases/mem2reg/mem2reg-1
+0
-0
tests/4-opt/testcases/mem2reg/mem2reg-1.cminus
tests/4-opt/testcases/mem2reg/mem2reg-1.cminus
+0
-23
tests/4-opt/testcases/mem2reg/mem2reg-1.in
tests/4-opt/testcases/mem2reg/mem2reg-1.in
+0
-1
tests/4-opt/testcases/mem2reg/mem2reg-1.out
tests/4-opt/testcases/mem2reg/mem2reg-1.out
+0
-2
tests/4-opt/testcases/mem2reg/mem2reg-2
tests/4-opt/testcases/mem2reg/mem2reg-2
+0
-0
tests/4-opt/testcases/mem2reg/mem2reg-2.cminus
tests/4-opt/testcases/mem2reg/mem2reg-2.cminus
+0
-9
tests/4-opt/testcases/mem2reg/mem2reg-2.out
tests/4-opt/testcases/mem2reg/mem2reg-2.out
+0
-1
tests/4-opt/testcases/mem2reg/mem2reg-3
tests/4-opt/testcases/mem2reg/mem2reg-3
+0
-0
tests/4-opt/testcases/mem2reg/mem2reg-3.cminus
tests/4-opt/testcases/mem2reg/mem2reg-3.cminus
+0
-70
tests/4-opt/testcases/mem2reg/mem2reg-3.in
tests/4-opt/testcases/mem2reg/mem2reg-3.in
+0
-32
tests/4-opt/testcases/mem2reg/mem2reg-3.out
tests/4-opt/testcases/mem2reg/mem2reg-3.out
+0
-2
No files found.
tests/4-opt/.gitignore
View file @
022e0742
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
tests/4-opt/cleanup.sh
deleted
100755 → 0
View file @
f40efe88
#!/bin/bash
rm
-rf
output log.txt
tests/4-opt/eval_lab4.sh
deleted
100755 → 0
View file @
f40efe88
#!/bin/bash
project_dir
=
$(
realpath
../../
)
io_dir
=
$(
realpath
"
$project_dir
"
/src/io
)
output_dir
=
output
suffix
=
cminus
LOG
=
log.txt
usage
()
{
cat
<<
JIANMU
Usage:
$0
[test-stage] [path-to-testcases] [type]
test-stage: 'licm' or 'mem2reg'
path-to-testcases: './testcases/functional-cases' or '../testcases_general' or 'self made cases'
type: 'debug' or 'test', debug will output .ll file
JIANMU
exit
0
}
check_return_value
()
{
rv
=
$1
expected_rv
=
$2
fail_msg
=
$3
detail
=
$4
if
[
"
$rv
"
-eq
"
$expected_rv
"
]
;
then
return
0
else
printf
"
\0
33[1;31m%s:
\0
33[0m%s
\n
"
"
$fail_msg
"
"
$detail
"
return
1
fi
}
# check arguments
[
$#
-lt
3
]
&&
usage
if
[
"
$3
"
==
"debug"
]
;
then
debug_mode
=
true
elif
[
"
$3
"
==
"test"
]
;
then
debug_mode
=
false
else
usage
fi
if
[
"
$1
"
==
"licm"
]
;
then
licm
=
true
flag
=
"-mem2reg -licm"
elif
[
"
$1
"
==
"mem2reg"
]
;
then
licm
=
false
flag
=
"-mem2reg"
else
usage
fi
test_dir
=
$2
testcases
=
$(
ls
"
$test_dir
"
/
*
.
"
$suffix
"
|
sort
-V
)
check_return_value
$?
0
"PATH"
"unable to access to '
$test_dir
'"
||
exit
1
# hide stderr in the script
# exec 2>/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/
\x
00*
$/
/"
"
$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
"
\0
33[1;32mOK
\0
33[0m
\n
"
done
tests/4-opt/test_perf.sh
deleted
100755 → 0
View file @
f40efe88
#!/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
"
\0
33[1;31m%s:
\0
33[0m%s
\n
"
"
$fail_msg
"
"
$detail
"
return
1
fi
}
usage
()
{
cat
<<
JIANMU
Usage:
$0
[test-type]
test-type: 'licm' or 'mem2reg'
JIANMU
exit
0
}
[
$#
-lt
1
]
&&
usage
if
[
"
$1
"
==
"licm"
]
;
then
licm
=
true
nflag
=
"-mem2reg"
flag
=
"-mem2reg -licm"
elif
[
"
$1
"
==
"mem2reg"
]
;
then
licm
=
false
nflag
=
""
flag
=
"-mem2reg"
else
usage
fi
if
[
$licm
=
true
]
;
then
test_dir
=
./testcases/loop
else
test_dir
=
./testcases/mem2reg
fi
testcases
=
$(
ls
"
$test_dir
"
/
*
.
"
$suffix
"
|
sort
-V
)
check_return_value
$?
0
"PATH"
"unable to access to '
$test_dir
'"
||
exit
1
# hide stderr in the script
# exec 2>/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
tests/4-opt/testcases/0_lab2_lv0_1.cminus
0 → 100644
View file @
022e0742
void main(void)
{
float a[10];
float b;
int c[10];
int d;
input();
outputFloat(123.4);
output(1234);
return;
}
tests/4-opt/testcases/0_lab2_lv0_1.in
0 → 100644
View file @
022e0742
4
tests/4-opt/testcases/
functional-cases/0-io
.out
→
tests/4-opt/testcases/
0_lab2_lv0_1
.out
View file @
022e0742
123.400002
1234
0
tests/4-opt/testcases/1_lab2_lv0_2.cminus
0 → 100644
View file @
022e0742
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;
}
tests/4-opt/testcases/1_lab2_lv0_2.out
0 → 100644
View file @
022e0742
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
tests/4-opt/testcases/2_lab2_lv1.cminus
0 → 100644
View file @
022e0742
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;
}
tests/4-opt/testcases/2_lab2_lv1.in
0 → 100644
View file @
022e0742
9
tests/4-opt/testcases/2_lab2_lv1.out
0 → 100644
View file @
022e0742
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
tests/4-opt/testcases/2_lab2_lv2.cminus
0 → 100644
View file @
022e0742
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;
}
tests/4-opt/testcases/2_lab2_lv2.out
0 → 100644
View file @
022e0742
0
3
3
3
1024
1024
1234
3
10
10
4.000000
10
0
0
233
7.000000
0
tests/4-opt/testcases/3_complex1.cminus
0 → 100644
View file @
022e0742
/*
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;
}
tests/4-opt/testcases/3_complex1.out
0 → 100644
View file @
022e0742
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
1
0
4
5
4
3
2
6
6
4
8
2
1
3
3
9
3
6
0
7
2
6
0
2
4
9
1
4
1
2
7
3
7
2
4
5
8
7
0
0
6
6
0
6
3
1
5
5
8
8
1
7
4
8
8
1
5
2
0
9
2
0
9
6
2
8
2
9
2
5
4
0
9
1
7
1
5
3
6
4
3
6
7
8
9
2
5
9
0
3
6
0
0
1
1
3
3
0
5
3
0
5
4
8
8
2
0
4
6
6
5
2
1
3
8
4
1
4
6
9
5
1
9
4
1
5
1
1
6
0
9
4
3
3
0
5
7
2
7
0
3
6
5
7
5
9
5
9
1
9
5
3
0
9
2
1
8
6
1
1
7
3
8
1
9
3
2
6
1
1
7
9
3
1
0
5
1
1
8
5
4
8
0
7
4
4
6
2
3
7
9
9
6
2
7
4
9
5
6
7
3
5
1
8
8
5
7
5
2
7
2
4
8
9
1
2
2
7
9
3
8
1
8
3
0
1
1
9
4
9
1
2
9
8
3
3
6
7
3
3
6
2
4
4
0
6
5
6
6
4
3
0
8
6
0
2
1
3
9
4
9
4
6
3
9
5
2
2
4
7
3
7
1
9
0
7
0
2
1
7
9
8
6
0
9
4
3
7
0
2
7
7
0
5
3
9
2
1
7
1
7
6
2
9
3
1
7
6
7
5
2
3
8
4
6
7
4
8
1
8
4
6
7
6
6
9
4
0
5
1
3
2
0
0
0
5
6
8
1
2
7
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
tests/4-opt/testcases/4_complex2.cminus
0 → 100755
View file @
022e0742
/* 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;
}
tests/4-opt/testcases/
functional-cases/9-fibonacci.out
→
tests/4-opt/testcases/
4_complex2.in
100644 → 100755
View file @
022e0742
0
1
1
2
3
5
9
8
13
21
34
7
6
5
4
3
2
1
0
tests/4-opt/testcases/
functional-cases/5-while
.out
→
tests/4-opt/testcases/
4_complex2
.out
100644 → 100755
View file @
022e0742
File moved
tests/4-opt/testcases/5_complex3.cminus
0 → 100755
View file @
022e0742
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;
}
tests/4-opt/testcases/5_complex3.in
0 → 100755
View file @
022e0742
78
117
tests/4-opt/testcases/
functional-cases/4-if
.out
→
tests/4-opt/testcases/
5_complex3
.out
100644 → 100755
View file @
022e0742
3
3
3
9
0
tests/4-opt/testcases/6_complex4.cminus
0 → 100755
View file @
022e0742
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;
}
}
tests/4-opt/testcases/6_complex4.out
0 → 100755
View file @
022e0742
1.000000
-0.200000
0.400000
0
tests/4-opt/testcases/7_return_early.cminus
0 → 100644
View file @
022e0742
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;
}
tests/4-opt/testcases/7_return_early.in
0 → 100644
View file @
022e0742
3
tests/4-opt/testcases/7_return_early.out
0 → 100644
View file @
022e0742
2
tests/4-opt/testcases/8_licm0.cminus
0 → 100644
View file @
022e0742
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;
}
tests/4-opt/testcases/8_licm0.in
0 → 100644
View file @
022e0742
1
2
3
4
tests/4-opt/testcases/8_licm0.out
0 → 100644
View file @
022e0742
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
tests/4-opt/testcases/9_licm_bad.cminus
0 → 100644
View file @
022e0742
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;
}
tests/4-opt/testcases/
loop/loop-1
.out
→
tests/4-opt/testcases/
9_licm_bad
.out
View file @
022e0742
0
0
4
tests/4-opt/testcases/functional-cases/0-io.cminus
deleted
100644 → 0
View file @
f40efe88
int main(void) {
output(input());
return 0;
}
tests/4-opt/testcases/functional-cases/0-io.in
deleted
100644 → 0
View file @
f40efe88
1234
tests/4-opt/testcases/functional-cases/1-return.cminus
deleted
100644 → 0
View file @
f40efe88
int main(void) {
output(111);
return 111;
}
tests/4-opt/testcases/functional-cases/1-return.out
deleted
100644 → 0
View file @
f40efe88
111
111
tests/4-opt/testcases/functional-cases/10-float.cminus
deleted
100644 → 0
View file @
f40efe88
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);
*/
tests/4-opt/testcases/functional-cases/10-float.out
deleted
100644 → 0
View file @
f40efe88
2.850000
0
tests/4-opt/testcases/functional-cases/11-floatcall.cminus
deleted
100644 → 0
View file @
f40efe88
/* 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;
}
tests/4-opt/testcases/functional-cases/11-floatcall.out
deleted
100644 → 0
View file @
f40efe88
0.200000
0
tests/4-opt/testcases/functional-cases/12-global.cminus
deleted
100644 → 0
View file @
f40efe88
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;
}
tests/4-opt/testcases/functional-cases/12-global.out
deleted
100644 → 0
View file @
f40efe88
4
2
2
4
8
2
2
2
2
2
6
2
10
8
4
2
20
2
2
8
0
tests/4-opt/testcases/functional-cases/13-complex.cminus
deleted
100644 → 0
View file @
f40efe88
/* 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;
}
tests/4-opt/testcases/functional-cases/13-complex.out
deleted
100644 → 0
View file @
f40efe88
15
0
tests/4-opt/testcases/functional-cases/2-calculate.cminus
deleted
100644 → 0
View file @
f40efe88
int main(void) {
int a;
int b;
int c;
a = 23;
b = 25;
c = 4;
return a + b * c;
}
tests/4-opt/testcases/functional-cases/2-calculate.out
deleted
100644 → 0
View file @
f40efe88
123
tests/4-opt/testcases/functional-cases/3-output.cminus
deleted
100644 → 0
View file @
f40efe88
int main(void) {
output(11);
output(22222);
return 0;
}
tests/4-opt/testcases/functional-cases/3-output.out
deleted
100644 → 0
View file @
f40efe88
11
22222
0
tests/4-opt/testcases/functional-cases/4-if.cminus
deleted
100644 → 0
View file @
f40efe88
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;
}
tests/4-opt/testcases/functional-cases/5-while.cminus
deleted
100644 → 0
View file @
f40efe88
int main(void) {
int n;
int i;
n = 10;
i = 0;
while (i < n) {
output(i);
i = i + 1;
}
return 0;
}
tests/4-opt/testcases/functional-cases/6-array.cminus
deleted
100644 → 0
View file @
f40efe88
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;
}
tests/4-opt/testcases/functional-cases/6-array.out
deleted
100644 → 0
View file @
f40efe88
11
22
33
0
tests/4-opt/testcases/functional-cases/7-function.cminus
deleted
100644 → 0
View file @
f40efe88
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;
}
tests/4-opt/testcases/functional-cases/7-function.out
deleted
100644 → 0
View file @
f40efe88
11
22
11
0
tests/4-opt/testcases/functional-cases/8-store.cminus
deleted
100644 → 0
View file @
f40efe88
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;
}
tests/4-opt/testcases/functional-cases/8-store.out
deleted
100644 → 0
View file @
f40efe88
90
0
tests/4-opt/testcases/functional-cases/9-fibonacci.cminus
deleted
100644 → 0
View file @
f40efe88
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;
}
tests/4-opt/testcases/loop/baseline/loop-1.ll
deleted
100644 → 0
View file @
f40efe88
; 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
}
tests/4-opt/testcases/loop/baseline/loop-2.ll
deleted
100644 → 0
View file @
f40efe88
; 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
}
tests/4-opt/testcases/loop/baseline/loop-3.ll
deleted
100644 → 0
View file @
f40efe88
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
}
tests/4-opt/testcases/loop/baseline/loop-4.ll
deleted
100644 → 0
View file @
f40efe88
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
}
tests/4-opt/testcases/loop/loop-1.cminus
deleted
100644 → 0
View file @
f40efe88
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
tests/4-opt/testcases/loop/loop-2.cminus
deleted
100644 → 0
View file @
f40efe88
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
tests/4-opt/testcases/loop/loop-2.out
deleted
100644 → 0
View file @
f40efe88
1
0
tests/4-opt/testcases/loop/loop-3.cminus
deleted
100644 → 0
View file @
f40efe88
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
tests/4-opt/testcases/loop/loop-3.out
deleted
100644 → 0
View file @
f40efe88
1
0
tests/4-opt/testcases/loop/loop-4.cminus
deleted
100644 → 0
View file @
f40efe88
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
tests/4-opt/testcases/loop/loop-4.out
deleted
100644 → 0
View file @
f40efe88
1
0
tests/4-opt/testcases/mem2reg/baseline/mem2reg-1
deleted
100755 → 0
View file @
f40efe88
File deleted
tests/4-opt/testcases/mem2reg/baseline/mem2reg-1.ll
deleted
100644 → 0
View file @
f40efe88
; 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
}
tests/4-opt/testcases/mem2reg/baseline/mem2reg-2
deleted
100755 → 0
View file @
f40efe88
File deleted
tests/4-opt/testcases/mem2reg/baseline/mem2reg-2.ll
deleted
100644 → 0
View file @
f40efe88
; 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
}
tests/4-opt/testcases/mem2reg/baseline/mem2reg-3
deleted
100755 → 0
View file @
f40efe88
File deleted
tests/4-opt/testcases/mem2reg/baseline/mem2reg-3.ll
deleted
100644 → 0
View file @
f40efe88
; 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
}
tests/4-opt/testcases/mem2reg/mem2reg-1
deleted
100755 → 0
View file @
f40efe88
File deleted
tests/4-opt/testcases/mem2reg/mem2reg-1.cminus
deleted
100644 → 0
View file @
f40efe88
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
tests/4-opt/testcases/mem2reg/mem2reg-1.in
deleted
100644 → 0
View file @
f40efe88
100000000
tests/4-opt/testcases/mem2reg/mem2reg-1.out
deleted
100644 → 0
View file @
f40efe88
711082625
0
tests/4-opt/testcases/mem2reg/mem2reg-2
deleted
100755 → 0
View file @
f40efe88
File deleted
tests/4-opt/testcases/mem2reg/mem2reg-2.cminus
deleted
100644 → 0
View file @
f40efe88
int main(void) {
int a;
a = 1;
while (a < 999999999) {
a = a + 1;
}
return a;
}
tests/4-opt/testcases/mem2reg/mem2reg-2.out
deleted
100644 → 0
View file @
f40efe88
255
tests/4-opt/testcases/mem2reg/mem2reg-3
deleted
100755 → 0
View file @
f40efe88
File deleted
tests/4-opt/testcases/mem2reg/mem2reg-3.cminus
deleted
100644 → 0
View file @
f40efe88
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;
}
tests/4-opt/testcases/mem2reg/mem2reg-3.in
deleted
100644 → 0
View file @
f40efe88
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
tests/4-opt/testcases/mem2reg/mem2reg-3.out
deleted
100644 → 0
View file @
f40efe88
1042523985
0
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment