aboutsummaryrefslogtreecommitdiff
path: root/test/codegen
diff options
context:
space:
mode:
authorPaul E. Murphy <murp@ibm.com>2022-10-12 14:02:38 -0500
committerPaul Murphy <murp@ibm.com>2022-11-14 19:44:47 +0000
commitdc6b7c86df3cac29c3506ef8b251345b8d914496 (patch)
tree5c0e966e9a2e15fd123d7daa15bdd04b2ac23b8f /test/codegen
parent24fc64028c0faa7fcbdae2bf2a2ded825713c982 (diff)
downloadgo-dc6b7c86df3cac29c3506ef8b251345b8d914496.tar.xz
cmd/compile: merge zero constant ISEL in PPC64 lateLower pass
Add a new SSA opcode ISELZ, similar to ISELB to represent a select of value or 0. Then, merge candidate ISEL opcodes inside the late lower pass. This avoids complicating rules within the the lower pass. Change-Id: I3b14c94b763863aadc834b0e910a85870c131313 Reviewed-on: https://go-review.googlesource.com/c/go/+/442596 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Run-TryBot: Paul Murphy <murp@ibm.com> Reviewed-by: Joedian Reid <joedian@golang.org>
Diffstat (limited to 'test/codegen')
-rw-r--r--test/codegen/condmove.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/codegen/condmove.go b/test/codegen/condmove.go
index bfab62213b..7b0f32e708 100644
--- a/test/codegen/condmove.go
+++ b/test/codegen/condmove.go
@@ -440,3 +440,27 @@ func cmovzero2(c bool) int {
// loong64:"MASKNEZ", -"MASKEQZ"
return x
}
+
+// Conditionally selecting between a value or 0 can be done without
+// an extra load of 0 to a register on PPC64 by using R0 (which always
+// holds the value $0) instead. Verify both cases where either arg1
+// or arg2 is zero.
+func cmovzeroreg0(a, b int) int {
+ x := 0
+ if a == b {
+ x = a
+ }
+ // ppc64:"ISEL\t[$]2, R[0-9]+, R0, R[0-9]+"
+ // ppc64le:"ISEL\t[$]2, R[0-9]+, R0, R[0-9]+"
+ return x
+}
+
+func cmovzeroreg1(a, b int) int {
+ x := a
+ if a == b {
+ x = 0
+ }
+ // ppc64:"ISEL\t[$]2, R0, R[0-9]+, R[0-9]+"
+ // ppc64le:"ISEL\t[$]2, R0, R[0-9]+, R[0-9]+"
+ return x
+}