| 1 |
// Copyright 2025 The Go Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a BSD-style |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
package test |
| 6 |
|
| 7 |
import ( |
| 8 |
"cmd/compile/internal/ssa" |
| 9 |
"cmd/compile/internal/types" |
| 10 |
"internal/buildcfg" |
| 11 |
"testing" |
| 12 |
) |
| 13 |
|
| 14 |
// This file contains tests for ssa values, types and their utility functions. |
| 15 |
|
| 16 |
func TestCanSSA(t *testing.T) { |
| 17 |
i64 := types.Types[types.TINT64] |
| 18 |
v128 := types.TypeVec128 |
| 19 |
s1 := mkstruct(i64, mkstruct(i64, i64, i64, i64)) |
| 20 |
if ssa.CanSSA(s1) { |
| 21 |
// Test size check for struct. |
| 22 |
t.Errorf("CanSSA(%v) returned true, expected false", s1) |
| 23 |
} |
| 24 |
a1 := types.NewArray(s1, 1) |
| 25 |
if ssa.CanSSA(a1) { |
| 26 |
// Test size check for array. |
| 27 |
t.Errorf("CanSSA(%v) returned true, expected false", a1) |
| 28 |
} |
| 29 |
if buildcfg.Experiment.SIMD { |
| 30 |
s2 := mkstruct(v128, v128, v128, v128) |
| 31 |
if !ssa.CanSSA(s2) { |
| 32 |
// Test size check for SIMD struct special case. |
| 33 |
t.Errorf("CanSSA(%v) returned false, expected true", s2) |
| 34 |
} |
| 35 |
a2 := types.NewArray(s2, 1) |
| 36 |
if !ssa.CanSSA(a2) { |
| 37 |
// Test size check for SIMD array special case. |
| 38 |
t.Errorf("CanSSA(%v) returned false, expected true", a2) |
| 39 |
} |
| 40 |
} |
| 41 |
} |