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.
9 // This file contains codegen tests related to arithmetic
10 // simplifications and optimizations on float types.
11 // For codegen tests on integer types, see arithmetic.go.
13 // --------------------- //
15 // --------------------- //
17 func Mul2(f float64) float64 {
18 // 386/sse2:"ADDSD",-"MULSD"
19 // amd64:"ADDSD",-"MULSD"
20 // arm/7:"ADDD",-"MULD"
21 // arm64:"FADDD",-"FMULD"
22 // ppc64x:"FADD",-"FMUL"
23 // riscv64:"FADDD",-"FMULD"
27 func DivPow2(f1, f2, f3 float64) (float64, float64, float64) {
28 // 386/sse2:"MULSD",-"DIVSD"
29 // amd64:"MULSD",-"DIVSD"
30 // arm/7:"MULD",-"DIVD"
31 // arm64:"FMULD",-"FDIVD"
32 // ppc64x:"FMUL",-"FDIV"
33 // riscv64:"FMULD",-"FDIVD"
36 // 386/sse2:"MULSD",-"DIVSD"
37 // amd64:"MULSD",-"DIVSD"
38 // arm/7:"MULD",-"DIVD"
39 // arm64:"FMULD",-"FDIVD"
40 // ppc64x:"FMUL",-"FDIVD"
41 // riscv64:"FMULD",-"FDIVD"
44 // 386/sse2:"ADDSD",-"DIVSD",-"MULSD"
45 // amd64:"ADDSD",-"DIVSD",-"MULSD"
46 // arm/7:"ADDD",-"MULD",-"DIVD"
47 // arm64:"FADDD",-"FMULD",-"FDIVD"
48 // ppc64x:"FADD",-"FMUL",-"FDIV"
49 // riscv64:"FADDD",-"FMULD",-"FDIVD"
55 func indexLoad(b0 []float32, b1 float32, idx int) float32 {
56 // arm64:`FMOVS\s\(R[0-9]+\)\(R[0-9]+<<2\),\sF[0-9]+`
60 func indexStore(b0 []float64, b1 float64, idx int) {
61 // arm64:`FMOVD\sF[0-9]+,\s\(R[0-9]+\)\(R[0-9]+<<3\)`
69 func FusedAdd32(x, y, z float32) float32 {
76 func FusedSub32_a(x, y, z float32) float32 {
82 func FusedSub32_b(x, y, z float32) float32 {
87 func FusedAdd64(x, y, z float64) float64 {
95 func FusedSub64_a(x, y, z float64) float64 {
102 func FusedSub64_b(x, y, z float64) float64 {
104 // riscv64:"FNMSUBD\t"
108 func Cmp(f float64) bool {
109 // arm64:"FCMPD","(BGT|BLE|BMI|BPL)",-"CSET\tGT",-"CBZ"
110 return f > 4 || f < -4
113 func CmpZero64(f float64) bool {
114 // s390x:"LTDBR",-"FCMPU"
118 func CmpZero32(f float32) bool {
119 // s390x:"LTEBR",-"CEBR"
123 func CmpWithSub(a float64, b float64) bool {
129 func CmpWithAdd(a float64, b float64) bool {
135 // ---------------- //
137 // ---------------- //
139 // We should make sure that the compiler doesn't generate floating point
140 // instructions for non-float operations on Plan 9, because floating point
141 // operations are not allowed in the note handler.
143 func ArrayZero() [16]byte {
145 // plan9/amd64/:-"MOVUPS"
150 func ArrayCopy(a [16]byte) (b [16]byte) {
152 // plan9/amd64/:-"MOVUPS"