Source file test/fixedbugs/issue29943.go

     1  // run
     2  
     3  // Copyright 2019 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  // Code was miscompiled on ppc64le due to incorrect zero-extension
     8  // that was CSE'd.
     9  
    10  package main
    11  
    12  //go:noinline
    13  func g(i uint64) uint64 {
    14  	return uint64(uint32(i))
    15  }
    16  
    17  var sink uint64
    18  
    19  func main() {
    20  	for i := uint64(0); i < 1; i++ {
    21  		i32 := int32(i - 1)
    22  		sink = uint64((uint32(i32) << 1) ^ uint32((i32 >> 31)))
    23  		x := g(uint64(i32))
    24  		if x != uint64(uint32(i32)) {
    25  			panic(x)
    26  		}
    27  	}
    28  }
    29  

View as plain text