Skip to content

Commit 144cf17

Browse files
committed
[dev.simd] simd, cmd/compile: move "simd" to "simd/archsimd"
Also removes a few leftover TODOs and scraps of commented-out code from simd development. Updated etetest.sh to make it behave whether amd64 implies the experiment, or not. Fixes #76473. Change-Id: I6d9792214d7f514cb90c21b101dbf7d07c1d0e55 Reviewed-on: https://go-review.googlesource.com/c/go/+/728220 TryBot-Bypass: David Chase <[email protected]> Reviewed-by: Cherry Mui <[email protected]>
1 parent 3417b48 commit 144cf17

File tree

115 files changed

+2066
-2065
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+2066
-2065
lines changed

src/cmd/compile/internal/inline/inl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ type hairyVisitor struct {
445445

446446
func isDebugFn(fn *ir.Func) bool {
447447
// if n := fn.Nname; n != nil {
448-
// if n.Sym().Name == "Int32x8.Transpose8" && n.Sym().Pkg.Path == "simd" {
448+
// if n.Sym().Name == "Int32x8.Transpose8" && n.Sym().Pkg.Path == "simd/archsimd" {
449449
// fmt.Printf("isDebugFn '%s' DOT '%s'\n", n.Sym().Pkg.Path, n.Sym().Name)
450450
// return true
451451
// }

src/cmd/compile/internal/ssagen/intrinsics.go

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,7 +1644,7 @@ func initIntrinsics(cfg *intrinsicBuildConfig) {
16441644
// Only enable intrinsics, if SIMD experiment.
16451645
simdIntrinsics(addF)
16461646

1647-
addF("simd", "ClearAVXUpperBits",
1647+
addF(simdPackage, "ClearAVXUpperBits",
16481648
func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
16491649
s.vars[memVar] = s.newValue1(ssa.OpAMD64VZEROUPPER, types.TypeMem, s.mem())
16501650
return nil
@@ -1668,15 +1668,18 @@ func initIntrinsics(cfg *intrinsicBuildConfig) {
16681668
addF(simdPackage, "Uint32x8.IsZero", opLen1(ssa.OpIsZeroVec, types.Types[types.TBOOL]), sys.AMD64)
16691669
addF(simdPackage, "Uint64x4.IsZero", opLen1(ssa.OpIsZeroVec, types.Types[types.TBOOL]), sys.AMD64)
16701670

1671+
// sfp4 is intrinsic-if-constant, but otherwise it's complicated enough to just implement in Go.
16711672
sfp4 := func(method string, hwop ssa.Op, vectype *types.Type) {
1672-
addF("simd", method,
1673+
addF(simdPackage, method,
16731674
func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
16741675
x, a, b, c, d, y := args[0], args[1], args[2], args[3], args[4], args[5]
16751676
if a.Op == ssa.OpConst8 && b.Op == ssa.OpConst8 && c.Op == ssa.OpConst8 && d.Op == ssa.OpConst8 {
1676-
return select4FromPair(x, a, b, c, d, y, s, hwop, vectype)
1677-
} else {
1678-
return s.callResult(n, callNormal)
1677+
z := select4FromPair(x, a, b, c, d, y, s, hwop, vectype)
1678+
if z != nil {
1679+
return z
1680+
}
16791681
}
1682+
return s.callResult(n, callNormal)
16801683
},
16811684
sys.AMD64)
16821685
}
@@ -1693,15 +1696,18 @@ func initIntrinsics(cfg *intrinsicBuildConfig) {
16931696
sfp4("Uint32x16.SelectFromPairGrouped", ssa.OpconcatSelectedConstantGroupedUint32x16, types.TypeVec512)
16941697
sfp4("Float32x16.SelectFromPairGrouped", ssa.OpconcatSelectedConstantGroupedFloat32x16, types.TypeVec512)
16951698

1699+
// sfp2 is intrinsic-if-constant, but otherwise it's complicated enough to just implement in Go.
16961700
sfp2 := func(method string, hwop ssa.Op, vectype *types.Type, cscimm func(i, j uint8) int64) {
1697-
addF("simd", method,
1701+
addF(simdPackage, method,
16981702
func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
16991703
x, a, b, y := args[0], args[1], args[2], args[3]
17001704
if a.Op == ssa.OpConst8 && b.Op == ssa.OpConst8 {
1701-
return select2FromPair(x, a, b, y, s, hwop, vectype, cscimm)
1702-
} else {
1703-
return s.callResult(n, callNormal)
1705+
z := select2FromPair(x, a, b, y, s, hwop, vectype, cscimm)
1706+
if z != nil {
1707+
return z
1708+
}
17041709
}
1710+
return s.callResult(n, callNormal)
17051711
},
17061712
sys.AMD64)
17071713
}
@@ -1767,6 +1773,9 @@ const (
17671773

17681774
func select2FromPair(x, _a, _b, y *ssa.Value, s *state, op ssa.Op, t *types.Type, csc func(a, b uint8) int64) *ssa.Value {
17691775
a, b := uint8(_a.AuxInt8()), uint8(_b.AuxInt8())
1776+
if a > 3 || b > 3 {
1777+
return nil
1778+
}
17701779
pattern := (a&2)>>1 + (b & 2)
17711780
a, b = a&1, b&1
17721781

@@ -1785,6 +1794,9 @@ func select2FromPair(x, _a, _b, y *ssa.Value, s *state, op ssa.Op, t *types.Type
17851794

17861795
func select4FromPair(x, _a, _b, _c, _d, y *ssa.Value, s *state, op ssa.Op, t *types.Type) *ssa.Value {
17871796
a, b, c, d := uint8(_a.AuxInt8()), uint8(_b.AuxInt8()), uint8(_c.AuxInt8()), uint8(_d.AuxInt8())
1797+
if a > 7 || b > 7 || c > 7 || d > 7 {
1798+
return nil
1799+
}
17881800
pattern := a>>2 + (b&4)>>1 + (c & 4) + (d&4)<<1
17891801

17901802
a, b, c, d = a&3, b&3, c&3, d&3
@@ -2154,7 +2166,7 @@ func findIntrinsic(sym *types.Sym) intrinsicBuilder {
21542166
fn := sym.Name
21552167
if ssa.IntrinsicsDisable {
21562168
if pkg == "internal/runtime/sys" && (fn == "GetCallerPC" || fn == "GrtCallerSP" || fn == "GetClosurePtr") ||
2157-
pkg == "internal/simd" || pkg == "simd" { // TODO after simd has been moved to package simd, remove internal/simd
2169+
pkg == simdPackage {
21582170
// These runtime functions don't have definitions, must be intrinsics.
21592171
} else {
21602172
return nil

src/cmd/compile/internal/ssagen/intrinsics_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,13 +1407,13 @@ func TestIntrinsics(t *testing.T) {
14071407
gotIntrinsics[testIntrinsicKey{ik.arch.Name, ik.pkg, ik.fn}] = struct{}{}
14081408
}
14091409
for ik, _ := range gotIntrinsics {
1410-
if _, found := wantIntrinsics[ik]; !found && (ik.pkg != "simd" || *simd) {
1410+
if _, found := wantIntrinsics[ik]; !found && (ik.pkg != "simd/archsimd" || *simd) {
14111411
t.Errorf("Got unwanted intrinsic %v %v.%v", ik.archName, ik.pkg, ik.fn)
14121412
}
14131413
}
14141414

14151415
for ik, _ := range wantIntrinsics {
1416-
if _, found := gotIntrinsics[ik]; !found && (ik.pkg != "simd" || *simd) {
1416+
if _, found := gotIntrinsics[ik]; !found && (ik.pkg != "simd/archsimd" || *simd) {
14171417
t.Errorf("Want missing intrinsic %v %v.%v", ik.archName, ik.pkg, ik.fn)
14181418
}
14191419
}

src/cmd/compile/internal/ssagen/simdintrinsics.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/compile/internal/types/size.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -471,11 +471,6 @@ func simdify(st *Type, isTag bool) {
471471
} else {
472472
st.floatRegs = 1
473473
}
474-
// if st.Sym() != nil {
475-
// base.Warn("Simdify %s, %v, %d", st.Sym().Name, isTag, st.width)
476-
// } else {
477-
// base.Warn("Simdify %v, %v, %d", st, isTag, st.width)
478-
// }
479474
}
480475

481476
// CalcStructSize calculates the size of t,
@@ -491,10 +486,9 @@ func CalcStructSize(t *Type) {
491486
case sym.Name == "align64" && isAtomicStdPkg(sym.Pkg):
492487
maxAlign = 8
493488

494-
case buildcfg.Experiment.SIMD && (sym.Pkg.Path == "internal/simd" || sym.Pkg.Path == "simd") && len(t.Fields()) >= 1:
489+
case buildcfg.Experiment.SIMD && (sym.Pkg.Path == "simd/archsimd") && len(t.Fields()) >= 1:
495490
// This gates the experiment -- without it, no user-visible types can be "simd".
496491
// The SSA-visible SIMD types remain.
497-
// TODO after simd has been moved to package simd, remove internal/simd.
498492
switch sym.Name {
499493
case "v128":
500494
simdify(t, true)

src/cmd/compile/internal/types2/stdlib_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,8 @@ var excluded = map[string]bool{
361361
"builtin": true,
362362
"cmd/compile/internal/ssa/_gen": true,
363363
"runtime/_mkmalloc": true,
364-
"simd/_gen/simdgen": true,
365-
"simd/_gen/unify": true,
364+
"simd/archsimd/_gen/simdgen": true,
365+
"simd/archsimd/_gen/unify": true,
366366
}
367367

368368
// printPackageMu synchronizes the printing of type-checked package files in

src/go/build/deps_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ var depsRules = `
7373
internal/byteorder, internal/cpu, internal/goarch < internal/chacha8rand;
7474
internal/goarch, math/bits < internal/strconv;
7575
76-
internal/cpu, internal/strconv < simd;
76+
internal/cpu, internal/strconv < simd/archsimd;
7777
7878
# RUNTIME is the core runtime group of packages, all of them very light-weight.
7979
internal/abi,
@@ -709,7 +709,7 @@ var depsRules = `
709709
< testing;
710710
711711
testing, math
712-
< simd/internal/test_helpers;
712+
< simd/archsimd/internal/test_helpers;
713713
714714
log/slog, testing
715715
< testing/slogtest;

src/go/types/stdlib_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,8 @@ var excluded = map[string]bool{
361361
"builtin": true,
362362
"cmd/compile/internal/ssa/_gen": true,
363363
"runtime/_mkmalloc": true,
364-
"simd/_gen/simdgen": true,
365-
"simd/_gen/unify": true,
364+
"simd/archsimd/_gen/simdgen": true,
365+
"simd/archsimd/_gen/unify": true,
366366
}
367367

368368
// printPackageMu synchronizes the printing of type-checked package files in

src/simd/_gen/simdgen/.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module simd/_gen
1+
module simd/archsimd/_gen
22

33
go 1.24
44

0 commit comments

Comments
 (0)