cgen: emit "break/continue" not "goto", part 3

A selection of benchmarks below. Some are up, some are down.

name                                                                old speed      new speed      delta

wuffs_bzip2_decode_10k/clang11                                      59.5MB/s ± 0%  59.1MB/s ± 0%   -0.72%  (p=0.008 n=5+5)
wuffs_bzip2_decode_100k/clang11                                     49.6MB/s ± 1%  47.4MB/s ± 0%   -4.48%  (p=0.008 n=5+5)

wuffs_bzip2_decode_10k/gcc10                                        59.0MB/s ± 0%  59.8MB/s ± 0%   +1.40%  (p=0.008 n=5+5)
wuffs_bzip2_decode_100k/gcc10                                       49.8MB/s ± 2%  53.0MB/s ± 0%   +6.51%  (p=0.008 n=5+5)

wuffs_deflate_decode_1k_full_init/clang11                            184MB/s ± 0%   182MB/s ± 0%   -1.06%  (p=0.008 n=5+5)
wuffs_deflate_decode_1k_part_init/clang11                            213MB/s ± 0%   211MB/s ± 0%   -0.65%  (p=0.008 n=5+5)
wuffs_deflate_decode_10k_full_init/clang11                           399MB/s ± 0%   409MB/s ± 0%   +2.68%  (p=0.008 n=5+5)
wuffs_deflate_decode_10k_part_init/clang11                           409MB/s ± 0%   421MB/s ± 0%   +2.96%  (p=0.008 n=5+5)
wuffs_deflate_decode_100k_just_one_read/clang11                      518MB/s ± 0%   517MB/s ± 0%     ~     (p=0.095 n=5+5)
wuffs_deflate_decode_100k_many_big_reads/clang11                     322MB/s ± 0%   319MB/s ± 0%   -0.93%  (p=0.008 n=5+5)

wuffs_deflate_decode_1k_full_init/gcc10                              173MB/s ± 0%   175MB/s ± 0%   +1.07%  (p=0.008 n=5+5)
wuffs_deflate_decode_1k_part_init/gcc10                              205MB/s ± 0%   208MB/s ± 0%   +1.26%  (p=0.008 n=5+5)
wuffs_deflate_decode_10k_full_init/gcc10                             408MB/s ± 0%   396MB/s ± 0%   -2.94%  (p=0.008 n=5+5)
wuffs_deflate_decode_10k_part_init/gcc10                             421MB/s ± 0%   408MB/s ± 0%   -2.88%  (p=0.008 n=5+5)
wuffs_deflate_decode_100k_just_one_read/gcc10                        542MB/s ± 0%   519MB/s ± 0%   -4.13%  (p=0.008 n=5+5)
wuffs_deflate_decode_100k_many_big_reads/gcc10                       340MB/s ± 0%   327MB/s ± 0%   -3.77%  (p=0.008 n=5+5)

wuffs_json_decode_1k/clang11                                        1.26GB/s ± 0%  1.34GB/s ± 0%   +6.90%  (p=0.008 n=5+5)
wuffs_json_decode_21k_formatted/clang11                              681MB/s ± 0%   684MB/s ± 0%   +0.47%  (p=0.008 n=5+5)
wuffs_json_decode_26k_compact/clang11                               1.00GB/s ± 0%  1.14GB/s ± 0%  +14.26%  (p=0.008 n=5+5)
wuffs_json_decode_217k_stringy/clang11                               786MB/s ± 0%   907MB/s ± 0%  +15.40%  (p=0.008 n=5+5)

wuffs_json_decode_1k/gcc10                                          1.20GB/s ± 0%  1.22GB/s ± 0%   +1.41%  (p=0.008 n=5+5)
wuffs_json_decode_21k_formatted/gcc10                                681MB/s ± 0%   719MB/s ± 0%   +5.59%  (p=0.008 n=5+5)
wuffs_json_decode_26k_compact/gcc10                                  957MB/s ± 0%   976MB/s ± 0%   +1.94%  (p=0.008 n=5+5)
wuffs_json_decode_217k_stringy/gcc10                                 773MB/s ± 0%   781MB/s ± 0%   +1.01%  (p=0.008 n=5+5)

wuffs_png_decode_image_19k_8bpp/clang11                              256MB/s ± 0%   256MB/s ± 0%     ~     (p=0.421 n=5+5)
wuffs_png_decode_image_40k_24bpp/clang11                             311MB/s ± 0%   313MB/s ± 0%   +0.57%  (p=0.008 n=5+5)
wuffs_png_decode_image_77k_8bpp/clang11                              907MB/s ± 0%   904MB/s ± 0%   -0.28%  (p=0.008 n=5+5)
wuffs_png_decode_image_552k_32bpp_ignore_checksum/clang11            821MB/s ± 0%   812MB/s ± 0%   -1.08%  (p=0.008 n=5+5)
wuffs_png_decode_image_552k_32bpp_verify_checksum/clang11            790MB/s ± 0%   782MB/s ± 0%   -0.94%  (p=0.008 n=5+5)
wuffs_png_decode_image_4002k_24bpp/clang11                           315MB/s ± 0%   315MB/s ± 0%   -0.09%  (p=0.008 n=5+5)

wuffs_png_decode_image_19k_8bpp/gcc10                                266MB/s ± 0%   273MB/s ± 0%   +2.94%  (p=0.008 n=5+5)
wuffs_png_decode_image_40k_24bpp/gcc10                               329MB/s ± 0%   324MB/s ± 2%   -1.65%  (p=0.008 n=5+5)
wuffs_png_decode_image_77k_8bpp/gcc10                                952MB/s ± 2%   967MB/s ± 0%   +1.57%  (p=0.016 n=5+4)
wuffs_png_decode_image_552k_32bpp_ignore_checksum/gcc10              871MB/s ± 0%   894MB/s ± 0%   +2.59%  (p=0.029 n=4+4)
wuffs_png_decode_image_552k_32bpp_verify_checksum/gcc10              831MB/s ± 0%   851MB/s ± 0%   +2.45%  (p=0.008 n=5+5)
wuffs_png_decode_image_4002k_24bpp/gcc10                             336MB/s ± 0%   335MB/s ± 0%   -0.53%  (p=0.008 n=5+5)
This commit is contained in:
Nigel Tao committed 2023-06-23 21:04:24 +10:00
1 parent de55ff7746
commit 66ef485efa
2 files changed
+224 -344

No files matched your search

+7 -14
View File
@@ -532,21 +532,17 @@ func (g *gen) writeStatementIterate(b *buffer, n *a.Iterate, depth uint32) error
}
func (g *gen) writeStatementJump(b *buffer, n *a.Jump, depth uint32) error {
jt, err := g.currFunk.jumpTarget(g.tm, n.JumpTarget())
if err != nil {
return err
}
keyword := "continue"
if n.Keyword() == t.IDBreak {
keyword = "break"
}
// TODO: apply to all generated code, not just wuffs_jpeg__etc.
if (n.JumpTarget() == g.currFunk.activeLoops.Top()) &&
(strings.HasPrefix(g.currFunk.cName, "wuffs_jpeg__")) {
if n.JumpTarget() == g.currFunk.activeLoops.Top() {
b.printf("%s;\n", keyword)
return nil
} else if jt, err := g.currFunk.jumpTarget(g.tm, n.JumpTarget()); err != nil {
return err
} else {
b.printf("goto label__%s__%s;\n", jt, keyword)
}
b.printf("goto label__%s__%s;\n", jt, keyword)
return nil
}
@@ -632,10 +628,7 @@ func (g *gen) writeStatementRet(b *buffer, n *a.Ret, depth uint32) error {
}
func (g *gen) writeStatementWhile(b *buffer, n *a.While, depth uint32) error {
// TODO: apply to all generated code, not just wuffs_jpeg__etc.
stagedRollout := !strings.HasPrefix(g.currFunk.cName, "wuffs_jpeg__")
if n.HasDeepContinue() || (stagedRollout && n.HasContinue()) {
if n.HasDeepContinue() {
jt, err := g.currFunk.jumpTarget(g.tm, n)
if err != nil {
return err
@@ -658,7 +651,7 @@ func (g *gen) writeStatementWhile(b *buffer, n *a.While, depth uint32) error {
b.writes("}\n")
g.currFunk.activeLoops.Pop()
if n.HasDeepBreak() || (stagedRollout && n.HasBreak()) {
if n.HasDeepBreak() {
jt, err := g.currFunk.jumpTarget(g.tm, n)
if err != nil {
return err