sources
sources
/root/src/hello/ex.go
func main() {
for i := 0; i < 5; i++ {
if i%2 == 0 {
println(i, "is even")
} else {
println(i, "is odd")
}
}
}
AST
AST buildssa-body
. DCL # ex.go:4:9
. . NAME-main.i esc(no) Class:PAUTO Offset:0 OnStack Used int tc(1) # ex.go:4:9
. AS Def tc(1) # ex.go:4:11
. . NAME-main.i esc(no) Class:PAUTO Offset:0 OnStack Used int tc(1) # ex.go:4:9
. . LITERAL-0 int tc(1) # ex.go:4:14
. FOR tc(1) # ex.go:4:5
. FOR-Cond
. . LT bool tc(1) # ex.go:4:19
. . . NAME-main.i esc(no) Class:PAUTO Offset:0 OnStack Used int tc(1) # ex.go:4:9
. . . LITERAL-5 int tc(1) # ex.go:4:21
. FOR-Post
. . BLOCK # ex.go:4:25
. . BLOCK-List
. . . AS tc(1) # ex.go:4:25
. . . . NAME-main.i esc(no) Class:PAUTO Offset:0 OnStack Used int tc(1) # ex.go:4:9
. . . . ADD int tc(1) # ex.go:4:25
. . . . . NAME-main.i esc(no) Class:PAUTO Offset:0 OnStack Used int tc(1) # ex.go:4:9
. . . . . LITERAL-1 int tc(1) # ex.go:4:25
. FOR-Body
. . IF tc(1) # ex.go:5:9
. . IF-Cond
. . . EQ bool tc(1) # ex.go:5:16
. . . . MOD int tc(1) # ex.go:5:13
. . . . . NAME-main.i esc(no) Class:PAUTO Offset:0 OnStack Used int tc(1) # ex.go:4:9
. . . . . LITERAL-2 int tc(1) # ex.go:5:14
. . . . LITERAL-0 int tc(1) # ex.go:5:19
. . IF-Body
. . . BLOCK tc(1) # ex.go:6:20
. . . BLOCK-List
. . . . CALLFUNC Walked tc(1) # ex.go:6:20
. . . . CALLFUNC-Fun
. . . . . NAME-runtime.printlock Class:PFUNC Offset:0 Used FUNC-func() tc(1)
. . . . CALLFUNC Walked tc(1) # ex.go:6:20
. . . . CALLFUNC-Fun
. . . . . NAME-runtime.printint Class:PFUNC Offset:0 Used FUNC-func(int64) tc(1)
. . . . CALLFUNC-Args
. . . . . CONVNOP int64 tc(1) # ex.go:6:20
. . . . . . NAME-main.i esc(no) Class:PAUTO Offset:0 OnStack Used int tc(1) # ex.go:4:9
. . . . CALLFUNC Walked tc(1) # ex.go:6:20
. . . . CALLFUNC-Fun
. . . . . NAME-runtime.printstring Class:PFUNC Offset:0 Used FUNC-func(string) tc(1)
. . . . CALLFUNC-Args
. . . . . LITERAL-" is even\n" string tc(1) # ex.go:6:20
. . . . CALLFUNC Walked tc(1) # ex.go:6:20
. . . . CALLFUNC-Fun
. . . . . NAME-runtime.printunlock Class:PFUNC Offset:0 Used FUNC-func() tc(1)
. . IF-Else
. . . BLOCK tc(1) # ex.go:8:20
. . . BLOCK-List
. . . . CALLFUNC Walked tc(1) # ex.go:8:20
. . . . CALLFUNC-Fun
. . . . . NAME-runtime.printlock Class:PFUNC Offset:0 Used FUNC-func() tc(1)
. . . . CALLFUNC Walked tc(1) # ex.go:8:20
. . . . CALLFUNC-Fun
. . . . . NAME-runtime.printint Class:PFUNC Offset:0 Used FUNC-func(int64) tc(1)
. . . . CALLFUNC-Args
. . . . . CONVNOP int64 tc(1) # ex.go:8:20
. . . . . . NAME-main.i esc(no) Class:PAUTO Offset:0 OnStack Used int tc(1) # ex.go:4:9
. . . . CALLFUNC Walked tc(1) # ex.go:8:20
. . . . CALLFUNC-Fun
. . . . . NAME-runtime.printstring Class:PFUNC Offset:0 Used FUNC-func(string) tc(1)
. . . . CALLFUNC-Args
. . . . . LITERAL-" is odd\n" string tc(1) # ex.go:8:20
. . . . CALLFUNC Walked tc(1) # ex.go:8:20
. . . . CALLFUNC-Fun
. . . . . NAME-runtime.printunlock Class:PFUNC Offset:0 Used FUNC-func() tc(1)
before insert phis
before insert phis b1 :- v1 (?) = InitMem <mem>v2 (?) = SP <uintptr>v3 (?) = SB <uintptr>v4 (?) = Const64 <int> [0] (i[int])v6 (?) = Const64 <int> [5]v9 (?) = Const64 <int> [2]v19 (?) = ConstString <string> {" is even\n"}v31 (?) = ConstString <string> {" is odd\n"}v37 (?) = Const64 <int> [1]Plain → b2 (4) b2 : ← b1 b4 - v5 (4 ) = FwdRef <int> {{[] i}} (i[int])v7 (4) = Less64 <bool> v5 v6 If v7 → b3 b5 (likely) (4) b3 : ← b2 - v8 (5 ) = FwdRef <int> {{[] i}} (i[int])v10 (5) = Mod64 <int> [false] v8 v9 v11 (5) = Eq64 <bool> v10 v4 If v11 → b7 b8 (5) b4 : ← b6 - v36 (4 ) = FwdRef <int> {{[] i}} (i[int])v38 (4) = Add64 <int> v36 v37 (i[int])Plain → b2 (4) b5 : ← b2 - v39 (11 ) = FwdRef <mem> {{[] mem}}v40 (11) = MakeResult <mem> v39 Ret v40 (11) b6 : ← b7 b8 Plain → b4 (4 ) b7 : ← b3 - v12 (6 ) = FwdRef <mem> {{[] mem}}v13 (6) = StaticLECall <mem> {AuxCall{runtime.printlock}} v12 v14 (6) = SelectN <mem> [0] v13 v15 (6 ) = FwdRef <int> {{[] i}} (i[int])v16 (6 ) = Copy <int64> v15 v17 (6) = StaticLECall <mem> {AuxCall{runtime.printint}} [8] v16 v14 v18 (6) = SelectN <mem> [0] v17 v20 (6) = StaticLECall <mem> {AuxCall{runtime.printstring}} [16] v19 v18 v21 (6) = SelectN <mem> [0] v20 v22 (6) = StaticLECall <mem> {AuxCall{runtime.printunlock}} v21 v23 (6) = SelectN <mem> [0] v22 Plain → b6 (6) b8 : ← b3 - v24 (8 ) = FwdRef <mem> {{[] mem}}v25 (8) = StaticLECall <mem> {AuxCall{runtime.printlock}} v24 v26 (8) = SelectN <mem> [0] v25 v27 (8 ) = FwdRef <int> {{[] i}} (i[int])v28 (8 ) = Copy <int64> v27 v29 (8) = StaticLECall <mem> {AuxCall{runtime.printint}} [8] v28 v26 v30 (8) = SelectN <mem> [0] v29 v32 (8) = StaticLECall <mem> {AuxCall{runtime.printstring}} [16] v31 v30 v33 (8) = SelectN <mem> [0] v32 v34 (8) = StaticLECall <mem> {AuxCall{runtime.printunlock}} v33 v35 (8) = SelectN <mem> [0] v34 Plain → b6 (8) name i[int]: v4 v5 v8 v15 v27 v36 v38
start
start b1 :- v1 (?) = InitMem <mem>v2 (?) = SP <uintptr>v3 (?) = SB <uintptr>v4 (?) = Const64 <int> [0] (i[int])v6 (?) = Const64 <int> [5]v9 (?) = Const64 <int> [2]v19 (?) = ConstString <string> {" is even\n"}v31 (?) = ConstString <string> {" is odd\n"}v37 (?) = Const64 <int> [1]Plain → b2 (4) b2 : ← b1 b4 - v5 (4 ) = Phi <int> v4 v38 (i[int])v41 (8 ) = Phi <mem> v1 v42 v7 (4) = Less64 <bool> v5 v6 If v7 → b3 b5 (likely) (4) b3 : ← b2 - v8 (5 ) = Copy <int> v5 (i[int])v10 (5) = Mod64 <int> [false] v8 v9 v11 (5) = Eq64 <bool> v10 v4 If v11 → b7 b8 (5) b4 : ← b6 - v36 (4 ) = Copy <int> v43 (i[int])v38 (4) = Add64 <int> v36 v37 (i[int])Plain → b2 (4) b5 : ← b2 - v39 (11 ) = Copy <mem> v41 v40 (11) = MakeResult <mem> v39 Ret v40 (11) b6 : ← b7 b8 - v42 (8 ) = Phi <mem> v23 v35 v43 (4 ) = Phi <int> v15 v27 (i[int])Plain → b4 (4 ) b7 : ← b3 - v12 (6 ) = Copy <mem> v41 v13 (6) = StaticLECall <mem> {AuxCall{runtime.printlock}} v12 v14 (6) = SelectN <mem> [0] v13 v15 (6 ) = Copy <int> v8 (i[int])v16 (6 ) = Copy <int64> v15 v17 (6) = StaticLECall <mem> {AuxCall{runtime.printint}} [8] v16 v14 v18 (6) = SelectN <mem> [0] v17 v20 (6) = StaticLECall <mem> {AuxCall{runtime.printstring}} [16] v19 v18 v21 (6) = SelectN <mem> [0] v20 v22 (6) = StaticLECall <mem> {AuxCall{runtime.printunlock}} v21 v23 (6) = SelectN <mem> [0] v22 Plain → b6 (6) b8 : ← b3 - v24 (8 ) = Copy <mem> v41 v25 (8) = StaticLECall <mem> {AuxCall{runtime.printlock}} v24 v26 (8) = SelectN <mem> [0] v25 v27 (8 ) = Copy <int> v8 (i[int])v28 (8 ) = Copy <int64> v27 v29 (8) = StaticLECall <mem> {AuxCall{runtime.printint}} [8] v28 v26 v30 (8) = SelectN <mem> [0] v29 v32 (8) = StaticLECall <mem> {AuxCall{runtime.printstring}} [16] v31 v30 v33 (8) = SelectN <mem> [0] v32 v34 (8) = StaticLECall <mem> {AuxCall{runtime.printunlock}} v33 v35 (8) = SelectN <mem> [0] v34 Plain → b6 (8) name i[int]: v4 v5 v8 v15 v27 v36 v38 v43
number lines
number lines [14942 ns] b1 :- v1 (?) = InitMem <mem>v2 (?) = SP <uintptr>v3 (?) = SB <uintptr>v4 (?) = Const64 <int> [0] (i[int])v6 (?) = Const64 <int> [5]v9 (?) = Const64 <int> [2]v19 (?) = ConstString <string> {" is even\n"}v31 (?) = ConstString <string> {" is odd\n"}v37 (?) = Const64 <int> [1]Plain → b2 (+4 ) b2 : ← b1 b4 - v5 (4 ) = Phi <int> v4 v38 (i[int])v41 (8 ) = Phi <mem> v1 v42 v7 (+4 ) = Less64 <bool> v5 v6 If v7 → b3 b5 (likely) (4) b3 : ← b2 - v8 (5 ) = Copy <int> v5 (i[int])v10 (+5 ) = Mod64 <int> [false] v8 v9 v11 (5) = Eq64 <bool> v10 v4 If v11 → b7 b8 (5) b4 : ← b6 - v36 (4 ) = Copy <int> v43 (i[int])v38 (+4 ) = Add64 <int> v36 v37 (i[int])Plain → b2 (4) b5 : ← b2 - v39 (11 ) = Copy <mem> v41 v40 (+11 ) = MakeResult <mem> v39 Ret v40 (11) b6 : ← b7 b8 - v42 (8 ) = Phi <mem> v23 v35 v43 (4 ) = Phi <int> v15 v27 (i[int])Plain → b4 b7 : ← b3 - v12 (6 ) = Copy <mem> v41 v13 (+6 ) = StaticLECall <mem> {AuxCall{runtime.printlock}} v12 v14 (6) = SelectN <mem> [0] v13 v15 (6 ) = Copy <int> v8 (i[int])v16 (6 ) = Copy <int64> v15 v17 (6) = StaticLECall <mem> {AuxCall{runtime.printint}} [8] v16 v14 v18 (6) = SelectN <mem> [0] v17 v20 (6) = StaticLECall <mem> {AuxCall{runtime.printstring}} [16] v19 v18 v21 (6) = SelectN <mem> [0] v20 v22 (6) = StaticLECall <mem> {AuxCall{runtime.printunlock}} v21 v23 (6) = SelectN <mem> [0] v22 Plain → b6 (6) b8 : ← b3 - v24 (8 ) = Copy <mem> v41 v25 (+8 ) = StaticLECall <mem> {AuxCall{runtime.printlock}} v24 v26 (8) = SelectN <mem> [0] v25 v27 (8 ) = Copy <int> v8 (i[int])v28 (8 ) = Copy <int64> v27 v29 (8) = StaticLECall <mem> {AuxCall{runtime.printint}} [8] v28 v26 v30 (8) = SelectN <mem> [0] v29 v32 (8) = StaticLECall <mem> {AuxCall{runtime.printstring}} [16] v31 v30 v33 (8) = SelectN <mem> [0] v32 v34 (8) = StaticLECall <mem> {AuxCall{runtime.printunlock}} v33 v35 (8) = SelectN <mem> [0] v34 Plain → b6 (8) name i[int]: v4 v5 v8 v15 v27 v36 v38 v43
early phielim and copyelim
early phielim and copyelim [3367 ns] b1 :- v1 (?) = InitMem <mem>v2 (?) = SP <uintptr>v3 (?) = SB <uintptr>v4 (?) = Const64 <int> [0] (i[int])v6 (?) = Const64 <int> [5]v9 (?) = Const64 <int> [2]v19 (?) = ConstString <string> {" is even\n"}v31 (?) = ConstString <string> {" is odd\n"}v37 (?) = Const64 <int> [1]Plain → b2 (+4 ) b2 : ← b1 b4 - v5 (4 ) = Phi <int> v4 v38 (i[int])v41 (8 ) = Phi <mem> v1 v42 v7 (+4 ) = Less64 <bool> v5 v6 If v7 → b3 b5 (likely) (4) b3 : ← b2 - v8 (5 ) = Copy <int> v5 v10 (+5 ) = Mod64 <int> [false] v5 v9 v11 (5) = Eq64 <bool> v10 v4 If v11 → b7 b8 (5) b4 : ← b6 - v36 (4 ) = Copy <int> v5 v38 (+4 ) = Add64 <int> v5 v37 (i[int])Plain → b2 (4) b5 : ← b2 - v39 (11 ) = Copy <mem> v41 v40 (+11 ) = MakeResult <mem> v41 Ret v40 (11) b6 : ← b7 b8 - v42 (8 ) = Phi <mem> v23 v35 v43 (4 ) = Copy <int> v5 Plain → b4 b7 : ← b3 - v12 (6 ) = Copy <mem> v41 v13 (+6 ) = StaticLECall <mem> {AuxCall{runtime.printlock}} v41 v14 (6) = SelectN <mem> [0] v13 v15 (6 ) = Copy <int> v5 v16 (6 ) = Copy <int64> v5 v17 (6) = StaticLECall <mem> {AuxCall{runtime.printint}} [8] v5 v14 v18 (6) = SelectN <mem> [0] v17 v20 (6) = StaticLECall <mem> {AuxCall{runtime.printstring}} [16] v19 v18 v21 (6) = SelectN <mem> [0] v20 v22 (6) = StaticLECall <mem> {AuxCall{runtime.printunlock}} v21 v23 (6) = SelectN <mem> [0] v22 Plain → b6 (6) b8 : ← b3 - v24 (8 ) = Copy <mem> v41 v25 (+8 ) = StaticLECall <mem> {AuxCall{runtime.printlock}} v41 v26 (8) = SelectN <mem> [0] v25 v27 (8 ) = Copy <int> v5 v28 (8 ) = Copy <int64> v5 v29 (8) = StaticLECall <mem> {AuxCall{runtime.printint}} [8] v5 v26 v30 (8) = SelectN <mem> [0] v29 v32 (8) = StaticLECall <mem> {AuxCall{runtime.printstring}} [16] v31 v30 v33 (8) = SelectN <mem> [0] v32 v34 (8) = StaticLECall <mem> {AuxCall{runtime.printunlock}} v33 v35 (8) = SelectN <mem> [0] v34 Plain → b6 (8) name i[int]: v4 v5 v5 v5 v5 v5 v38 v5
early deadcode
early deadcode [17689 ns] b1 :- v1 (?) = InitMem <mem>v4 (?) = Const64 <int> [0] (i[int])v6 (?) = Const64 <int> [5]v9 (?) = Const64 <int> [2]v19 (?) = ConstString <string> {" is even\n"}v31 (?) = ConstString <string> {" is odd\n"}v37 (?) = Const64 <int> [1]Plain → b2 (+4 ) b2 : ← b1 b4 - v5 (4 ) = Phi <int> v4 v38 (i[int])v41 (8 ) = Phi <mem> v1 v42 v7 (+4 ) = Less64 <bool> v5 v6 If v7 → b3 b5 (likely) (4) b3 : ← b2 - v10 (+5 ) = Mod64 <int> [false] v5 v9 v11 (5) = Eq64 <bool> v10 v4 If v11 → b7 b8 (5) b4 : ← b6 - v38 (+4 ) = Add64 <int> v5 v37 (i[int])Plain → b2 (4) b5 : ← b2 - v40 (+11 ) = MakeResult <mem> v41 Ret v40 (11) b6 : ← b7 b8 - v42 (8 ) = Phi <mem> v23 v35 Plain → b4 b7 : ← b3 - v13 (+6 ) = StaticLECall <mem> {AuxCall{runtime.printlock}} v41 v14 (6) = SelectN <mem> [0] v13 v17 (6) = StaticLECall <mem> {AuxCall{runtime.printint}} [8] v5 v14 v18 (6) = SelectN <mem> [0] v17 v20 (6) = StaticLECall <mem> {AuxCall{runtime.printstring}} [16] v19 v18 v21 (6) = SelectN <mem> [0] v20 v22 (6) = StaticLECall <mem> {AuxCall{runtime.printunlock}} v21 v23 (6) = SelectN <mem> [0] v22 Plain → b6 (6) b8 : ← b3 - v25 (+8 ) = StaticLECall <mem> {AuxCall{runtime.printlock}} v41 v26 (8) = SelectN <mem> [0] v25 v29 (8) = StaticLECall <mem> {AuxCall{runtime.printint}} [8] v5 v26 v30 (8) = SelectN <mem> [0] v29 v32 (8) = StaticLECall <mem> {AuxCall{runtime.printstring}} [16] v31 v30 v33 (8) = SelectN <mem> [0] v32 v34 (8) = StaticLECall <mem> {AuxCall{runtime.printunlock}} v33 v35 (8) = SelectN <mem> [0] v34 Plain → b6 (8) name i[int]: v4 v5 v38
short circuit
short circuit [2408 ns] b1 :- v1 (?) = InitMem <mem>v4 (?) = Const64 <int> [0] (i[int])v6 (?) = Const64 <int> [5]v9 (?) = Const64 <int> [2]v19 (?) = ConstString <string> {" is even\n"}v31 (?) = ConstString <string> {" is odd\n"}v37 (?) = Const64 <int> [1]Plain → b2 (+4 ) b2 : ← b1 b4 - v5 (4 ) = Phi <int> v4 v38 (i[int])v41 (8 ) = Phi <mem> v1 v42 v7 (+4 ) = Less64 <bool> v5 v6 If v7 → b3 b5 (likely) (4) b3 : ← b2 - v10 (+5 ) = Mod64 <int> [false] v5 v9 v11 (5) = Eq64 <bool> v10 v4 If v11 → b7 b8 (5) b4 : ← b7 b8 - v42 (8 ) = Phi <mem> v23 v35 v38 (+4 ) = Add64 <int> v5 v37 (i[int])Plain → b2 (4) b5 : ← b2 - v40 (+11 ) = MakeResult <mem> v41 Ret v40 (11) b7 : ← b3 - v13 (+6 ) = StaticLECall <mem> {AuxCall{runtime.printlock}} v41 v14 (6) = SelectN <mem> [0] v13 v17 (6) = StaticLECall <mem> {AuxCall{runtime.printint}} [8] v5 v14 v18 (6) = SelectN <mem> [0] v17 v20 (6) = StaticLECall <mem> {AuxCall{runtime.printstring}} [16] v19 v18 v21 (6) = SelectN <mem> [0] v20 v22 (6) = StaticLECall <mem> {AuxCall{runtime.printunlock}} v21 v23 (6) = SelectN <mem> [0] v22 Plain → b4 (6) b8 : ← b3 - v25 (+8 ) = StaticLECall <mem> {AuxCall{runtime.printlock}} v41 v26 (8) = SelectN <mem> [0] v25 v29 (8) = StaticLECall <mem> {AuxCall{runtime.printint}} [8] v5 v26 v30 (8) = SelectN <mem> [0] v29 v32 (8) = StaticLECall <mem> {AuxCall{runtime.printstring}} [16] v31 v30 v33 (8) = SelectN <mem> [0] v32 v34 (8) = StaticLECall <mem> {AuxCall{runtime.printunlock}} v33 v35 (8) = SelectN <mem> [0] v34 Plain → b4 (8) name i[int]: v4 v5 v38
decompose user + pre-opt deadcode
decompose user [687 ns] pre-opt deadcode [4912 ns] b1 :- v1 (?) = InitMem <mem>v4 (?) = Const64 <int> [0] (i[int])v6 (?) = Const64 <int> [5]v9 (?) = Const64 <int> [2]v19 (?) = ConstString <string> {" is even\n"}v31 (?) = ConstString <string> {" is odd\n"}v37 (?) = Const64 <int> [1]Plain → b2 (+4 ) b2 : ← b1 b4 - v5 (4 ) = Phi <int> v4 v38 (i[int])v41 (8 ) = Phi <mem> v1 v42 v7 (+4 ) = Less64 <bool> v5 v6 If v7 → b3 b5 (likely) (4) b3 : ← b2 - v10 (+5 ) = Mod64 <int> [false] v5 v9 v11 (5) = Eq64 <bool> v10 v4 If v11 → b7 b8 (5) b4 : ← b7 b8 - v42 (8 ) = Phi <mem> v23 v35 v38 (+4 ) = Add64 <int> v5 v37 (i[int])Plain → b2 (4) b5 : ← b2 - v40 (+11 ) = MakeResult <mem> v41 Ret v40 (11) b7 : ← b3 - v13 (+6 ) = StaticLECall <mem> {AuxCall{runtime.printlock}} v41 v14 (6) = SelectN <mem> [0] v13 v17 (6) = StaticLECall <mem> {AuxCall{runtime.printint}} [8] v5 v14 v18 (6) = SelectN <mem> [0] v17 v20 (6) = StaticLECall <mem> {AuxCall{runtime.printstring}} [16] v19 v18 v21 (6) = SelectN <mem> [0] v20 v22 (6) = StaticLECall <mem> {AuxCall{runtime.printunlock}} v21 v23 (6) = SelectN <mem> [0] v22 Plain → b4 (6) b8 : ← b3 - v25 (+8 ) = StaticLECall <mem> {AuxCall{runtime.printlock}} v41 v26 (8) = SelectN <mem> [0] v25 v29 (8) = StaticLECall <mem> {AuxCall{runtime.printint}} [8] v5 v26 v30 (8) = SelectN <mem> [0] v29 v32 (8) = StaticLECall <mem> {AuxCall{runtime.printstring}} [16] v31 v30 v33 (8) = SelectN <mem> [0] v32 v34 (8) = StaticLECall <mem> {AuxCall{runtime.printunlock}} v33 v35 (8) = SelectN <mem> [0] v34 Plain → b4 (8) name i[int]: v4 v5 v38
opt
opt [66422 ns] b1 :- v1 (?) = InitMem <mem>v4 (?) = Const64 <int> [0] (i[int])v6 (?) = Const64 <int> [5]v37 (?) = Const64 <int> [1]v27 (?) = SB <uintptr>v24 (?) = Const64 <int> [9]v15 (?) = SB <uintptr>v12 (?) = Const64 <int> [8]v28 (?) = Addr <*uint8> {go:string." is even\n"} v27 v16 (?) = Addr <*uint8> {go:string." is odd\n"} v15 v19 (?) = StringMake <string> v28 v24 v31 (?) = StringMake <string> v16 v12 Plain → b2 (+4 ) b2 : ← b1 b4 - v5 (4 ) = Phi <int> v4 v38 (i[int])v41 (8 ) = Phi <mem> v1 v42 v7 (+4 ) = Less64 <bool> v5 v6 If v7 → b3 b5 (likely) (4) b3 : ← b2 - v49 (5) = Const64 <int> [1]v50 (5) = Const64 <int> [0]v48 (+5 ) = And64 <int> v5 v49 v11 (+5 ) = Eq64 <bool> v48 v50 If v11 → b7 b8 (5) b4 : ← b7 b8 - v42 (8 ) = Phi <mem> v23 v35 v38 (+4 ) = Add64 <int> v5 v37 (i[int])Plain → b2 (4) b5 : ← b2 - v40 (+11 ) = MakeResult <mem> v41 Ret v40 (11) b7 : ← b3 - v13 (+6 ) = StaticLECall <mem> {AuxCall{runtime.printlock}} v41 v14 (6) = SelectN <mem> [0] v13 v17 (6) = StaticLECall <mem> {AuxCall{runtime.printint}} [8] v5 v14 v18 (6) = SelectN <mem> [0] v17 v20 (6) = StaticLECall <mem> {AuxCall{runtime.printstring}} [16] v19 v18 v21 (6) = SelectN <mem> [0] v20 v22 (6) = StaticLECall <mem> {AuxCall{runtime.printunlock}} v21 v23 (6) = SelectN <mem> [0] v22 Plain → b4 (6) b8 : ← b3 - v25 (+8 ) = StaticLECall <mem> {AuxCall{runtime.printlock}} v41 v26 (8) = SelectN <mem> [0] v25 v29 (8) = StaticLECall <mem> {AuxCall{runtime.printint}} [8] v5 v26 v30 (8) = SelectN <mem> [0] v29 v32 (8) = StaticLECall <mem> {AuxCall{runtime.printstring}} [16] v31 v30 v33 (8) = SelectN <mem> [0] v32 v34 (8) = StaticLECall <mem> {AuxCall{runtime.printunlock}} v33 v35 (8) = SelectN <mem> [0] v34 Plain → b4 (8) name i[int]: v4 v5 v38
zero arg cse
zero arg cse [4689 ns] b1 :- v1 (?) = InitMem <mem>v4 (?) = Const64 <int> [0] (i[int])v6 (?) = Const64 <int> [5]v37 (?) = Const64 <int> [1]v27 (?) = SB <uintptr>v24 (?) = Const64 <int> [9]v16 (?) = Addr <*uint8> {go:string." is odd\n"} v27 v15 (?) = SB <uintptr>v12 (?) = Const64 <int> [8]v31 (?) = StringMake <string> v16 v12 v28 (?) = Addr <*uint8> {go:string." is even\n"} v27 v19 (?) = StringMake <string> v28 v24 Plain → b2 (+4 ) b2 : ← b1 b4 - v5 (4 ) = Phi <int> v4 v38 (i[int])v41 (8 ) = Phi <mem> v1 v42 v7 (+4 ) = Less64 <bool> v5 v6 If v7 → b3 b5 (likely) (4) b3 : ← b2 - v48 (+5 ) = And64 <int> v5 v37 v49 (5) = Const64 <int> [1]v50 (5) = Const64 <int> [0]v11 (+5 ) = Eq64 <bool> v48 v4 If v11 → b7 b8 (5) b4 : ← b7 b8 - v42 (8 ) = Phi <mem> v23 v35 v38 (+4 ) = Add64 <int> v5 v37 (i[int])Plain → b2 (4) b5 : ← b2 - v40 (+11 ) = MakeResult <mem> v41 Ret v40 (11) b7 : ← b3 - v13 (+6 ) = StaticLECall <mem> {AuxCall{runtime.printlock}} v41 v14 (6) = SelectN <mem> [0] v13 v17 (6) = StaticLECall <mem> {AuxCall{runtime.printint}} [8] v5 v14 v18 (6) = SelectN <mem> [0] v17 v20 (6) = StaticLECall <mem> {AuxCall{runtime.printstring}} [16] v19 v18 v21 (6) = SelectN <mem> [0] v20 v22 (6) = StaticLECall <mem> {AuxCall{runtime.printunlock}} v21 v23 (6) = SelectN <mem> [0] v22 Plain → b4 (6) b8 : ← b3 - v25 (+8 ) = StaticLECall <mem> {AuxCall{runtime.printlock}} v41 v26 (8) = SelectN <mem> [0] v25 v29 (8) = StaticLECall <mem> {AuxCall{runtime.printint}} [8] v5 v26 v30 (8) = SelectN <mem> [0] v29 v32 (8) = StaticLECall <mem> {AuxCall{runtime.printstring}} [16] v31 v30 v33 (8) = SelectN <mem> [0] v32 v34 (8) = StaticLECall <mem> {AuxCall{runtime.printunlock}} v33 v35 (8) = SelectN <mem> [0] v34 Plain → b4 (8) name i[int]: v4 v5 v38
opt deadcode
opt deadcode [4748 ns] b1 :- v1 (?) = InitMem <mem>v4 (?) = Const64 <int> [0] (i[int])v6 (?) = Const64 <int> [5]v37 (?) = Const64 <int> [1]v27 (?) = SB <uintptr>v24 (?) = Const64 <int> [9]v16 (?) = Addr <*uint8> {go:string." is odd\n"} v27 v12 (?) = Const64 <int> [8]v31 (?) = StringMake <string> v16 v12 v28 (?) = Addr <*uint8> {go:string." is even\n"} v27 v19 (?) = StringMake <string> v28 v24 Plain → b2 (+4 ) b2 : ← b1 b4 - v5 (4 ) = Phi <int> v4 v38 (i[int])v41 (8 ) = Phi <mem> v1 v42 v7 (+4 ) = Less64 <bool> v5 v6 If v7 → b3 b5 (likely) (4) b3 : ← b2 - v48 (+5 ) = And64 <int> v5 v37 v11 (+5 ) = Eq64 <bool> v48 v4 If v11 → b7 b8 (5) b4 : ← b7 b8 - v42 (8 ) = Phi <mem> v23 v35 v38 (+4 ) = Add64 <int> v5 v37 (i[int])Plain → b2 (4) b5 : ← b2 - v40 (+11 ) = MakeResult <mem> v41 Ret v40 (11) b7 : ← b3 - v13 (+6 ) = StaticLECall <mem> {AuxCall{runtime.printlock}} v41 v14 (6) = SelectN <mem> [0] v13 v17 (6) = StaticLECall <mem> {AuxCall{runtime.printint}} [8] v5 v14 v18 (6) = SelectN <mem> [0] v17 v20 (6) = StaticLECall <mem> {AuxCall{runtime.printstring}} [16] v19 v18 v21 (6) = SelectN <mem> [0] v20 v22 (6) = StaticLECall <mem> {AuxCall{runtime.printunlock}} v21 v23 (6) = SelectN <mem> [0] v22 Plain → b4 (6) b8 : ← b3 - v25 (+8 ) = StaticLECall <mem> {AuxCall{runtime.printlock}} v41 v26 (8) = SelectN <mem> [0] v25 v29 (8) = StaticLECall <mem> {AuxCall{runtime.printint}} [8] v5 v26 v30 (8) = SelectN <mem> [0] v29 v32 (8) = StaticLECall <mem> {AuxCall{runtime.printstring}} [16] v31 v30 v33 (8) = SelectN <mem> [0] v32 v34 (8) = StaticLECall <mem> {AuxCall{runtime.printunlock}} v33 v35 (8) = SelectN <mem> [0] v34 Plain → b4 (8) name i[int]: v4 v5 v38
generic cse + phiopt + gcse deadcode + nilcheckelim + prove + early fuse + expand calls
generic cse [24603 ns] phiopt [1068 ns] gcse deadcode [3613 ns] nilcheckelim [8665 ns] prove [55207 ns] early fuse [1089 ns] expand calls [8719 ns] b1 :- v1 (?) = InitMem <mem>v4 (?) = Const64 <int> [0] (i[int])v6 (?) = Const64 <int> [5]v37 (?) = Const64 <int> [1]v27 (?) = SB <uintptr>v24 (?) = Const64 <int> [9]v16 (?) = Addr <*uint8> {go:string." is odd\n"} v27 v12 (?) = Const64 <int> [8]v50 (?) = SP <uintptr>v31 (?) = StringMake <string> v16 v12 v28 (?) = Addr <*uint8> {go:string." is even\n"} v27 v19 (?) = StringMake <string> v28 v24 Plain → b2 (+4 ) b2 : ← b1 b4 - v5 (4 ) = Phi <int> v4 v38 (i[int])v41 (8 ) = Phi <mem> v1 v42 v7 (+4 ) = Less64 <bool> v5 v6 If v7 → b3 b5 (likely) (4) b3 : ← b2 - v48 (+5 ) = And64 <int> v5 v37 v11 (+5 ) = Eq64 <bool> v48 v4 If v11 → b7 b8 (5) b4 : ← b7 b8 - v42 (8 ) = Phi <mem> v23 v35 v38 (+4 ) = Add64 <int> v5 v37 (i[int])Plain → b2 (4) b5 : ← b2 - v40 (+11 ) = MakeResult <mem> v41 Ret v40 (11) b7 : ← b3 - v13 (+6 ) = StaticCall <mem> {AuxCall{runtime.printlock}} v41 v14 (6) = SelectN <mem> [0] v13 v17 (6) = StaticCall <mem> {AuxCall{runtime.printint}} [8] v5 v14 v18 (6) = SelectN <mem> [0] v17 v49 (6) = StringPtr <*uint8> v19 v15 (6 ) = StringLen <int> v19 v20 (6) = StaticCall <mem> {AuxCall{runtime.printstring}} [16] v49 v15 v18 v21 (6) = SelectN <mem> [0] v20 v22 (6) = StaticCall <mem> {AuxCall{runtime.printunlock}} v21 v23 (6) = SelectN <mem> [0] v22 Plain → b4 (6) b8 : ← b3 - v25 (+8 ) = StaticCall <mem> {AuxCall{runtime.printlock}} v41 v26 (8) = SelectN <mem> [0] v25 v29 (8) = StaticCall <mem> {AuxCall{runtime.printint}} [8] v5 v26 v30 (8) = SelectN <mem> [0] v29 v47 (8) = StringPtr <*uint8> v31 v46 (8 ) = StringLen <int> v31 v32 (8) = StaticCall <mem> {AuxCall{runtime.printstring}} [16] v47 v46 v30 v33 (8) = SelectN <mem> [0] v32 v34 (8) = StaticCall <mem> {AuxCall{runtime.printunlock}} v33 v35 (8) = SelectN <mem> [0] v34 Plain → b4 (8) name i[int]: v4 v5 v38
decompose builtin
decompose builtin [9399 ns] b1 :- v1 (?) = InitMem <mem>v4 (?) = Const64 <int> [0] (i[int])v6 (?) = Const64 <int> [5]v37 (?) = Const64 <int> [1]v27 (?) = SB <uintptr>v24 (?) = Const64 <int> [9]v16 (?) = Addr <*uint8> {go:string." is odd\n"} v27 v12 (?) = Const64 <int> [8]v50 (?) = SP <uintptr>v31 (?) = StringMake <string> v16 v12 v28 (?) = Addr <*uint8> {go:string." is even\n"} v27 v19 (?) = StringMake <string> v28 v24 Plain → b2 (+4 ) b2 : ← b1 b4 - v5 (4 ) = Phi <int> v4 v38 (i[int])v41 (8 ) = Phi <mem> v1 v42 v7 (+4 ) = Less64 <bool> v5 v6 If v7 → b3 b5 (likely) (4) b3 : ← b2 - v48 (+5 ) = And64 <int> v5 v37 v11 (+5 ) = Eq64 <bool> v48 v4 If v11 → b7 b8 (5) b4 : ← b7 b8 - v42 (8 ) = Phi <mem> v23 v35 v38 (+4 ) = Add64 <int> v5 v37 (i[int])Plain → b2 (4) b5 : ← b2 - v40 (+11 ) = MakeResult <mem> v41 Ret v40 (11) b7 : ← b3 - v13 (+6 ) = StaticCall <mem> {AuxCall{runtime.printlock}} v41 v14 (6) = SelectN <mem> [0] v13 v17 (6) = StaticCall <mem> {AuxCall{runtime.printint}} [8] v5 v14 v18 (6) = SelectN <mem> [0] v17 v20 (6) = StaticCall <mem> {AuxCall{runtime.printstring}} [16] v28 v24 v18 v21 (6) = SelectN <mem> [0] v20 v22 (6) = StaticCall <mem> {AuxCall{runtime.printunlock}} v21 v23 (6) = SelectN <mem> [0] v22 Plain → b4 (6) b8 : ← b3 - v25 (+8 ) = StaticCall <mem> {AuxCall{runtime.printlock}} v41 v26 (8) = SelectN <mem> [0] v25 v29 (8) = StaticCall <mem> {AuxCall{runtime.printint}} [8] v5 v26 v30 (8) = SelectN <mem> [0] v29 v32 (8) = StaticCall <mem> {AuxCall{runtime.printstring}} [16] v16 v12 v30 v33 (8) = SelectN <mem> [0] v32 v34 (8) = StaticCall <mem> {AuxCall{runtime.printunlock}} v33 v35 (8) = SelectN <mem> [0] v34 Plain → b4 (8) name i[int]: v4 v5 v38
softfloat + late opt
softfloat [274 ns] late opt [7163 ns] b1 :- v1 (?) = InitMem <mem>v4 (?) = Const64 <int> [0] (i[int])v6 (?) = Const64 <int> [5]v37 (?) = Const64 <int> [1]v27 (?) = SB <uintptr>v24 (?) = Const64 <int> [9]v16 (?) = Addr <*uint8> {go:string." is odd\n"} v27 v12 (?) = Const64 <int> [8]v28 (?) = Addr <*uint8> {go:string." is even\n"} v27 Plain → b2 (+4 ) b2 : ← b1 b4 - v5 (4 ) = Phi <int> v4 v38 (i[int])v41 (8 ) = Phi <mem> v1 v42 v7 (+4 ) = Less64 <bool> v5 v6 If v7 → b3 b5 (likely) (4) b3 : ← b2 - v48 (+5 ) = And64 <int> v5 v37 v11 (+5 ) = Eq64 <bool> v48 v4 If v11 → b7 b8 (5) b4 : ← b7 b8 - v42 (8 ) = Phi <mem> v23 v35 v38 (+4 ) = Add64 <int> v5 v37 (i[int])Plain → b2 (4) b5 : ← b2 - v40 (+11 ) = MakeResult <mem> v41 Ret v40 (11) b7 : ← b3 - v13 (+6 ) = StaticCall <mem> {AuxCall{runtime.printlock}} v41 v14 (6) = SelectN <mem> [0] v13 v17 (6) = StaticCall <mem> {AuxCall{runtime.printint}} [8] v5 v14 v18 (6) = SelectN <mem> [0] v17 v20 (6) = StaticCall <mem> {AuxCall{runtime.printstring}} [16] v28 v24 v18 v21 (6) = SelectN <mem> [0] v20 v22 (6) = StaticCall <mem> {AuxCall{runtime.printunlock}} v21 v23 (6) = SelectN <mem> [0] v22 Plain → b4 (6) b8 : ← b3 - v25 (+8 ) = StaticCall <mem> {AuxCall{runtime.printlock}} v41 v26 (8) = SelectN <mem> [0] v25 v29 (8) = StaticCall <mem> {AuxCall{runtime.printint}} [8] v5 v26 v30 (8) = SelectN <mem> [0] v29 v32 (8) = StaticCall <mem> {AuxCall{runtime.printstring}} [16] v16 v12 v30 v33 (8) = SelectN <mem> [0] v32 v34 (8) = StaticCall <mem> {AuxCall{runtime.printunlock}} v33 v35 (8) = SelectN <mem> [0] v34 Plain → b4 (8) name i[int]: v4 v5 v38
dead auto elim + sccp
dead auto elim [2289 ns] sccp [21167 ns] b1 :- v1 (?) = InitMem <mem>v4 (?) = Const64 <int> [0] (i[int])v6 (?) = Const64 <int> [5]v37 (?) = Const64 <int> [1]v27 (?) = SB <uintptr>v24 (?) = Const64 <int> [9]v16 (?) = Addr <*uint8> {go:string." is odd\n"} v27 v12 (?) = Const64 <int> [8]v50 (+4 ) = ConstBool <bool> [true]v31 (+5 ) = Const64 <int> [0]v19 (+5 ) = ConstBool <bool> [true]v46 (+4 ) = Const64 <int> [1]v28 (?) = Addr <*uint8> {go:string." is even\n"} v27 Plain → b2 (+4 ) b2 : ← b1 b4 - v5 (4 ) = Phi <int> v4 v38 (i[int])v41 (8 ) = Phi <mem> v1 v42 v7 (+4 ) = Less64 <bool> v5 v6 If v7 → b3 b5 (likely) (4) b3 : ← b2 - v48 (+5 ) = And64 <int> v5 v37 v11 (+5 ) = Eq64 <bool> v48 v4 If v11 → b7 b8 (5) b4 : ← b7 b8 - v42 (8 ) = Phi <mem> v23 v35 v38 (+4 ) = Add64 <int> v5 v37 (i[int])Plain → b2 (4) b5 : ← b2 - v40 (+11 ) = MakeResult <mem> v41 Ret v40 (11) b7 : ← b3 - v13 (+6 ) = StaticCall <mem> {AuxCall{runtime.printlock}} v41 v14 (6) = SelectN <mem> [0] v13 v17 (6) = StaticCall <mem> {AuxCall{runtime.printint}} [8] v5 v14 v18 (6) = SelectN <mem> [0] v17 v20 (6) = StaticCall <mem> {AuxCall{runtime.printstring}} [16] v28 v24 v18 v21 (6) = SelectN <mem> [0] v20 v22 (6) = StaticCall <mem> {AuxCall{runtime.printunlock}} v21 v23 (6) = SelectN <mem> [0] v22 Plain → b4 (6) b8 : ← b3 - v25 (+8 ) = StaticCall <mem> {AuxCall{runtime.printlock}} v41 v26 (8) = SelectN <mem> [0] v25 v29 (8) = StaticCall <mem> {AuxCall{runtime.printint}} [8] v5 v26 v30 (8) = SelectN <mem> [0] v29 v32 (8) = StaticCall <mem> {AuxCall{runtime.printstring}} [16] v16 v12 v30 v33 (8) = SelectN <mem> [0] v32 v34 (8) = StaticCall <mem> {AuxCall{runtime.printunlock}} v33 v35 (8) = SelectN <mem> [0] v34 Plain → b4 (8) name i[int]: v4 v5 v38
generic deadcode
generic deadcode [5239 ns] b1 :- v1 (?) = InitMem <mem>v4 (?) = Const64 <int> [0] (i[int])v6 (?) = Const64 <int> [5]v37 (?) = Const64 <int> [1]v27 (?) = SB <uintptr>v24 (?) = Const64 <int> [9]v16 (?) = Addr <*uint8> {go:string." is odd\n"} v27 v12 (?) = Const64 <int> [8]v28 (?) = Addr <*uint8> {go:string." is even\n"} v27 Plain → b2 (+4 ) b2 : ← b1 b4 - v5 (4 ) = Phi <int> v4 v38 (i[int])v41 (8 ) = Phi <mem> v1 v42 v7 (+4 ) = Less64 <bool> v5 v6 If v7 → b3 b5 (likely) (4) b3 : ← b2 - v48 (+5 ) = And64 <int> v5 v37 v11 (+5 ) = Eq64 <bool> v48 v4 If v11 → b7 b8 (5) b4 : ← b7 b8 - v42 (8 ) = Phi <mem> v23 v35 v38 (+4 ) = Add64 <int> v5 v37 (i[int])Plain → b2 (4) b5 : ← b2 - v40 (+11 ) = MakeResult <mem> v41 Ret v40 (11) b7 : ← b3 - v13 (+6 ) = StaticCall <mem> {AuxCall{runtime.printlock}} v41 v14 (6) = SelectN <mem> [0] v13 v17 (6) = StaticCall <mem> {AuxCall{runtime.printint}} [8] v5 v14 v18 (6) = SelectN <mem> [0] v17 v20 (6) = StaticCall <mem> {AuxCall{runtime.printstring}} [16] v28 v24 v18 v21 (6) = SelectN <mem> [0] v20 v22 (6) = StaticCall <mem> {AuxCall{runtime.printunlock}} v21 v23 (6) = SelectN <mem> [0] v22 Plain → b4 (6) b8 : ← b3 - v25 (+8 ) = StaticCall <mem> {AuxCall{runtime.printlock}} v41 v26 (8) = SelectN <mem> [0] v25 v29 (8) = StaticCall <mem> {AuxCall{runtime.printint}} [8] v5 v26 v30 (8) = SelectN <mem> [0] v29 v32 (8) = StaticCall <mem> {AuxCall{runtime.printstring}} [16] v16 v12 v30 v33 (8) = SelectN <mem> [0] v32 v34 (8) = StaticCall <mem> {AuxCall{runtime.printunlock}} v33 v35 (8) = SelectN <mem> [0] v34 Plain → b4 (8) name i[int]: v4 v5 v38
branchelim + late fuse + check bce + dse + memcombine + writebarrier + lower
branchelim [2084 ns] late fuse [3882 ns] check bce [237 ns] dse [13741 ns] memcombine [1645 ns] writebarrier [3160 ns] lower [60579 ns] b1 :- v1 (?) = InitMem <mem>v4 (?) = MOVQconst <int> [0] (i[int])v27 (?) = SB <uintptr>v24 (?) = MOVQconst <int> [9]v16 (?) = LEAQ <*uint8> {go:string." is odd\n"} v27 v12 (?) = MOVQconst <int> [8]v28 (?) = LEAQ <*uint8> {go:string." is even\n"} v27 Plain → b2 (+4 ) b2 : ← b1 b4 - v5 (4 ) = Phi <int> v4 v38 (i[int])v41 (8 ) = Phi <mem> v1 v42 v19 (+4 ) = CMPQconst <flags> [5] v5 LT v19 → b3 b5 (likely) (4) b3 : ← b2 - v47 (+5 ) = BTQconst <flags> [0] v5 UGE v47 → b7 b8 (5) b4 : ← b7 b8 - v42 (8 ) = Phi <mem> v23 v35 v38 (+4 ) = ADDQconst <int> [1] v5 (i[int])Plain → b2 (4) b5 : ← b2 - v40 (+11 ) = MakeResult <mem> v41 Ret v40 (11) b7 : ← b3 - v13 (+6 ) = CALLstatic <mem> {AuxCall{runtime.printlock}} v41 v14 (6) = SelectN <mem> [0] v13 v17 (6) = CALLstatic <mem> {AuxCall{runtime.printint}} [8] v5 v14 v18 (6) = SelectN <mem> [0] v17 v20 (6) = CALLstatic <mem> {AuxCall{runtime.printstring}} [16] v28 v24 v18 v21 (6) = SelectN <mem> [0] v20 v22 (6) = CALLstatic <mem> {AuxCall{runtime.printunlock}} v21 v23 (6) = SelectN <mem> [0] v22 Plain → b4 (6) b8 : ← b3 - v25 (+8 ) = CALLstatic <mem> {AuxCall{runtime.printlock}} v41 v26 (8) = SelectN <mem> [0] v25 v29 (8) = CALLstatic <mem> {AuxCall{runtime.printint}} [8] v5 v26 v30 (8) = SelectN <mem> [0] v29 v32 (8) = CALLstatic <mem> {AuxCall{runtime.printstring}} [16] v16 v12 v30 v33 (8) = SelectN <mem> [0] v32 v34 (8) = CALLstatic <mem> {AuxCall{runtime.printunlock}} v33 v35 (8) = SelectN <mem> [0] v34 Plain → b4 (8) name i[int]: v4 v5 v38
addressing modes + late lower + lowered deadcode for cse + lowered cse + elim unread autos + tighten tuple selectors + lowered deadcode + checkLower + late phielim and copyelim + tighten + late deadcode + critical + phi tighten + likelyadjust + layout
addressing modes [1007 ns] late lower [2492 ns] lowered deadcode for cse [3678 ns] lowered cse [3967 ns] elim unread autos [330 ns] tighten tuple selectors [2129 ns] lowered deadcode [2703 ns] checkLower [655 ns] late phielim and copyelim [1274 ns] tighten [15117 ns] late deadcode [2804 ns] critical [736 ns] phi tighten [467 ns] likelyadjust [1425 ns] layout [10801 ns] b1 :- v1 (?) = InitMem <mem>v4 (?) = MOVQconst <int> [0] (i[int])v27 (?) = SB <uintptr>v24 (?) = MOVQconst <int> [9]v16 (?) = LEAQ <*uint8> {go:string." is odd\n"} v27 v12 (?) = MOVQconst <int> [8]v28 (?) = LEAQ <*uint8> {go:string." is even\n"} v27 Plain → b2 (+4 ) b2 : ← b1 b4 - v5 (4 ) = Phi <int> v4 v38 (i[int])v41 (8 ) = Phi <mem> v1 v42 v19 (+4 ) = CMPQconst <flags> [5] v5 LT v19 → b3 b5 (likely) (4) b3 : ← b2 - v47 (+5 ) = BTQconst <flags> [0] v5 UGE v47 → b7 b8 (5) b7 : ← b3 - v13 (+6 ) = CALLstatic <mem> {AuxCall{runtime.printlock}} v41 v14 (6) = SelectN <mem> [0] v13 v17 (6) = CALLstatic <mem> {AuxCall{runtime.printint}} [8] v5 v14 v18 (6) = SelectN <mem> [0] v17 v20 (6) = CALLstatic <mem> {AuxCall{runtime.printstring}} [16] v28 v24 v18 v21 (6) = SelectN <mem> [0] v20 v22 (6) = CALLstatic <mem> {AuxCall{runtime.printunlock}} v21 v23 (6) = SelectN <mem> [0] v22 Plain → b4 (6) b8 : ← b3 - v25 (+8 ) = CALLstatic <mem> {AuxCall{runtime.printlock}} v41 v26 (8) = SelectN <mem> [0] v25 v29 (8) = CALLstatic <mem> {AuxCall{runtime.printint}} [8] v5 v26 v30 (8) = SelectN <mem> [0] v29 v32 (8) = CALLstatic <mem> {AuxCall{runtime.printstring}} [16] v16 v12 v30 v33 (8) = SelectN <mem> [0] v32 v34 (8) = CALLstatic <mem> {AuxCall{runtime.printunlock}} v33 v35 (8) = SelectN <mem> [0] v34 Plain → b4 (8) b4 : ← b7 b8 - v42 (8 ) = Phi <mem> v23 v35 v38 (+4 ) = ADDQconst <int> [1] v5 (i[int])Plain → b2 (4) b5 : ← b2 - v40 (+11 ) = MakeResult <mem> v41 Ret v40 (11) name i[int]: v4 v5 v38
schedule
schedule [14213 ns] b1 :- v27 (?) = SB <uintptr>v1 (?) = InitMem <mem>v16 (?) = LEAQ <*uint8> {go:string." is odd\n"} v27 v28 (?) = LEAQ <*uint8> {go:string." is even\n"} v27 v4 (?) = MOVQconst <int> [0] (i[int])v12 (?) = MOVQconst <int> [8]v24 (?) = MOVQconst <int> [9]Plain → b2 (+4 ) b2 : ← b1 b4 - v5 (4 ) = Phi <int> v4 v38 (i[int])v41 (8 ) = Phi <mem> v1 v42 v19 (+4 ) = CMPQconst <flags> [5] v5 LT v19 → b3 b5 (likely) (4) b3 : ← b2 - v47 (+5 ) = BTQconst <flags> [0] v5 UGE v47 → b7 b8 (5) b7 : ← b3 - v13 (+6 ) = CALLstatic <mem> {AuxCall{runtime.printlock}} v41 v14 (6) = SelectN <mem> [0] v13 v17 (6) = CALLstatic <mem> {AuxCall{runtime.printint}} [8] v5 v14 v18 (6) = SelectN <mem> [0] v17 v20 (6) = CALLstatic <mem> {AuxCall{runtime.printstring}} [16] v28 v24 v18 v21 (6) = SelectN <mem> [0] v20 v22 (6) = CALLstatic <mem> {AuxCall{runtime.printunlock}} v21 v23 (6) = SelectN <mem> [0] v22 Plain → b4 (6) b8 : ← b3 - v25 (+8 ) = CALLstatic <mem> {AuxCall{runtime.printlock}} v41 v26 (8) = SelectN <mem> [0] v25 v29 (8) = CALLstatic <mem> {AuxCall{runtime.printint}} [8] v5 v26 v30 (8) = SelectN <mem> [0] v29 v32 (8) = CALLstatic <mem> {AuxCall{runtime.printstring}} [16] v16 v12 v30 v33 (8) = SelectN <mem> [0] v32 v34 (8) = CALLstatic <mem> {AuxCall{runtime.printunlock}} v33 v35 (8) = SelectN <mem> [0] v34 Plain → b4 (8) b4 : ← b7 b8 - v42 (8 ) = Phi <mem> v23 v35 v38 (+4 ) = ADDQconst <int> [1] v5 (i[int])Plain → b2 (4) b5 : ← b2 - v40 (+11 ) = MakeResult <mem> v41 Ret v40 (11) name i[int]: v4 v5 v38
late nilcheck + flagalloc + regalloc
late nilcheck [2402 ns] flagalloc [5472 ns] regalloc [103020 ns] b1 :- v27 (?) = SB <uintptr> : SBv1 (?) = InitMem <mem>v15 (?) = MOVQconst <int> [0] : AXPlain → b2 (+4 ) b2 : ← b1 b4 - v5 (4 ) = Phi <int> v15 v38 : AX (i[int])v41 (8 ) = Phi <mem> v1 v42 v19 (+4 ) = CMPQconst <flags> [5] v5 LT v19 → b3 b5 (likely) (4) b3 : ← b2 - v50 (4 ) = StoreReg <int> v5 : i[int]v47 (+5 ) = BTQconst <flags> [0] v5 UGE v47 → b7 b8 (5) b7 : ← b3 - v13 (+6 ) = CALLstatic <mem> {AuxCall{runtime.printlock}} v41 v14 (6) = SelectN <mem> [0] v13 v31 (6 ) = LoadReg <int> v50 : AXv17 (6) = CALLstatic <mem> {AuxCall{runtime.printint}} [8] v31 v14 : <>v18 (6) = SelectN <mem> [0] v17 v48 (6 ) = LEAQ <*uint8> {go:string." is even\n"} v27 : AXv11 (6 ) = MOVQconst <int> [9] : BXv20 (6) = CALLstatic <mem> {AuxCall{runtime.printstring}} [16] v48 v11 v18 : <>v21 (6) = SelectN <mem> [0] v20 v22 (6) = CALLstatic <mem> {AuxCall{runtime.printunlock}} v21 v23 (6) = SelectN <mem> [0] v22 Plain → b4 (6) b8 : ← b3 - v25 (+8 ) = CALLstatic <mem> {AuxCall{runtime.printlock}} v41 v26 (8) = SelectN <mem> [0] v25 v46 (8 ) = LoadReg <int> v50 : AXv29 (8) = CALLstatic <mem> {AuxCall{runtime.printint}} [8] v46 v26 : <>v30 (8) = SelectN <mem> [0] v29 v7 (8 ) = LEAQ <*uint8> {go:string." is odd\n"} v27 : AXv37 (8 ) = MOVQconst <int> [8] : BXv32 (8) = CALLstatic <mem> {AuxCall{runtime.printstring}} [16] v7 v37 v30 : <>v33 (8) = SelectN <mem> [0] v32 v34 (8) = CALLstatic <mem> {AuxCall{runtime.printunlock}} v33 v35 (8) = SelectN <mem> [0] v34 Plain → b4 (8) b4 : ← b7 b8 - v42 (8 ) = Phi <mem> v23 v35 v6 (4 ) = LoadReg <int> v50 : AXv38 (+4 ) = ADDQconst <int> [1] v6 : AX (i[int])Plain → b2 (4) b5 : ← b2 - v40 (+11 ) = MakeResult <mem> v41 Ret v40 (11) name i[int]: v4 v5 v38
loop rotate
loop rotate [2421 ns] b1 :- v27 (?) = SB <uintptr> : SBv1 (?) = InitMem <mem>v15 (?) = MOVQconst <int> [0] : AXPlain → b2 (+4 ) b4 : ← b7 b8 - v42 (8 ) = Phi <mem> v23 v35 v6 (4 ) = LoadReg <int> v50 : AXv38 (+4 ) = ADDQconst <int> [1] v6 : AX (i[int])Plain → b2 (4) b2 : ← b1 b4 - v5 (4 ) = Phi <int> v15 v38 : AX (i[int])v41 (8 ) = Phi <mem> v1 v42 v19 (+4 ) = CMPQconst <flags> [5] v5 LT v19 → b3 b5 (likely) (4) b3 : ← b2 - v50 (4 ) = StoreReg <int> v5 : i[int]v47 (+5 ) = BTQconst <flags> [0] v5 UGE v47 → b7 b8 (5) b7 : ← b3 - v13 (+6 ) = CALLstatic <mem> {AuxCall{runtime.printlock}} v41 v14 (6) = SelectN <mem> [0] v13 v31 (6 ) = LoadReg <int> v50 : AXv17 (6) = CALLstatic <mem> {AuxCall{runtime.printint}} [8] v31 v14 : <>v18 (6) = SelectN <mem> [0] v17 v48 (6 ) = LEAQ <*uint8> {go:string." is even\n"} v27 : AXv11 (6 ) = MOVQconst <int> [9] : BXv20 (6) = CALLstatic <mem> {AuxCall{runtime.printstring}} [16] v48 v11 v18 : <>v21 (6) = SelectN <mem> [0] v20 v22 (6) = CALLstatic <mem> {AuxCall{runtime.printunlock}} v21 v23 (6) = SelectN <mem> [0] v22 Plain → b4 (6) b8 : ← b3 - v25 (+8 ) = CALLstatic <mem> {AuxCall{runtime.printlock}} v41 v26 (8) = SelectN <mem> [0] v25 v46 (8 ) = LoadReg <int> v50 : AXv29 (8) = CALLstatic <mem> {AuxCall{runtime.printint}} [8] v46 v26 : <>v30 (8) = SelectN <mem> [0] v29 v7 (8 ) = LEAQ <*uint8> {go:string." is odd\n"} v27 : AXv37 (8 ) = MOVQconst <int> [8] : BXv32 (8) = CALLstatic <mem> {AuxCall{runtime.printstring}} [16] v7 v37 v30 : <>v33 (8) = SelectN <mem> [0] v32 v34 (8) = CALLstatic <mem> {AuxCall{runtime.printunlock}} v33 v35 (8) = SelectN <mem> [0] v34 Plain → b4 (8) b5 : ← b2 - v40 (+11 ) = MakeResult <mem> v41 Ret v40 (11) name i[int]: v4 v5 v38
trim
trim [602 ns] b1 :- v27 (?) = SB <uintptr> : SBv1 (?) = InitMem <mem>v15 (?) = MOVQconst <int> [0] : AXPlain → b2 (+4 ) b4 : ← b7 b8 - v42 (8 ) = Phi <mem> v23 v35 v6 (4 ) = LoadReg <int> v50 : AXv38 (+4 ) = ADDQconst <int> [1] v6 : AX (i[int])Plain → b2 (4) b2 : ← b1 b4 - v5 (4 ) = Phi <int> v15 v38 : AX (i[int])v41 (8 ) = Phi <mem> v1 v42 v19 (+4 ) = CMPQconst <flags> [5] v5 LT v19 → b3 b5 (likely) (4) b3 : ← b2 - v50 (4 ) = StoreReg <int> v5 : i[int]v47 (+5 ) = BTQconst <flags> [0] v5 UGE v47 → b7 b8 (5) b7 : ← b3 - v13 (+6 ) = CALLstatic <mem> {AuxCall{runtime.printlock}} v41 v14 (6) = SelectN <mem> [0] v13 v31 (6 ) = LoadReg <int> v50 : AXv17 (6) = CALLstatic <mem> {AuxCall{runtime.printint}} [8] v31 v14 : <>v18 (6) = SelectN <mem> [0] v17 v48 (6 ) = LEAQ <*uint8> {go:string." is even\n"} v27 : AXv11 (6 ) = MOVQconst <int> [9] : BXv20 (6) = CALLstatic <mem> {AuxCall{runtime.printstring}} [16] v48 v11 v18 : <>v21 (6) = SelectN <mem> [0] v20 v22 (6) = CALLstatic <mem> {AuxCall{runtime.printunlock}} v21 v23 (6) = SelectN <mem> [0] v22 Plain → b4 (6) b8 : ← b3 - v25 (+8 ) = CALLstatic <mem> {AuxCall{runtime.printlock}} v41 v26 (8) = SelectN <mem> [0] v25 v46 (8 ) = LoadReg <int> v50 : AXv29 (8) = CALLstatic <mem> {AuxCall{runtime.printint}} [8] v46 v26 : <>v30 (8) = SelectN <mem> [0] v29 v7 (8 ) = LEAQ <*uint8> {go:string." is odd\n"} v27 : AXv37 (8 ) = MOVQconst <int> [8] : BXv32 (8) = CALLstatic <mem> {AuxCall{runtime.printstring}} [16] v7 v37 v30 : <>v33 (8) = SelectN <mem> [0] v32 v34 (8) = CALLstatic <mem> {AuxCall{runtime.printunlock}} v33 v35 (8) = SelectN <mem> [0] v34 Plain → b4 (8) b5 : ← b2 - v40 (+11 ) = MakeResult <mem> v41 Ret v40 (11) name i[int]: v4 v5 v38
genssa
genssa # /root/src/hello/ex.go 00000 (3) TEXT main.main(SB), ABIInternal 00001 (3) FUNCDATA $0, gclocals·M83szM6+gDKfH9vuf1h0yw==(SB) 00002 (3) FUNCDATA $1, gclocals·M83szM6+gDKfH9vuf1h0yw==(SB) v15 00003 (3 ) XORL AX, AX b1 00004 (4 ) JMP 7 v6 00005 (+4 ) MOVQ main.i-8(SP), AX v38 00006 (4 ) INCQ AX v19 00007 (+4 ) CMPQ AX, $5 b2 00008 (4 ) JGE 29 v50 00009 (4 ) MOVQ AX, main.i-8(SP) v47 00010 (+5 ) BTL $0, AX b3 00011 (5 ) JCS 21 v13 00012 (+6 ) PCDATA $1, $0 v13 00013 (+6 ) CALL runtime.printlock(SB) v31 00014 (6 ) MOVQ main.i-8(SP), AX v17 00015 (6 ) CALL runtime.printint(SB) v48 00016 (6 ) LEAQ go:string." is even\n"(SB), AX v11 00017 (6 ) MOVL $9, BX v20 00018 (6 ) CALL runtime.printstring(SB) v22 00019 (6 ) CALL runtime.printunlock(SB) b7 00020 (6 ) JMP 5 v25 00021 (+8 ) CALL runtime.printlock(SB) v46 00022 (8 ) MOVQ main.i-8(SP), AX v29 00023 (8 ) CALL runtime.printint(SB) v7 00024 (8 ) LEAQ go:string." is odd\n"(SB), AX v37 00025 (8 ) MOVL $8, BX v32 00026 (8 ) CALL runtime.printstring(SB) v34 00027 (8 ) CALL runtime.printunlock(SB) b8 00028 (8 ) JMP 5 b5 00029 (11) RET 00030 (?) END