modernc.org/gc@v1.0.1-0.20240304020402-f0dba7c97c2b/testdata/errchk/test/fixedbugs/bug440_64.go (about)

     1  // run
     2  
     3  // Test for 6g register move bug.  The optimizer gets confused
     4  // about 32- vs 64-bit moves during splitContractIndex.
     5  
     6  // Issue 3918.
     7  
     8  package main
     9  
    10  func main() {
    11  	const c = 0x123400005678
    12  	index, offset := splitContractIndex(c)
    13  	if index != (c&0xffffffff)>>5 || offset != c+1 {
    14  		println("BUG", index, offset)
    15  	}
    16  }
    17  
    18  func splitContractIndex(ce uint64) (index uint32, offset uint64) {
    19  	h := uint32(ce)
    20  	return h >> 5, ce + 1
    21  }