Skip to content

Instantly share code, notes, and snippets.

@csabahruska
Created November 28, 2018 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csabahruska/fdc0390545b86378e6d355fe9c30e45d to your computer and use it in GitHub Desktop.
Save csabahruska/fdc0390545b86378e6d355fe9c30e45d to your computer and use it in GitHub Desktop.
optimized sum simple code with boxed literals
grinMain =
v.0 <- pure (Cint64 1)
ptr_lit.1.0 <- store v.0
v.3 <- pure (Cint64 10)
ptr_lit.2.0 <- store v.3
ww.s15120.0.56.3.arity.1.0 <- pure 1
ww1.s15121.0.56.3.arity.1.0 <- pure 10
r_45.0.0 <- _prim_int_gt $ ww.s15120.0.56.3.arity.1.0 ww1.s15121.0.56.3.arity.1.0
unboxed.Cint64.3.0 <- case r_45.0.0 of
#False ->
pure 0
#True ->
pure ww.s15120.0.56.3.arity.1.0
sat.s15127.1.0 <- case unboxed.Cint64.3.0 of
#default ->
v.4 <- pure (F"Main.$wupto.closure.0" ptr_lit.1.0 ptr_lit.2.0)
sat.s15125.0.0 <- store v.4
v.5 <- pure (C"GHC.Types.I#" ptr_lit.1.0)
sat.s15123.1.0 <- store v.5
pure (CMain.Cons sat.s15123.1.0 sat.s15125.0.0)
1 ->
pure (CMain.Nil)
ptr_sat.s15127.1.0.0 <- store sat.s15127.1.0
ptr_lit.3.123.6.arity.1.0 <- pure 0
unboxed.Cint64.1.0 <- "Main.$wxsum.unboxed" $ ptr_lit.3.123.6.arity.1.0 ptr_sat.s15127.1.0.0
_prim_int_print $ unboxed.Cint64.1.0
_prim_int_print $ 0
"Main.$wxsum.unboxed" ww.s15112.0.123.arity.1 w.s15113.0 =
v.10 <- fetch w.s15113.0
wild.s15114.0 <- case v.10 of
#default ->
pure v.10
(F"Main.$wupto.closure.0" a.2.0 a.3.0) ->
v.11 <- fetch a.2.0
(Cint64 a.2.0.123.3.arity.1) <- pure v.11
ptr_lit.0.56.4.arity.1.0 <- pure 1
unboxed.Cint64.4.0 <- _prim_int_add $ a.2.0.123.3.arity.1 ptr_lit.0.56.4.arity.1.0
v.12 <- pure (Cint64 unboxed.Cint64.4.0)
ptr_sat.s15124.0.0.0 <- store v.12
v.13 <- fetch a.3.0
(Cint64 ww1.s15121.0.56.3.arity.1.1) <- pure v.13
r_45.0.1 <- _prim_int_gt $ unboxed.Cint64.4.0 ww1.s15121.0.56.3.arity.1.1
unboxed.Cint64.3.1 <- case r_45.0.1 of
#False ->
pure 0
#True ->
pure ptr_lit.0.56.4.arity.1.0
case unboxed.Cint64.3.1 of
#default ->
v.16 <- pure (F"Main.$wupto.closure.0" ptr_sat.s15124.0.0.0 a.3.0)
sat.s15125.0.1 <- store v.16
v.17 <- pure (C"GHC.Types.I#" ptr_sat.s15124.0.0.0)
sat.s15123.1.1 <- store v.17
pure (CMain.Cons sat.s15123.1.1 sat.s15125.0.1)
1 ->
pure (CMain.Nil)
case wild.s15114.0 of
(CMain.Nil) ->
pure ww.s15112.0.123.arity.1
(CMain.Cons x.s15115.0 xs.s15116.0) ->
v.24 <- fetch x.s15115.0
(C"GHC.Types.I#" y.s15118.0) <- pure v.24
v.25 <- fetch y.s15118.0
(Cint64 y.s15118.0.56.9.arity.1) <- pure v.25
unboxed.Cint64.5 <- _prim_int_add $ ww.s15112.0.123.arity.1 y.s15118.0.56.9.arity.1
"Main.$wxsum.unboxed" $ unboxed.Cint64.5 xs.s15116.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment