Source file test/codegen/logic.go
1 // asmcheck 2 3 // Copyright 2018 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 package codegen 8 9 var gx, gy int 10 11 // Test to make sure that (CMPQ (ANDQ x y) [0]) does not get rewritten to 12 // (TESTQ x y) if the ANDQ has other uses. If that rewrite happens, then one 13 // of the args of the ANDQ needs to be saved so it can be used as the arg to TESTQ. 14 func andWithUse(x, y int) int { 15 // Load x,y into registers, so those MOVQ will not appear at the z := x&y line. 16 gx, gy = x, y 17 // amd64:-"MOVQ" 18 z := x & y 19 if z == 0 { 20 return 77 21 } 22 // use z by returning it 23 return z 24 } 25 26 // Verify (OR x (NOT y)) rewrites to (ORN x y) where supported 27 func ornot(x, y int) int { 28 // ppc64:"ORN" 29 // ppc64le:"ORN" 30 z := x | ^y 31 return z 32 } 33