From 455d4f41fb1c2bf48645b4904a8ee293272c90db Mon Sep 17 00:00:00 2001 From: Jorropo Date: Tue, 7 Apr 2026 11:57:56 +0200 Subject: cmd/compile: run CondSelect into math rules on all arches Fixes #78558 I've also added tests to make sure PPC still generate ISEL when the constant isn't 1. This is to make sure we aren't generating a sequence that wouldn't work right now. But it does not mean we couldn't try to optimize other constants on PPC64 if a fast sequence exists; for example like arm64's inline register shifts. Change-Id: Ic241d593149b7a11533948f5d4c52db357cc134f Reviewed-on: https://go-review.googlesource.com/c/go/+/763340 Reviewed-by: Keith Randall Auto-Submit: Jorropo Reviewed-by: David Chase LUCI-TryBot-Result: Go LUCI Reviewed-by: Jayanth Krishnamurthy Reviewed-by: Paul Murphy --- src/cmd/compile/internal/ssa/rewrite.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') 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 } -- cgit v1.3-5-g9baa