]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: optimize comparisons with immediates on s390x
authorMichael Munday <mike.munday@ibm.com>
Fri, 17 Apr 2020 12:05:07 +0000 (05:05 -0700)
committerMichael Munday <mike.munday@ibm.com>
Tue, 21 Apr 2020 19:23:51 +0000 (19:23 +0000)
commite464d7d7970be972a17a98c7ad996c2db4a04997
treecb93a31efb12684ab2c3fc36ee09dc9538e0518e
parent099c6116ccb11595620148cd1a321bd216d37e2b
cmd/compile: optimize comparisons with immediates on s390x

When generating code for unsigned equals (==) and not equals (!=)
comparisons we currently, on s390x, always use signed comparisons.

This mostly works well, however signed comparisons on s390x sign
extend their immediates and unsigned comparisons zero extend them.
For compare-and-branch instructions which can only have 8-bit
immediates this significantly changes the range of immediate values
we can represent: [-128, 127] for signed comparisons and [0, 255]
for unsigned comparisons.

When generating equals and not equals checks we don't neet to worry
about whether the comparison is signed or unsigned. This CL
therefore adds rules to allow us to switch signedness for such
comparisons if it means that it brings a constant into range for an
8-bit immediate.

For example, a signed equals with an integer in the range [128, 255]
will now be implemented using an unsigned compare-and-branch
instruction rather than separate compare and branch instructions.

As part of this change I've also added support for adding a name
to block control values using the same `x:(...)` syntax we use for
value rules.

Triggers 792 times when compiling cmd and std.

Change-Id: I77fa80a128f0a8ce51a2888d1e384bd5e9b61a77
Reviewed-on: https://go-review.googlesource.com/c/go/+/228642
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/gen/rulegen.go
src/cmd/compile/internal/ssa/rewriteS390X.go
test/codegen/compare_and_branch.go