You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

159 lines
4.5 KiB

@COUNT = global i32 500000
declare i32 @getint()
declare float @getfloat()
declare i32 @getarray(i32* %arg.a)
declare i32 @getfarray(float* %arg.a)
declare i32 @getch()
declare void @putint(i32 %arg.x)
declare void @putfloat(float %arg.x)
declare void @putarray(i32 %arg.n, i32* %arg.a)
declare void @putfarray(i32 %arg.n, float* %arg.a)
declare void @putch(i32 %arg.x)
declare void @starttime()
declare void @stoptime()
define float @loop(float* %arg.x, float* %arg.y, i32 %arg.length) {
entry:
%t1 = alloca i32
%t2 = alloca float
%t0 = alloca i32
store i32 %arg.length, i32* %t0
store i32 0, i32* %t1
store float 0x0000000000000000, float* %t2
br label %while.cond.1
while.cond.1:
%t3 = load i32, i32* %t1
%t4 = load i32, i32* %t0
%t5 = icmp slt i32 %t3, %t4
%t6 = zext i1 %t5 to i32
%t7 = icmp ne i32 %t6, 0
br i1 %t7, label %while.body.2, label %while.end.3
while.body.2:
%t8 = load float, float* %t2
%t9 = load i32, i32* %t1
%t10 = getelementptr inbounds float, float* %arg.x, i32 %t9
%t11 = load float, float* %t10
%t12 = load i32, i32* %t1
%t13 = getelementptr inbounds float, float* %arg.y, i32 %t12
%t14 = load float, float* %t13
%t15 = fmul float %t11, %t14
%t16 = fadd float %t8, %t15
store float %t16, float* %t2
%t17 = load i32, i32* %t1
%t18 = add i32 %t17, 1
store i32 %t18, i32* %t1
br label %while.cond.1
while.end.3:
%t19 = load float, float* %t2
ret float %t19
}
define i32 @main() {
entry:
%t20 = alloca i32
%t21 = alloca i32
%t22 = alloca float, i32 4900
%t23 = alloca float, i32 4900
%t24 = alloca i32
%t25 = alloca float
%t26 = alloca float
%t27 = alloca float
%t67 = alloca i32
store i32 0, i32* %t20
store i32 0, i32* %t21
store i32 4900, i32* %t24
store float 0x0000000000000000, float* %t25
store float 0x0000000000000000, float* %t26
store float 0x3FF0000000000000, float* %t27
call void @starttime()
br label %while.cond.4
while.cond.4:
%t29 = load i32, i32* %t20
%t30 = load i32, i32* @COUNT
%t31 = icmp slt i32 %t29, %t30
%t32 = zext i1 %t31 to i32
%t33 = icmp ne i32 %t32, 0
br i1 %t33, label %while.body.5, label %while.end.6
while.body.5:
%t34 = load i32, i32* %t20
%t35 = srem i32 %t34, 10
%t36 = icmp ne i32 %t35, 0
br i1 %t36, label %if.then.7, label %if.else.8
while.end.6:
call void @stoptime()
%t68 = load float, float* %t25
%t69 = fsub float %t68, 0x43517E0A60000000
%t70 = fptosi float %t69 to i32
store i32 %t70, i32* %t67
%t71 = load i32, i32* %t67
%t72 = sitofp i32 %t71 to float
%t73 = fcmp ole float %t72, 0x3EB0C6F7A0000000
%t74 = zext i1 %t73 to i32
%t75 = icmp ne i32 %t74, 0
br i1 %t75, label %land.rhs.16, label %if.else.14
if.then.7:
store float 0x0000000000000000, float* %t26
store float 0x3FF0000000000000, float* %t27
br label %if.end.9
if.else.8:
%t37 = load float, float* %t26
%t38 = fadd float %t37, 0x3FB99999A0000000
store float %t38, float* %t26
%t39 = load float, float* %t27
%t40 = fadd float %t39, 0x3FC99999A0000000
store float %t40, float* %t27
br label %if.end.9
if.end.9:
br label %while.cond.10
while.cond.10:
%t41 = load i32, i32* %t21
%t42 = load i32, i32* %t24
%t43 = icmp slt i32 %t41, %t42
%t44 = zext i1 %t43 to i32
%t45 = icmp ne i32 %t44, 0
br i1 %t45, label %while.body.11, label %while.end.12
while.body.11:
%t46 = load i32, i32* %t21
%t47 = getelementptr inbounds float, float* %t22, i32 %t46
%t48 = load float, float* %t26
%t49 = load i32, i32* %t21
%t50 = sitofp i32 %t49 to float
%t51 = fadd float %t48, %t50
store float %t51, float* %t47
%t52 = load i32, i32* %t21
%t53 = getelementptr inbounds float, float* %t23, i32 %t52
%t54 = load float, float* %t27
%t55 = load i32, i32* %t21
%t56 = sitofp i32 %t55 to float
%t57 = fadd float %t54, %t56
store float %t57, float* %t53
%t58 = load i32, i32* %t21
%t59 = add i32 %t58, 1
store i32 %t59, i32* %t21
br label %while.cond.10
while.end.12:
%t60 = load float, float* %t25
%t61 = load i32, i32* %t24
%t62 = call float @loop(float* %t22, float* %t23, i32 %t61)
%t63 = fadd float %t60, %t62
store float %t63, float* %t25
%t64 = load i32, i32* %t20
%t65 = add i32 %t64, 1
store i32 %t65, i32* %t20
br label %while.cond.4
if.then.13:
call void @putint(i32 10)
ret i32 0
if.else.14:
call void @putint(i32 1)
ret i32 1
if.end.15:
ret i32 0
land.rhs.16:
%t76 = load i32, i32* %t67
%t77 = sitofp i32 %t76 to float
%t78 = fcmp oge float %t77, 0xBEB0C6F7A0000000
%t79 = zext i1 %t78 to i32
%t80 = icmp ne i32 %t79, 0
br i1 %t80, label %if.then.13, label %if.else.14
}