Source file test/fixedbugs/shrd_zero_count.go
1 // run 2 3 // Copyright 2026 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 // Folding a paired modulo-count shift into a double-register shift 8 // (SHRD/SHLD on amd64) must not drop the second operand when the 9 // shift count is zero modulo 64. 10 11 package main 12 13 //go:noinline 14 func shrd(lo, hi uint64, bits uint) uint64 { 15 return lo>>(bits&63) | hi<<((-bits)&63) 16 } 17 18 func main() { 19 got := shrd(0x1111000000000000, 0x2222, 0) 20 want := uint64(0x1111000000002222) 21 if got != want { 22 println("shrd zero count: got", got, "want", want) 23 panic("FAIL") 24 } 25 } 26