]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: clean up codegen for branch-on-carry on s390x
authorMichael Munday <mike.munday@ibm.com>
Mon, 17 Feb 2020 11:43:33 +0000 (03:43 -0800)
committerMichael Munday <mike.munday@ibm.com>
Wed, 22 Apr 2020 20:11:06 +0000 (20:11 +0000)
commitab7a65f2837b693f015f47572b6bf2c8f1062288
tree707bff72fe84b42a903f06fa897a4ba2817b8228
parent81df5e69fc189af44459a4c6520b1c99d0210a92
cmd/compile: clean up codegen for branch-on-carry on s390x

This CL optimizes code that uses a carry from a function such as
bits.Add64 as the condition in an if statement. For example:

    x, c := bits.Add64(a, b, 0)
    if c != 0 {
        panic("overflow")
    }

Rather than converting the carry into a 0 or a 1 value and using
that as an input to a comparison instruction the carry flag is now
used as the input to a conditional branch directly. This typically
removes an ADD LOGICAL WITH CARRY instruction when user code is
doing overflow detection and is closer to the code that a user
would expect to generate.

Change-Id: I950431270955ab72f1b5c6db873b6abe769be0da
Reviewed-on: https://go-review.googlesource.com/c/go/+/219757
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/ssa/gen/S390X.rules
src/cmd/compile/internal/ssa/rewriteS390X.go
src/cmd/internal/obj/s390x/condition_code.go
src/math/bits/bits_test.go
test/codegen/mathbits.go