sources
sources
/home/rileythomp/github/go/demo3.go
AST
AST buildssa-body
. DCL # demo3.go:16:7
. . NAME-main.i esc(no) Class:PAUTO Offset:0 OnStack Used int tc(1) # demo3.go:16:7
. AS Def tc(1) # demo3.go:16:9
. . NAME-main.i esc(no) Class:PAUTO Offset:0 OnStack Used int tc(1) # demo3.go:16:7
. . LITERAL-8 int tc(1) # demo3.go:16:12
. FOUR tc(1) # demo3.go:16:2
. FOUR-Cond
. . LE bool tc(1) # demo3.go:16:17
. . . NAME-main.i esc(no) Class:PAUTO Offset:0 OnStack Used int tc(1) # demo3.go:16:7
. . . LITERAL-20 int tc(1) # demo3.go:16:20
. FOUR-Post
. . BLOCK # demo3.go:16:25
. . BLOCK-List
. . . AS tc(1) # demo3.go:16:25
. . . . NAME-main.i esc(no) Class:PAUTO Offset:0 OnStack Used int tc(1) # demo3.go:16:7
. . . . ADD int tc(1) # demo3.go:16:25
. . . . . NAME-main.i esc(no) Class:PAUTO Offset:0 OnStack Used int tc(1) # demo3.go:16:7
. . . . . LITERAL-1 int tc(1) # demo3.go:16:25
. FOUR-Body
. . IF # demo3.go:17:3
. . IF-Cond
. . . NOT # demo3.go:17:3
. . . . EQ bool tc(1) # demo3.go:17:14
. . . . . MOD int tc(1) # demo3.go:17:11
. . . . . . NAME-main.i esc(no) Class:PAUTO Offset:0 OnStack Used int tc(1) # demo3.go:16:7
. . . . . . LITERAL-8 int tc(1) # demo3.go:17:12
. . . . . LITERAL-0 int tc(1) # demo3.go:17:17
. . IF-Body
. . . CALLFUNC Walked tc(1) # demo3.go:18:5
. . . CALLFUNC-Fun
. . . . NAME-main.g Class:PFUNC Offset:0 Used FUNC-func() tc(1) # demo3.go:11:6
. . . CONTINUE tc(1) # demo3.go:19:4
. . CALLFUNC Walked tc(1) # demo3.go:21:4
. . CALLFUNC-Fun
. . . NAME-main.f Class:PFUNC Offset:0 Used FUNC-func() tc(1) # demo3.go:7:6
before insert phis
before insert phis b1 :- v1 (?) = InitMem <mem>v2 (?) = SP <uintptr>v3 (?) = SB <uintptr>v4 (?) = Const64 <int> [8] (i[int])v6 (?) = Const64 <int> [20]v10 (?) = Const64 <int> [0]v19 (?) = Const64 <int> [1]Plain → b2 (16) b2 : ← b1 b4 - v5 (16 ) = FwdRef <int> {{[] i}} (i[int])v7 (16) = Leq64 <bool> v5 v6 If v7 → b3 b5 (likely) (16) b3 : ← b2 - v8 (17 ) = FwdRef <int> {{[] i}} (i[int])v9 (17) = Mod64 <int> [false] v8 v4 v11 (17) = Eq64 <bool> v9 v10 If v11 → b6 b7 (17) b4 : ← b7 b6 - v18 (16 ) = FwdRef <int> {{[] i}} (i[int])v20 (16) = Add64 <int> v18 v19 (i[int])v21 (16) = Add64 <int> v20 v19 (i[int])v22 (16) = Add64 <int> v21 v19 (i[int])v23 (16) = Add64 <int> v22 v19 (i[int])Plain → b2 (16) b5 : ← b2 - v24 (15 ) = FwdRef <mem> {{[] mem}}v25 (15) = MakeResult <mem> v24 Ret v25 (16) b6 : ← b3 - v15 (21 ) = FwdRef <mem> {{[] mem}}v16 (21) = StaticLECall <mem> {AuxCall{main.f}} v15 v17 (21) = SelectN <mem> [0] v16 Plain → b4 (21) b7 : ← b3 - v12 (18 ) = FwdRef <mem> {{[] mem}}v13 (18) = StaticLECall <mem> {AuxCall{main.g}} v12 v14 (18) = SelectN <mem> [0] v13 Plain → b4 (+19 ) name i[int]: v4 v5 v8 v18 v20 v21 v22 v23
start
start b1 :- v1 (?) = InitMem <mem>v2 (?) = SP <uintptr>v3 (?) = SB <uintptr>v4 (?) = Const64 <int> [8] (i[int])v6 (?) = Const64 <int> [20]v10 (?) = Const64 <int> [0]v19 (?) = Const64 <int> [1]Plain → b2 (16) b2 : ← b1 b4 - v5 (16 ) = Phi <int> v4 v23 (i[int])v26 (18 ) = Phi <mem> v1 v27 v7 (16) = Leq64 <bool> v5 v6 If v7 → b3 b5 (likely) (16) b3 : ← b2 - v8 (17 ) = Copy <int> v5 (i[int])v9 (17) = Mod64 <int> [false] v8 v4 v11 (17) = Eq64 <bool> v9 v10 If v11 → b6 b7 (17) b4 : ← b7 b6 - v27 (18 ) = Phi <mem> v14 v17 v18 (16 ) = Copy <int> v8 (i[int])v20 (16) = Add64 <int> v18 v19 (i[int])v21 (16) = Add64 <int> v20 v19 (i[int])v22 (16) = Add64 <int> v21 v19 (i[int])v23 (16) = Add64 <int> v22 v19 (i[int])Plain → b2 (16) b5 : ← b2 - v24 (15 ) = Copy <mem> v26 v25 (15) = MakeResult <mem> v24 Ret v25 (16) b6 : ← b3 - v15 (21 ) = Copy <mem> v26 v16 (21) = StaticLECall <mem> {AuxCall{main.f}} v15 v17 (21) = SelectN <mem> [0] v16 Plain → b4 (21) b7 : ← b3 - v12 (18 ) = Copy <mem> v26 v13 (18) = StaticLECall <mem> {AuxCall{main.g}} v12 v14 (18) = SelectN <mem> [0] v13 Plain → b4 (+19 ) name i[int]: v4 v5 v8 v18 v20 v21 v22 v23
number lines
number lines [4100 ns] b1 :- v1 (?) = InitMem <mem>v2 (?) = SP <uintptr>v3 (?) = SB <uintptr>v4 (?) = Const64 <int> [8] (i[int])v6 (?) = Const64 <int> [20]v10 (?) = Const64 <int> [0]v19 (?) = Const64 <int> [1]Plain → b2 (+16 ) b2 : ← b1 b4 - v5 (16 ) = Phi <int> v4 v23 (i[int])v26 (18 ) = Phi <mem> v1 v27 v7 (+16 ) = Leq64 <bool> v5 v6 If v7 → b3 b5 (likely) (16) b3 : ← b2 - v8 (17 ) = Copy <int> v5 (i[int])v9 (+17 ) = Mod64 <int> [false] v8 v4 v11 (17) = Eq64 <bool> v9 v10 If v11 → b6 b7 (17) b4 : ← b7 b6 - v27 (18 ) = Phi <mem> v14 v17 v18 (16 ) = Copy <int> v8 (i[int])v20 (+16 ) = Add64 <int> v18 v19 (i[int])v21 (16) = Add64 <int> v20 v19 (i[int])v22 (16) = Add64 <int> v21 v19 (i[int])v23 (16) = Add64 <int> v22 v19 (i[int])Plain → b2 (16) b5 : ← b2 - v24 (15 ) = Copy <mem> v26 v25 (+15 ) = MakeResult <mem> v24 Ret v25 (+16 ) b6 : ← b3 - v15 (21 ) = Copy <mem> v26 v16 (+21 ) = StaticLECall <mem> {AuxCall{main.f}} v15 v17 (21) = SelectN <mem> [0] v16 Plain → b4 (21) b7 : ← b3 - v12 (18 ) = Copy <mem> v26 v13 (+18 ) = StaticLECall <mem> {AuxCall{main.g}} v12 v14 (18) = SelectN <mem> [0] v13 Plain → b4 (+19 ) name i[int]: v4 v5 v8 v18 v20 v21 v22 v23
early phielim
early phielim [1800 ns] b1 :- v1 (?) = InitMem <mem>v2 (?) = SP <uintptr>v3 (?) = SB <uintptr>v4 (?) = Const64 <int> [8] (i[int])v6 (?) = Const64 <int> [20]v10 (?) = Const64 <int> [0]v19 (?) = Const64 <int> [1]Plain → b2 (+16 ) b2 : ← b1 b4 - v5 (16 ) = Phi <int> v4 v23 (i[int])v26 (18 ) = Phi <mem> v1 v27 v7 (+16 ) = Leq64 <bool> v5 v6 If v7 → b3 b5 (likely) (16) b3 : ← b2 - v8 (17 ) = Copy <int> v5 (i[int])v9 (+17 ) = Mod64 <int> [false] v5 v4 v11 (17) = Eq64 <bool> v9 v10 If v11 → b6 b7 (17) b4 : ← b7 b6 - v27 (18 ) = Phi <mem> v14 v17 v18 (16 ) = Copy <int> v5 (i[int])v20 (+16 ) = Add64 <int> v5 v19 (i[int])v21 (16) = Add64 <int> v20 v19 (i[int])v22 (16) = Add64 <int> v21 v19 (i[int])v23 (16) = Add64 <int> v22 v19 (i[int])Plain → b2 (16) b5 : ← b2 - v24 (15 ) = Copy <mem> v26 v25 (+15 ) = MakeResult <mem> v26 Ret v25 (+16 ) b6 : ← b3 - v15 (21 ) = Copy <mem> v26 v16 (+21 ) = StaticLECall <mem> {AuxCall{main.f}} v26 v17 (21) = SelectN <mem> [0] v16 Plain → b4 (21) b7 : ← b3 - v12 (18 ) = Copy <mem> v26 v13 (+18 ) = StaticLECall <mem> {AuxCall{main.g}} v26 v14 (18) = SelectN <mem> [0] v13 Plain → b4 (+19 ) name i[int]: v4 v5 v8 v18 v20 v21 v22 v23
early copyelim
early copyelim [1000 ns] b1 :- v1 (?) = InitMem <mem>v2 (?) = SP <uintptr>v3 (?) = SB <uintptr>v4 (?) = Const64 <int> [8] (i[int])v6 (?) = Const64 <int> [20]v10 (?) = Const64 <int> [0]v19 (?) = Const64 <int> [1]Plain → b2 (+16 ) b2 : ← b1 b4 - v5 (16 ) = Phi <int> v4 v23 (i[int])v26 (18 ) = Phi <mem> v1 v27 v7 (+16 ) = Leq64 <bool> v5 v6 If v7 → b3 b5 (likely) (16) b3 : ← b2 - v8 (17 ) = Copy <int> v5 v9 (+17 ) = Mod64 <int> [false] v5 v4 v11 (17) = Eq64 <bool> v9 v10 If v11 → b6 b7 (17) b4 : ← b7 b6 - v27 (18 ) = Phi <mem> v14 v17 v18 (16 ) = Copy <int> v5 v20 (+16 ) = Add64 <int> v5 v19 (i[int])v21 (16) = Add64 <int> v20 v19 (i[int])v22 (16) = Add64 <int> v21 v19 (i[int])v23 (16) = Add64 <int> v22 v19 (i[int])Plain → b2 (16) b5 : ← b2 - v24 (15 ) = Copy <mem> v26 v25 (+15 ) = MakeResult <mem> v26 Ret v25 (+16 ) b6 : ← b3 - v15 (21 ) = Copy <mem> v26 v16 (+21 ) = StaticLECall <mem> {AuxCall{main.f}} v26 v17 (21) = SelectN <mem> [0] v16 Plain → b4 (21) b7 : ← b3 - v12 (18 ) = Copy <mem> v26 v13 (+18 ) = StaticLECall <mem> {AuxCall{main.g}} v26 v14 (18) = SelectN <mem> [0] v13 Plain → b4 (+19 ) name i[int]: v4 v5 v5 v5 v20 v21 v22 v23
early deadcode
early deadcode [5300 ns] b1 :- v1 (?) = InitMem <mem>v4 (?) = Const64 <int> [8] (i[int])v6 (?) = Const64 <int> [20]v10 (?) = Const64 <int> [0]v19 (?) = Const64 <int> [1]Plain → b2 (+16 ) b2 : ← b1 b4 - v5 (16 ) = Phi <int> v4 v23 (i[int])v26 (18 ) = Phi <mem> v1 v27 v7 (+16 ) = Leq64 <bool> v5 v6 If v7 → b3 b5 (likely) (16) b3 : ← b2 - v9 (+17 ) = Mod64 <int> [false] v5 v4 v11 (17) = Eq64 <bool> v9 v10 If v11 → b6 b7 (17) b4 : ← b7 b6 - v27 (18 ) = Phi <mem> v14 v17 v20 (+16 ) = Add64 <int> v5 v19 (i[int])v21 (16) = Add64 <int> v20 v19 (i[int])v22 (16) = Add64 <int> v21 v19 (i[int])v23 (16) = Add64 <int> v22 v19 (i[int])Plain → b2 (16) b5 : ← b2 - v25 (+15 ) = MakeResult <mem> v26 Ret v25 (+16 ) b6 : ← b3 - v16 (+21 ) = StaticLECall <mem> {AuxCall{main.f}} v26 v17 (21) = SelectN <mem> [0] v16 Plain → b4 (21) b7 : ← b3 - v13 (+18 ) = StaticLECall <mem> {AuxCall{main.g}} v26 v14 (18) = SelectN <mem> [0] v13 Plain → b4 (+19 ) name i[int]: v4 v5 v20 v21 v22 v23
short circuit + decompose user + pre-opt deadcode + opt
short circuit [1100 ns] decompose user [500 ns] pre-opt deadcode [2500 ns] opt [18900 ns] b1 :- v1 (?) = InitMem <mem>v4 (?) = Const64 <int> [8] (i[int])v6 (?) = Const64 <int> [20]Plain → b2 (+16 ) b2 : ← b1 b4 - v5 (16 ) = Phi <int> v4 v23 (i[int])v26 (18 ) = Phi <mem> v1 v27 v7 (+16 ) = Leq64 <bool> v5 v6 If v7 → b3 b5 (likely) (16) b3 : ← b2 - v35 (17) = Const64 <int> [7]v36 (17) = Const64 <int> [0]v34 (+17 ) = And64 <int> v5 v35 v11 (+17 ) = Eq64 <bool> v34 v36 If v11 → b6 b7 (17) b4 : ← b7 b6 - v27 (18 ) = Phi <mem> v14 v17 v3 (16) = Const64 <int> [4]v23 (+16 ) = Add64 <int> v3 v5 (i[int])Plain → b2 (16) b5 : ← b2 - v25 (+15 ) = MakeResult <mem> v26 Ret v25 (+16 ) b6 : ← b3 - v16 (+21 ) = StaticLECall <mem> {AuxCall{main.f}} v26 v17 (21) = SelectN <mem> [0] v16 Plain → b4 (21) b7 : ← b3 - v13 (+18 ) = StaticLECall <mem> {AuxCall{main.g}} v26 v14 (18) = SelectN <mem> [0] v13 Plain → b4 (+19 ) name i[int]: v4 v5 v20 v21 v22 v23
zero arg cse
zero arg cse [3300 ns] b1 :- v1 (?) = InitMem <mem>v4 (?) = Const64 <int> [8] (i[int])v6 (?) = Const64 <int> [20]v35 (17) = Const64 <int> [7]v36 (17) = Const64 <int> [0]v3 (16) = Const64 <int> [4]Plain → b2 (+16 ) b2 : ← b1 b4 - v5 (16 ) = Phi <int> v4 v23 (i[int])v26 (18 ) = Phi <mem> v1 v27 v7 (+16 ) = Leq64 <bool> v5 v6 If v7 → b3 b5 (likely) (16) b3 : ← b2 - v34 (+17 ) = And64 <int> v5 v35 v11 (+17 ) = Eq64 <bool> v34 v36 If v11 → b6 b7 (17) b4 : ← b7 b6 - v27 (18 ) = Phi <mem> v14 v17 v23 (+16 ) = Add64 <int> v3 v5 (i[int])Plain → b2 (16) b5 : ← b2 - v25 (+15 ) = MakeResult <mem> v26 Ret v25 (+16 ) b6 : ← b3 - v16 (+21 ) = StaticLECall <mem> {AuxCall{main.f}} v26 v17 (21) = SelectN <mem> [0] v16 Plain → b4 (21) b7 : ← b3 - v13 (+18 ) = StaticLECall <mem> {AuxCall{main.g}} v26 v14 (18) = SelectN <mem> [0] v13 Plain → b4 (+19 ) name i[int]: v4 v5 v20 v21 v22 v23
opt deadcode
opt deadcode [3900 ns] b1 :- v1 (?) = InitMem <mem>v4 (?) = Const64 <int> [8] (i[int])v6 (?) = Const64 <int> [20]v35 (17) = Const64 <int> [7]v36 (17) = Const64 <int> [0]v3 (16) = Const64 <int> [4]Plain → b2 (+16 ) b2 : ← b1 b4 - v5 (16 ) = Phi <int> v4 v23 (i[int])v26 (18 ) = Phi <mem> v1 v27 v7 (+16 ) = Leq64 <bool> v5 v6 If v7 → b3 b5 (likely) (16) b3 : ← b2 - v34 (+17 ) = And64 <int> v5 v35 v11 (+17 ) = Eq64 <bool> v34 v36 If v11 → b6 b7 (17) b4 : ← b7 b6 - v27 (18 ) = Phi <mem> v14 v17 v23 (+16 ) = Add64 <int> v3 v5 (i[int])Plain → b2 (16) b5 : ← b2 - v25 (+15 ) = MakeResult <mem> v26 Ret v25 (+16 ) b6 : ← b3 - v16 (+21 ) = StaticLECall <mem> {AuxCall{main.f}} v26 v17 (21) = SelectN <mem> [0] v16 Plain → b4 (21) b7 : ← b3 - v13 (+18 ) = StaticLECall <mem> {AuxCall{main.g}} v26 v14 (18) = SelectN <mem> [0] v13 Plain → b4 (+19 ) name i[int]: v4 v5 v23
generic cse + phiopt + gcse deadcode + nilcheckelim + prove
generic cse [7100 ns] phiopt [700 ns] gcse deadcode [2200 ns] nilcheckelim [4300 ns] prove [41200 ns] b1 :- v1 (?) = InitMem <mem>v4 (?) = Const64 <int> [8] (i[int])v6 (?) = Const64 <int> [20]v35 (17) = Const64 <int> [7]v36 (17) = Const64 <int> [0]v3 (16) = Const64 <int> [4]v8 (?) = Const64 <int64> [0]Plain → b2 (+16 ) b2 : ← b1 b4 - v5 (16 ) = Phi <int> v4 v23 (i[int])v26 (18 ) = Phi <mem> v1 v27 v7 (+16 ) = Leq64 <bool> v5 v6 If v7 → b3 b5 (likely) (16) b3 : ← b2 - v34 (+17 ) = And64 <int> v5 v35 v11 (+17 ) = Eq64 <bool> v34 v36 If v11 → b6 b7 (17) b4 : ← b7 b6 - v27 (18 ) = Phi <mem> v14 v17 v23 (+16 ) = Add64 <int> v3 v5 (i[int])Plain → b2 (16) b5 : ← b2 - v25 (+15 ) = MakeResult <mem> v26 Ret v25 (+16 ) b6 : ← b3 - v16 (+21 ) = StaticLECall <mem> {AuxCall{main.f}} v26 v17 (21) = SelectN <mem> [0] v16 Plain → b4 (21) b7 : ← b3 - v13 (+18 ) = StaticLECall <mem> {AuxCall{main.g}} v26 v14 (18) = SelectN <mem> [0] v13 Plain → b4 (+19 ) name i[int]: v4 v5 v23
early fuse + expand calls
early fuse [500 ns] expand calls [3600 ns] b1 :- v1 (?) = InitMem <mem>v4 (?) = Const64 <int> [8] (i[int])v6 (?) = Const64 <int> [20]v35 (17) = Const64 <int> [7]v36 (17) = Const64 <int> [0]v3 (16) = Const64 <int> [4]v8 (?) = Const64 <int64> [0]v18 (?) = SB <uintptr>v22 (?) = SP <uintptr>Plain → b2 (+16 ) b2 : ← b1 b4 - v5 (16 ) = Phi <int> v4 v23 (i[int])v26 (18 ) = Phi <mem> v1 v27 v7 (+16 ) = Leq64 <bool> v5 v6 If v7 → b3 b5 (likely) (16) b3 : ← b2 - v34 (+17 ) = And64 <int> v5 v35 v11 (+17 ) = Eq64 <bool> v34 v36 If v11 → b6 b7 (17) b4 : ← b7 b6 - v27 (18 ) = Phi <mem> v14 v17 v23 (+16 ) = Add64 <int> v3 v5 (i[int])Plain → b2 (16) b5 : ← b2 - v25 (+15 ) = MakeResult <mem> v26 Ret v25 (+16 ) b6 : ← b3 - v16 (+21 ) = StaticCall <mem> {AuxCall{main.f}} v26 v17 (21) = SelectN <mem> [0] v16 Plain → b4 (21) b7 : ← b3 - v13 (+18 ) = StaticCall <mem> {AuxCall{main.g}} v26 v14 (18) = SelectN <mem> [0] v13 Plain → b4 (+19 ) name i[int]: v4 v5 v23
decompose builtin + softfloat + late opt
decompose builtin [5400 ns] softfloat [100 ns] late opt [5600 ns] b1 :- v1 (?) = InitMem <mem>v4 (?) = Const64 <int> [8] (i[int])v6 (?) = Const64 <int> [20]v35 (17) = Const64 <int> [7]v36 (17) = Const64 <int> [0]v3 (16) = Const64 <int> [4]Plain → b2 (+16 ) b2 : ← b1 b4 - v5 (16 ) = Phi <int> v4 v23 (i[int])v26 (18 ) = Phi <mem> v1 v27 v7 (+16 ) = Leq64 <bool> v5 v6 If v7 → b3 b5 (likely) (16) b3 : ← b2 - v34 (+17 ) = And64 <int> v5 v35 v11 (+17 ) = Eq64 <bool> v34 v36 If v11 → b6 b7 (17) b4 : ← b7 b6 - v27 (18 ) = Phi <mem> v14 v17 v23 (+16 ) = Add64 <int> v3 v5 (i[int])Plain → b2 (16) b5 : ← b2 - v25 (+15 ) = MakeResult <mem> v26 Ret v25 (+16 ) b6 : ← b3 - v16 (+21 ) = StaticCall <mem> {AuxCall{main.f}} v26 v17 (21) = SelectN <mem> [0] v16 Plain → b4 (21) b7 : ← b3 - v13 (+18 ) = StaticCall <mem> {AuxCall{main.g}} v26 v14 (18) = SelectN <mem> [0] v13 Plain → b4 (+19 ) name i[int]: v4 v5 v23
dead auto elim + sccp
dead auto elim [1900 ns] sccp [18100 ns] b1 :- v1 (?) = InitMem <mem>v4 (?) = Const64 <int> [8] (i[int])v6 (?) = Const64 <int> [20]v35 (17) = Const64 <int> [7]v36 (17) = Const64 <int> [0]v3 (16) = Const64 <int> [4]v22 (+16 ) = ConstBool <bool> [true]v18 (+17 ) = Const64 <int> [0]v8 (+16 ) = ConstBool <bool> [true]v21 (+17 ) = Const64 <int> [0]v20 (+17 ) = ConstBool <bool> [true]v33 (+16 ) = Const64 <int> [12]Plain → b2 (+16 ) b2 : ← b1 b4 - v5 (16 ) = Phi <int> v4 v23 (i[int])v26 (18 ) = Phi <mem> v1 v27 v7 (+16 ) = Leq64 <bool> v5 v6 If v7 → b3 b5 (likely) (16) b3 : ← b2 - v34 (+17 ) = And64 <int> v5 v35 v11 (+17 ) = Eq64 <bool> v34 v36 If v11 → b6 b7 (17) b4 : ← b7 b6 - v27 (18 ) = Phi <mem> v14 v17 v23 (+16 ) = Add64 <int> v3 v5 (i[int])Plain → b2 (16) b5 : ← b2 - v25 (+15 ) = MakeResult <mem> v26 Ret v25 (+16 ) b6 : ← b3 - v16 (+21 ) = StaticCall <mem> {AuxCall{main.f}} v26 v17 (21) = SelectN <mem> [0] v16 Plain → b4 (21) b7 : ← b3 - v13 (+18 ) = StaticCall <mem> {AuxCall{main.g}} v26 v14 (18) = SelectN <mem> [0] v13 Plain → b4 (+19 ) name i[int]: v4 v5 v23
generic deadcode
generic deadcode [4500 ns] b1 :- v1 (?) = InitMem <mem>v4 (?) = Const64 <int> [8] (i[int])v6 (?) = Const64 <int> [20]v35 (+17 ) = Const64 <int> [7]v36 (17) = Const64 <int> [0]v3 (+16 ) = Const64 <int> [4]Plain → b2 (+16 ) b2 : ← b1 b4 - v5 (16 ) = Phi <int> v4 v23 (i[int])v26 (18 ) = Phi <mem> v1 v27 v7 (+16 ) = Leq64 <bool> v5 v6 If v7 → b3 b5 (likely) (16) b3 : ← b2 - v34 (+17 ) = And64 <int> v5 v35 v11 (+17 ) = Eq64 <bool> v34 v36 If v11 → b6 b7 (17) b4 : ← b7 b6 - v27 (18 ) = Phi <mem> v14 v17 v23 (+16 ) = Add64 <int> v3 v5 (i[int])Plain → b2 (16) b5 : ← b2 - v25 (+15 ) = MakeResult <mem> v26 Ret v25 (+16 ) b6 : ← b3 - v16 (+21 ) = StaticCall <mem> {AuxCall{main.f}} v26 v17 (21) = SelectN <mem> [0] v16 Plain → b4 (21) b7 : ← b3 - v13 (+18 ) = StaticCall <mem> {AuxCall{main.g}} v26 v14 (18) = SelectN <mem> [0] v13 Plain → b4 (+19 ) name i[int]: v4 v5 v23
check bce + branchelim + late fuse
check bce [300 ns] branchelim [1000 ns] late fuse [1900 ns] b1 :- v1 (?) = InitMem <mem>v4 (?) = Const64 <int> [8] (i[int])v6 (?) = Const64 <int> [20]v35 (+17 ) = Const64 <int> [7]v36 (17) = Const64 <int> [0]v3 (+16 ) = Const64 <int> [4]v33 (?) = Const64 <int64> [0]Plain → b2 (+16 ) b2 : ← b1 b4 - v5 (16 ) = Phi <int> v4 v23 (i[int])v26 (18 ) = Phi <mem> v1 v27 v7 (+16 ) = Leq64 <bool> v5 v6 If v7 → b3 b5 (likely) (16) b3 : ← b2 - v34 (+17 ) = And64 <int> v5 v35 v11 (+17 ) = Eq64 <bool> v34 v36 If v11 → b6 b7 (17) b4 : ← b7 b6 - v27 (18 ) = Phi <mem> v14 v17 v23 (+16 ) = Add64 <int> v3 v5 (i[int])Plain → b2 (16) b5 : ← b2 - v25 (+15 ) = MakeResult <mem> v26 Ret v25 (+16 ) b6 : ← b3 - v16 (+21 ) = StaticCall <mem> {AuxCall{main.f}} v26 v17 (21) = SelectN <mem> [0] v16 Plain → b4 (21) b7 : ← b3 - v13 (+18 ) = StaticCall <mem> {AuxCall{main.g}} v26 v14 (18) = SelectN <mem> [0] v13 Plain → b4 (+19 ) name i[int]: v4 v5 v23
dse + memcombine + writebarrier + lower
dse [3200 ns] memcombine [1100 ns] writebarrier [1800 ns] lower [18900 ns] b1 :- v1 (?) = InitMem <mem>v4 (?) = MOVQconst <int> [8] (i[int])Plain → b2 (+16 ) b2 : ← b1 b4 - v5 (16 ) = Phi <int> v4 v23 (i[int])v26 (18 ) = Phi <mem> v1 v27 v21 (+16 ) = CMPQconst <flags> [20] v5 LE v21 → b3 b5 (likely) (16) b3 : ← b2 - v18 (+17 ) = TESTQconst <flags> [7] v5 EQ v18 → b6 b7 (17) b4 : ← b7 b6 - v27 (18 ) = Phi <mem> v14 v17 v23 (+16 ) = ADDQconst <int> [4] v5 (i[int])Plain → b2 (16) b5 : ← b2 - v25 (+15 ) = MakeResult <mem> v26 Ret v25 (+16 ) b6 : ← b3 - v16 (+21 ) = CALLstatic <mem> {AuxCall{main.f}} v26 v17 (21) = SelectN <mem> [0] v16 Plain → b4 (21) b7 : ← b3 - v13 (+18 ) = CALLstatic <mem> {AuxCall{main.g}} v26 v14 (18) = SelectN <mem> [0] v13 Plain → b4 (+19 ) name i[int]: v4 v5 v23
addressing modes + late lower + lowered deadcode for cse + lowered cse + elim unread autos + tighten tuple selectors + lowered deadcode + checkLower + late phielim + late copyelim + tighten + late deadcode + critical + phi tighten + likelyadjust + layout
addressing modes [1200 ns] late lower [1400 ns] lowered deadcode for cse [2100 ns] lowered cse [2100 ns] elim unread autos [300 ns] tighten tuple selectors [1100 ns] lowered deadcode [1600 ns] checkLower [300 ns] late phielim [400 ns] late copyelim [500 ns] tighten [7900 ns] late deadcode [1300 ns] critical [900 ns] phi tighten [300 ns] likelyadjust [900 ns] layout [2800 ns] b1 :- v1 (?) = InitMem <mem>v4 (?) = MOVQconst <int> [8] (i[int])Plain → b2 (+16 ) b2 : ← b1 b4 - v5 (16 ) = Phi <int> v4 v23 (i[int])v26 (18 ) = Phi <mem> v1 v27 v21 (+16 ) = CMPQconst <flags> [20] v5 LE v21 → b3 b5 (likely) (16) b3 : ← b2 - v18 (+17 ) = TESTQconst <flags> [7] v5 EQ v18 → b6 b7 (17) b6 : ← b3 - v16 (+21 ) = CALLstatic <mem> {AuxCall{main.f}} v26 v17 (21) = SelectN <mem> [0] v16 Plain → b4 (21) b7 : ← b3 - v13 (+18 ) = CALLstatic <mem> {AuxCall{main.g}} v26 v14 (18) = SelectN <mem> [0] v13 Plain → b4 (+19 ) b4 : ← b7 b6 - v27 (18 ) = Phi <mem> v14 v17 v23 (+16 ) = ADDQconst <int> [4] v5 (i[int])Plain → b2 (16) b5 : ← b2 - v25 (+15 ) = MakeResult <mem> v26 Ret v25 (+16 ) name i[int]: v4 v5 v23
schedule + late nilcheck + flagalloc + regalloc
schedule [6600 ns] late nilcheck [1700 ns] flagalloc [3100 ns] regalloc [37500 ns] b1 :- v1 (?) = InitMem <mem>v11 (?) = MOVQconst <int> [8] : AXPlain → b2 (+16 ) b2 : ← b1 b4 - v5 (16 ) = Phi <int> v11 v23 : AX (i[int])v26 (18 ) = Phi <mem> v1 v27 v21 (+16 ) = CMPQconst <flags> [20] v5 LE v21 → b3 b5 (likely) (16) b3 : ← b2 - v8 (16 ) = StoreReg <int> v5 : i[int]v18 (+17 ) = TESTQconst <flags> [7] v5 EQ v18 → b6 b7 (17) b6 : ← b3 - v16 (+21 ) = CALLstatic <mem> {AuxCall{main.f}} v26 v17 (21) = SelectN <mem> [0] v16 Plain → b4 (21) b7 : ← b3 - v13 (+18 ) = CALLstatic <mem> {AuxCall{main.g}} v26 v14 (18) = SelectN <mem> [0] v13 Plain → b4 (+19 ) b4 : ← b7 b6 - v27 (18 ) = Phi <mem> v14 v17 v34 (16 ) = LoadReg <int> v8 : AXv23 (+16 ) = ADDQconst <int> [4] v34 : AX (i[int])Plain → b2 (16) b5 : ← b2 - v25 (+15 ) = MakeResult <mem> v26 Ret v25 (+16 ) name i[int]: v4 v5 v23
loop rotate
loop rotate [2200 ns] b1 :- v1 (?) = InitMem <mem>v11 (?) = MOVQconst <int> [8] : AXPlain → b2 (+16 ) b4 : ← b7 b6 - v27 (18 ) = Phi <mem> v14 v17 v34 (16 ) = LoadReg <int> v8 : AXv23 (+16 ) = ADDQconst <int> [4] v34 : AX (i[int])Plain → b2 (16) b2 : ← b1 b4 - v5 (16 ) = Phi <int> v11 v23 : AX (i[int])v26 (18 ) = Phi <mem> v1 v27 v21 (+16 ) = CMPQconst <flags> [20] v5 LE v21 → b3 b5 (likely) (16) b3 : ← b2 - v8 (16 ) = StoreReg <int> v5 : i[int]v18 (+17 ) = TESTQconst <flags> [7] v5 EQ v18 → b6 b7 (17) b6 : ← b3 - v16 (+21 ) = CALLstatic <mem> {AuxCall{main.f}} v26 v17 (21) = SelectN <mem> [0] v16 Plain → b4 (21) b7 : ← b3 - v13 (+18 ) = CALLstatic <mem> {AuxCall{main.g}} v26 v14 (18) = SelectN <mem> [0] v13 Plain → b4 (+19 ) b5 : ← b2 - v25 (+15 ) = MakeResult <mem> v26 Ret v25 (+16 ) name i[int]: v4 v5 v23
trim
trim [400 ns] b1 :- v1 (?) = InitMem <mem>v11 (?) = MOVQconst <int> [8] : AXPlain → b2 (+16 ) b4 : ← b7 b6 - v27 (18 ) = Phi <mem> v14 v17 v34 (16 ) = LoadReg <int> v8 : AXv23 (+16 ) = ADDQconst <int> [4] v34 : AX (i[int])Plain → b2 (16) b2 : ← b1 b4 - v5 (16 ) = Phi <int> v11 v23 : AX (i[int])v26 (18 ) = Phi <mem> v1 v27 v21 (+16 ) = CMPQconst <flags> [20] v5 LE v21 → b3 b5 (likely) (16) b3 : ← b2 - v8 (16 ) = StoreReg <int> v5 : i[int]v18 (+17 ) = TESTQconst <flags> [7] v5 EQ v18 → b6 b7 (17) b6 : ← b3 - v16 (+21 ) = CALLstatic <mem> {AuxCall{main.f}} v26 v17 (21) = SelectN <mem> [0] v16 Plain → b4 (21) b7 : ← b3 - v13 (+18 ) = CALLstatic <mem> {AuxCall{main.g}} v26 v14 (18) = SelectN <mem> [0] v13 Plain → b4 (+19 ) b5 : ← b2 - v25 (+15 ) = MakeResult <mem> v26 Ret v25 (+16 ) name i[int]: v4 v5 v23
genssa
genssa # /home/rileythomp/github/go/demo3.go 00000 (15) TEXT main.main(SB), ABIInternal 00001 (15) FUNCDATA $0, gclocals·g2BeySu+wFnoycgXfElmcg==(SB) 00002 (15) FUNCDATA $1, gclocals·g2BeySu+wFnoycgXfElmcg==(SB) v11 00003 (15 ) MOVL $8, AX b1 00004 (16 ) JMP 7 v34 00005 (+16 ) MOVQ main.i-8(SP), AX v23 00006 (16 ) ADDQ $4, AX v21 00007 (+16 ) CMPQ AX, $20 b2 00008 (16 ) JGT 17 v8 00009 (16 ) MOVQ AX, main.i-8(SP) v18 00010 (+17 ) TESTQ $7, AX b3 00011 (17 ) JNE 15 v16 00012 (+21 ) PCDATA $1, $0 v16 00013 (+21 ) CALL main.f(SB) b6 00014 (21 ) JMP 5 v13 00015 (+18 ) CALL main.g(SB) b7 00016 (+19 ) JMP 5 b5 00017 (+16 ) RET 00018 (?) END