mirror of
https://github.com/golang/go
synced 2024-11-23 19:50:06 -07:00
d585f04fd3
Whether a truncation should become a MOVWreg or a MOVWZreg doesn't depend on the type of the operand, it depends on the type of the final result. If the final result is unsigned, we can use MOVWZreg. If the final result is signed, we can use MOVWreg. Checking the type of the operand does the wrong thing if truncating an unsigned value to a signed value, or vice-versa. Fixes #29943 Change-Id: Ia6fc7d006486fa02cffd0bec4d910bdd5b6365f8 Reviewed-on: https://go-review.googlesource.com/c/159760 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
29 lines
558 B
Go
29 lines
558 B
Go
// run
|
|
|
|
// Copyright 2019 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// Code was miscompiled on ppc64le due to incorrect zero-extension
|
|
// that was CSE'd.
|
|
|
|
package main
|
|
|
|
//go:noinline
|
|
func g(i uint64) uint64 {
|
|
return uint64(uint32(i))
|
|
}
|
|
|
|
var sink uint64
|
|
|
|
func main() {
|
|
for i := uint64(0); i < 1; i++ {
|
|
i32 := int32(i - 1)
|
|
sink = uint64((uint32(i32) << 1) ^ uint32((i32 >> 31)))
|
|
x := g(uint64(i32))
|
|
if x != uint64(uint32(i32)) {
|
|
panic(x)
|
|
}
|
|
}
|
|
}
|