diff options
| author | Jorropo <jorropo.pgm@gmail.com> | 2026-04-07 11:57:56 +0200 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2026-04-09 04:42:54 -0700 |
| commit | 455d4f41fb1c2bf48645b4904a8ee293272c90db (patch) | |
| tree | 6c845ced29a36abeccabbc6e092691b1f7e0631d /src/cmd/compile/internal | |
| parent | 996b985008c7615004c0dbe8b031928faff3c993 (diff) | |
| download | go-455d4f41fb1c2bf48645b4904a8ee293272c90db.tar.xz | |
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 <khr@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jayanth Krishnamurthy <jayanth.krishnamurthy@ibm.com>
Reviewed-by: Paul Murphy <paumurph@redhat.com>
Diffstat (limited to 'src/cmd/compile/internal')
| -rw-r--r-- | src/cmd/compile/internal/ssa/rewrite.go | 3 |
1 files changed, 3 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 } |
