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.

317 lines
9.3 KiB

@N = global i32 1024
@A = global [1048576 x float] zeroinitializer
@B = global [1048576 x float] zeroinitializer
@C = global [1048576 x float] zeroinitializer
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 void @trsm(i32 %arg.n, float* %arg.A, float* %arg.B) {
entry:
%t1 = alloca i32
%t2 = alloca i32
%t3 = alloca i32
%t0 = alloca i32
store i32 %arg.n, i32* %t0
store i32 0, i32* %t1
store i32 0, i32* %t2
store i32 0, i32* %t3
store i32 0, i32* %t3
br label %while.cond.1
while.cond.1:
%t4 = load i32, i32* %t3
%t5 = load i32, i32* %t0
%t6 = icmp slt i32 %t4, %t5
%t7 = zext i1 %t6 to i32
%t8 = icmp ne i32 %t7, 0
br i1 %t8, label %while.body.2, label %while.end.3
while.body.2:
store i32 0, i32* %t1
br label %while.cond.4
while.end.3:
ret void
while.cond.4:
%t9 = load i32, i32* %t1
%t10 = load i32, i32* %t0
%t11 = icmp slt i32 %t9, %t10
%t12 = zext i1 %t11 to i32
%t13 = icmp ne i32 %t12, 0
br i1 %t13, label %while.body.5, label %while.end.6
while.body.5:
%t14 = load i32, i32* %t1
%t15 = load i32, i32* %t3
%t16 = mul i32 %t14, 1024
%t17 = add i32 %t16, %t15
%t18 = getelementptr inbounds float, float* %arg.B, i32 %t17
%t19 = load i32, i32* %t1
%t20 = load i32, i32* %t3
%t21 = mul i32 %t19, 1024
%t22 = add i32 %t21, %t20
%t23 = getelementptr inbounds float, float* %arg.B, i32 %t22
%t24 = load float, float* %t23
%t25 = load i32, i32* %t1
%t26 = load i32, i32* %t1
%t27 = mul i32 %t25, 1024
%t28 = add i32 %t27, %t26
%t29 = getelementptr inbounds float, float* %arg.A, i32 %t28
%t30 = load float, float* %t29
%t31 = fdiv float %t24, %t30
store float %t31, float* %t18
%t32 = load i32, i32* %t1
%t33 = add i32 %t32, 1
store i32 %t33, i32* %t2
br label %while.cond.7
while.end.6:
%t68 = load i32, i32* %t3
%t69 = add i32 %t68, 1
store i32 %t69, i32* %t3
br label %while.cond.1
while.cond.7:
%t34 = load i32, i32* %t2
%t35 = load i32, i32* %t0
%t36 = icmp slt i32 %t34, %t35
%t37 = zext i1 %t36 to i32
%t38 = icmp ne i32 %t37, 0
br i1 %t38, label %while.body.8, label %while.end.9
while.body.8:
%t39 = load i32, i32* %t2
%t40 = load i32, i32* %t3
%t41 = mul i32 %t39, 1024
%t42 = add i32 %t41, %t40
%t43 = getelementptr inbounds float, float* %arg.B, i32 %t42
%t44 = load i32, i32* %t2
%t45 = load i32, i32* %t3
%t46 = mul i32 %t44, 1024
%t47 = add i32 %t46, %t45
%t48 = getelementptr inbounds float, float* %arg.B, i32 %t47
%t49 = load float, float* %t48
%t50 = load i32, i32* %t2
%t51 = load i32, i32* %t1
%t52 = mul i32 %t50, 1024
%t53 = add i32 %t52, %t51
%t54 = getelementptr inbounds float, float* %arg.A, i32 %t53
%t55 = load float, float* %t54
%t56 = load i32, i32* %t1
%t57 = load i32, i32* %t3
%t58 = mul i32 %t56, 1024
%t59 = add i32 %t58, %t57
%t60 = getelementptr inbounds float, float* %arg.B, i32 %t59
%t61 = load float, float* %t60
%t62 = fmul float %t55, %t61
%t63 = fsub float %t49, %t62
store float %t63, float* %t43
%t64 = load i32, i32* %t2
%t65 = add i32 %t64, 1
store i32 %t65, i32* %t2
br label %while.cond.7
while.end.9:
%t66 = load i32, i32* %t1
%t67 = add i32 %t66, 1
store i32 %t67, i32* %t1
br label %while.cond.4
}
define i32 @main() {
entry:
%t70 = alloca i32
%t72 = alloca i32
%t73 = alloca i32
%t74 = alloca i32
%t152 = alloca float
%t71 = call i32 @getint()
store i32 %t71, i32* %t70
store i32 0, i32* %t72
store i32 0, i32* %t73
store i32 0, i32* %t74
store i32 0, i32* %t72
store i32 0, i32* %t73
br label %while.cond.10
while.cond.10:
%t75 = load i32, i32* %t72
%t76 = load i32, i32* %t70
%t77 = icmp slt i32 %t75, %t76
%t78 = zext i1 %t77 to i32
%t79 = icmp ne i32 %t78, 0
br i1 %t79, label %while.body.11, label %while.end.12
while.body.11:
store i32 0, i32* %t73
br label %while.cond.13
while.end.12:
store i32 0, i32* %t72
store i32 0, i32* %t73
br label %while.cond.16
while.cond.13:
%t80 = load i32, i32* %t73
%t81 = load i32, i32* %t70
%t82 = icmp slt i32 %t80, %t81
%t83 = zext i1 %t82 to i32
%t84 = icmp ne i32 %t83, 0
br i1 %t84, label %while.body.14, label %while.end.15
while.body.14:
%t85 = load i32, i32* %t72
%t86 = load i32, i32* %t73
%t87 = mul i32 %t85, 1024
%t88 = add i32 %t87, %t86
%t89 = getelementptr inbounds [1048576 x float], [1048576 x float]* @A, i32 0, i32 %t88
%t90 = call float @getfloat()
store float %t90, float* %t89
%t91 = load i32, i32* %t73
%t92 = add i32 %t91, 1
store i32 %t92, i32* %t73
br label %while.cond.13
while.end.15:
%t93 = load i32, i32* %t72
%t94 = add i32 %t93, 1
store i32 %t94, i32* %t72
br label %while.cond.10
while.cond.16:
%t95 = load i32, i32* %t72
%t96 = load i32, i32* %t70
%t97 = icmp slt i32 %t95, %t96
%t98 = zext i1 %t97 to i32
%t99 = icmp ne i32 %t98, 0
br i1 %t99, label %while.body.17, label %while.end.18
while.body.17:
store i32 0, i32* %t73
br label %while.cond.19
while.end.18:
call void @starttime()
store i32 0, i32* %t74
br label %while.cond.22
while.cond.19:
%t100 = load i32, i32* %t73
%t101 = load i32, i32* %t70
%t102 = icmp slt i32 %t100, %t101
%t103 = zext i1 %t102 to i32
%t104 = icmp ne i32 %t103, 0
br i1 %t104, label %while.body.20, label %while.end.21
while.body.20:
%t105 = load i32, i32* %t72
%t106 = load i32, i32* %t73
%t107 = mul i32 %t105, 1024
%t108 = add i32 %t107, %t106
%t109 = getelementptr inbounds [1048576 x float], [1048576 x float]* @C, i32 0, i32 %t108
%t110 = call float @getfloat()
store float %t110, float* %t109
%t111 = load i32, i32* %t73
%t112 = add i32 %t111, 1
store i32 %t112, i32* %t73
br label %while.cond.19
while.end.21:
%t113 = load i32, i32* %t72
%t114 = add i32 %t113, 1
store i32 %t114, i32* %t72
br label %while.cond.16
while.cond.22:
%t116 = load i32, i32* %t74
%t117 = icmp slt i32 %t116, 5
%t118 = zext i1 %t117 to i32
%t119 = icmp ne i32 %t118, 0
br i1 %t119, label %while.body.23, label %while.end.24
while.body.23:
store i32 0, i32* %t72
br label %while.cond.25
while.end.24:
call void @stoptime()
store float 0x0000000000000000, float* %t152
store i32 0, i32* %t72
br label %while.cond.31
while.cond.25:
%t120 = load i32, i32* %t72
%t121 = load i32, i32* %t70
%t122 = icmp slt i32 %t120, %t121
%t123 = zext i1 %t122 to i32
%t124 = icmp ne i32 %t123, 0
br i1 %t124, label %while.body.26, label %while.end.27
while.body.26:
store i32 0, i32* %t73
br label %while.cond.28
while.end.27:
%t145 = load i32, i32* %t70
%t146 = getelementptr inbounds [1048576 x float], [1048576 x float]* @A, i32 0, i32 0
%t147 = getelementptr inbounds [1048576 x float], [1048576 x float]* @B, i32 0, i32 0
call void @trsm(i32 %t145, float* %t146, float* %t147)
%t149 = load i32, i32* %t74
%t150 = add i32 %t149, 1
store i32 %t150, i32* %t74
br label %while.cond.22
while.cond.28:
%t125 = load i32, i32* %t73
%t126 = load i32, i32* %t70
%t127 = icmp slt i32 %t125, %t126
%t128 = zext i1 %t127 to i32
%t129 = icmp ne i32 %t128, 0
br i1 %t129, label %while.body.29, label %while.end.30
while.body.29:
%t130 = load i32, i32* %t72
%t131 = load i32, i32* %t73
%t132 = mul i32 %t130, 1024
%t133 = add i32 %t132, %t131
%t134 = getelementptr inbounds [1048576 x float], [1048576 x float]* @B, i32 0, i32 %t133
%t135 = load i32, i32* %t72
%t136 = load i32, i32* %t73
%t137 = mul i32 %t135, 1024
%t138 = add i32 %t137, %t136
%t139 = getelementptr inbounds [1048576 x float], [1048576 x float]* @C, i32 0, i32 %t138
%t140 = load float, float* %t139
store float %t140, float* %t134
%t141 = load i32, i32* %t73
%t142 = add i32 %t141, 1
store i32 %t142, i32* %t73
br label %while.cond.28
while.end.30:
%t143 = load i32, i32* %t72
%t144 = add i32 %t143, 1
store i32 %t144, i32* %t72
br label %while.cond.25
while.cond.31:
%t153 = load i32, i32* %t72
%t154 = load i32, i32* %t70
%t155 = icmp slt i32 %t153, %t154
%t156 = zext i1 %t155 to i32
%t157 = icmp ne i32 %t156, 0
br i1 %t157, label %while.body.32, label %while.end.33
while.body.32:
store i32 0, i32* %t73
br label %while.cond.34
while.end.33:
%t175 = load float, float* %t152
call void @putfloat(float %t175)
call void @putch(i32 10)
ret i32 0
while.cond.34:
%t158 = load i32, i32* %t73
%t159 = load i32, i32* %t70
%t160 = icmp slt i32 %t158, %t159
%t161 = zext i1 %t160 to i32
%t162 = icmp ne i32 %t161, 0
br i1 %t162, label %while.body.35, label %while.end.36
while.body.35:
%t163 = load float, float* %t152
%t164 = load i32, i32* %t72
%t165 = load i32, i32* %t73
%t166 = mul i32 %t164, 1024
%t167 = add i32 %t166, %t165
%t168 = getelementptr inbounds [1048576 x float], [1048576 x float]* @B, i32 0, i32 %t167
%t169 = load float, float* %t168
%t170 = fadd float %t163, %t169
store float %t170, float* %t152
%t171 = load i32, i32* %t73
%t172 = add i32 %t171, 1
store i32 %t172, i32* %t73
br label %while.cond.34
while.end.36:
%t173 = load i32, i32* %t72
%t174 = add i32 %t173, 1
store i32 %t174, i32* %t72
br label %while.cond.31
}