Skip to content

[AUTOMATED] Preserve Go result pairs across signedness conversions - #1771

Merged
mahaloz merged 1 commit into
mainfrom
fix/go-result-pair-signedness
Nov 19, 2026
Merged

mahaloz merged 1 commit into
mainfrom
fix/go-result-pair-signedness

Conversation

@mahaloz

@mahaloz mahaloz commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

[AUTOMATED] Go output can cast an entire result struct even when both fields change signedness. Go rejects that cast.

d=$(mktemp -d)
cat > "$d/pair.go" <<'GO'
package main
//go:noinline
func Words(a int64, b uint64) (int64, uint64) { return a - 3, b ^ (1 << 63) }
//go:noinline
func Retype(a int64, b uint64) (uint64, int64) {
    x, y := Words(a, b)
    return uint64(x), int64(y)
}
func main() { x, y := Retype(-9, 11); println(x, y) }
GO
CGO_ENABLED=0 go build -trimpath -o "$d/pair" "$d/pair.go"
kuna decompile "$d/pair" main.Retype --language go

Stock wraps the signed pair in struct { result0 uint64; result1 int64 }(...). The fix evaluates the pair once and builds the target fields with uint64(v.result0) and int64(v.result1).

The stage covers a direct return, a merged result, and alias and ordering controls.

Median paired CPU time for the affected Go output rose 2.0% with Go 1.22 and fell 0.2% with Go 1.27.

Convert verified Go integer result lanes independently while evaluating the source pair once.
@mahaloz
mahaloz merged commit 24eb881 into main Nov 19, 2026
9 checks passed
@mahaloz
mahaloz deleted the fix/go-result-pair-signedness branch November 19, 2026 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant