21 lines
755 B
Plaintext
21 lines
755 B
Plaintext
;;;; A hot loop of struct copies.
|
|
;;;;
|
|
;;;; The suspected cost is `rep movsb`: this backend copies an aggregate by
|
|
;;;; block-moving bytes, where LLVM either keeps the thing in registers or
|
|
;;;; emits a handful of wide moves. Eight i64 fields is 64 bytes -- big
|
|
;;;; enough that a copy is a real copy, small enough that `rep movsb` is
|
|
;;;; paying its setup cost on every one of them, which is the shape the
|
|
;;;; instruction is worst at.
|
|
|
|
(defstruct Big [a i64 b i64 c i64 d i64 e i64 f i64 g i64 h i64])
|
|
|
|
(defn main [] i32
|
|
(let [acc (i64 0)
|
|
v (Big {.a 1 .b 2 .c 3 .d 4 .e 5 .f 6 .g 7 .h 8})]
|
|
(dotimes [i 2000000]
|
|
(let [w v]
|
|
(set (.a v) (+ (.h w) 1))
|
|
(set acc (+ acc (.a w)))))
|
|
(print acc) (println ""))
|
|
0)
|