aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cmd/compile/internal/ssa/rewrite.go3
-rw-r--r--test/codegen/condmove.go20
2 files changed, 23 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssa/rewrite.go b/src/cmd/compile/internal/ssa/rewrite.go
index 008767f19c..eefabfba2f 100644
--- a/src/cmd/compile/internal/ssa/rewrite.go
+++ b/src/cmd/compile/internal/ssa/rewrite.go
@@ -2834,6 +2834,9 @@ func rewriteCondSelectIntoMath(config *Config, op Op, constant int64) bool {
return true
}
}
+ default:
+ // TODO: fine tune for other architectures.
+ return constant == 1
}
return false
}
diff --git a/test/codegen/condmove.go b/test/codegen/condmove.go
index 43ca9a961f..8527ff2896 100644
--- a/test/codegen/condmove.go
+++ b/test/codegen/condmove.go
@@ -481,6 +481,7 @@ func cmovmathadd2(a uint, b bool) uint {
}
// amd64:"LEAQ" -"CMOV" -"MUL"
// arm64:"ADD R[0-9]+<<1" -"CSEL" -"MUL"
+ // ppc64x: "ISEL" -"MUL"
return a
}
func cmovmathadd2else(a uint, b bool) uint {
@@ -489,6 +490,7 @@ func cmovmathadd2else(a uint, b bool) uint {
}
// amd64:"LEAQ" -"CMOV" -"MUL"
// arm64:"ADD R[0-9]+<<1" -"CSEL" -"MUL"
+ // ppc64x: "ISEL" -"MUL"
return a
}
@@ -498,6 +500,7 @@ func cmovmathadd4(a uint, b bool) uint {
}
// amd64:"LEAQ" -"CMOV" -"MUL"
// arm64:"ADD R[0-9]+<<2" -"CSEL" -"MUL"
+ // ppc64x: "ISEL" -"MUL"
return a
}
func cmovmathadd4else(a uint, b bool) uint {
@@ -506,6 +509,7 @@ func cmovmathadd4else(a uint, b bool) uint {
}
// amd64:"LEAQ" -"CMOV" -"MUL"
// arm64:"ADD R[0-9]+<<2" -"CSEL" -"MUL"
+ // ppc64x: "ISEL" -"MUL"
return a
}
@@ -515,6 +519,7 @@ func cmovmathadd8(a uint, b bool) uint {
}
// amd64:"LEAQ" -"CMOV" -"MUL"
// arm64:"ADD R[0-9]+<<3" -"CSEL" -"MUL"
+ // ppc64x: "ISEL" -"MUL"
return a
}
func cmovmathadd8else(a uint, b bool) uint {
@@ -523,6 +528,7 @@ func cmovmathadd8else(a uint, b bool) uint {
}
// amd64:"LEAQ" -"CMOV" -"MUL"
// arm64:"ADD R[0-9]+<<3" -"CSEL" -"MUL"
+ // ppc64x: "ISEL" -"MUL"
return a
}
@@ -531,6 +537,7 @@ func cmovmathadd9223372036854775808(a uint, b bool) uint {
a += 1 << 63
}
// arm64:"ADD R[0-9]+<<63" -"CSEL" -"MUL"
+ // ppc64x: "ISEL" -"MUL"
return a
}
func cmovmathadd9223372036854775808else(a uint, b bool) uint {
@@ -538,6 +545,7 @@ func cmovmathadd9223372036854775808else(a uint, b bool) uint {
a += 1 << 63
}
// arm64:"ADD R[0-9]+<<63" -"CSEL" -"MUL"
+ // ppc64x: "ISEL" -"MUL"
return a
}
@@ -567,6 +575,7 @@ func cmovmathsub2(a uint, b bool) uint {
a -= 2
}
// arm64 :"SUB R[0-9]+<<1" -"CSEL" -"MUL"
+ // ppc64x: "ISEL" -"MUL"
return a
}
func cmovmathsub2else(a uint, b bool) uint {
@@ -574,6 +583,7 @@ func cmovmathsub2else(a uint, b bool) uint {
a -= 2
}
// arm64 :"SUB R[0-9]+<<1" -"CSEL" -"MUL"
+ // ppc64x: "ISEL" -"MUL"
return a
}
@@ -584,6 +594,7 @@ func cmovmathsub9223372036854775808(a uint, b bool) uint {
a -= 1 << 63
}
// arm64:"(SUB|ADD) R[0-9]+<<63" -"CSEL" -"MUL"
+ // ppc64x: "ISEL" -"MUL"
return a
}
func cmovmathsub9223372036854775808else(a uint, b bool) uint {
@@ -591,6 +602,7 @@ func cmovmathsub9223372036854775808else(a uint, b bool) uint {
a -= 1 << 63
}
// arm64:"(SUB|ADD) R[0-9]+<<63" -"CSEL" -"MUL"
+ // ppc64x: "ISEL" -"MUL"
return a
}
@@ -685,6 +697,7 @@ func cmovmathor2(a uint, b bool) uint {
a |= 2
}
// arm64:"ORR R[0-9]+<<1" -"CSEL" -"MUL"
+ // ppc64x:"ISEL" -"MUL"
return a
}
func cmovmathor2else(a uint, b bool) uint {
@@ -692,6 +705,7 @@ func cmovmathor2else(a uint, b bool) uint {
a |= 2
}
// arm64:"ORR R[0-9]+<<1" -"CSEL" -"MUL"
+ // ppc64x:"ISEL" -"MUL"
return a
}
@@ -700,6 +714,7 @@ func cmovmathor9223372036854775808(a uint, b bool) uint {
a |= 1 << 63
}
// arm64:"ORR R[0-9]+<<63" -"CSEL" -"MUL"
+ // ppc64x:"ISEL" -"MUL"
return a
}
func cmovmathor9223372036854775808else(a uint, b bool) uint {
@@ -707,6 +722,7 @@ func cmovmathor9223372036854775808else(a uint, b bool) uint {
a |= 1 << 63
}
// arm64:"ORR R[0-9]+<<63" -"CSEL" -"MUL"
+ // ppc64x:"ISEL" -"MUL"
return a
}
@@ -736,6 +752,7 @@ func cmovmathxor2(a uint, b bool) uint {
a ^= 2
}
// arm64:"EOR R[0-9]+<<1" -"CSEL" -"MUL"
+ // ppc64x: "ISEL" -"MUL"
return a
}
func cmovmathxor2else(a uint, b bool) uint {
@@ -743,6 +760,7 @@ func cmovmathxor2else(a uint, b bool) uint {
a ^= 2
}
// arm64:"EOR R[0-9]+<<1" -"CSEL" -"MUL"
+ // ppc64x: "ISEL" -"MUL"
return a
}
@@ -751,6 +769,7 @@ func cmovmathxor9223372036854775808(a uint, b bool) uint {
a ^= 1 << 63
}
// arm64:"EOR R[0-9]+<<63" -"CSEL" -"MUL"
+ // ppc64x: "ISEL" -"MUL"
return a
}
func cmovmathxor9223372036854775808else(a uint, b bool) uint {
@@ -758,6 +777,7 @@ func cmovmathxor9223372036854775808else(a uint, b bool) uint {
a ^= 1 << 63
}
// arm64:"EOR R[0-9]+<<63" -"CSEL" -"MUL"
+ // ppc64x: "ISEL" -"MUL"
return a
}