]> Cypherpunks repositories - gostls13.git/commit
[dev.ssa] cmd/compile: better ANDAND and OROR in IF and FOR
authorKeith Randall <khr@golang.org>
Tue, 3 Nov 2015 00:56:53 +0000 (16:56 -0800)
committerKeith Randall <khr@golang.org>
Tue, 3 Nov 2015 17:22:27 +0000 (17:22 +0000)
commit991873116e316f334f41343bb9bbd97720b0ee29
tree41e98f5d2c1a33bee96ef9432435ea1e0520282e
parent729abfa35ca19a3ec9bd11a8c25eecac5eba6cc9
[dev.ssa] cmd/compile: better ANDAND and OROR in IF and FOR

For the statement

    if a && b { target }

the old code allocated a new variable v and did:

    v = a
    if a {
       v = b
    }
    if v { goto target }

The new code does:

    if a {
      if b { goto target }
    }

The new arrangement tends to generate much more efficient code.  In
particular, there is no temporary variable and there is only one join
point instead of two.

The old code is still used for ANDAND and OROR which are not
direct descendents of IF or FOR statements.

Change-Id: I082f246d27c823c6f32d1287300e4b0911607507
Reviewed-on: https://go-review.googlesource.com/16584
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
src/cmd/compile/internal/gc/ssa.go