aboutsummaryrefslogtreecommitdiff
path: root/test/codegen/arithmetic.go
diff options
context:
space:
mode:
authorAlberto Donizetti <alb.donizetti@gmail.com>2018-03-08 10:57:10 +0100
committerAlberto Donizetti <alb.donizetti@gmail.com>2018-03-08 16:30:14 +0000
commit3772b2e1d5e5ebf45d69eb4720cf81804169be01 (patch)
tree5ef135fb51829c15f90571540e32771b6ee8cdd5 /test/codegen/arithmetic.go
parent0585d41c87674da36c9a926aad115815db1dd295 (diff)
downloadgo-3772b2e1d5e5ebf45d69eb4720cf81804169be01.tar.xz
test/codegen: port 2^n muls tests to codegen harness
And delete them from the asm_test.go file. Change-Id: I124c8c352299646ec7db0968cdb0fe59a3b5d83d Reviewed-on: https://go-review.googlesource.com/99475 Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Giovanni Bajo <rasky@develer.com>
Diffstat (limited to 'test/codegen/arithmetic.go')
-rw-r--r--test/codegen/arithmetic.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/codegen/arithmetic.go b/test/codegen/arithmetic.go
new file mode 100644
index 0000000000..c09fad60c8
--- /dev/null
+++ b/test/codegen/arithmetic.go
@@ -0,0 +1,26 @@
+// asmcheck
+
+// Copyright 2018 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.
+
+package codegen
+
+// This file contains codegen tests related to arithmetic
+// simplifications/optimizations.
+
+func Pow2Muls(n1, n2 int) (int, int) {
+ // amd64:"SHLQ\t[$]5",-"IMULQ"
+ // 386:"SHLL\t[$]5",-"IMULL"
+ // arm:"SLL\t[$]5",-"MUL"
+ // arm64:"LSL\t[$]5",-"MUL"
+ a := n1 * 32
+
+ // amd64:"SHLQ\t[$]6",-"IMULQ"
+ // 386:"SHLL\t[$]6",-"IMULL"
+ // arm:"SLL\t[$]6",-"MUL"
+ // arm64:"LSL\t[$]6",-"MUL"
+ b := -64 * n2
+
+ return a, b
+}