Skip to content

Commit 74ebdd2

Browse files
committed
[dev.simd] simd, cmd/compile: add more element types for Select128FromPair
Also includes a comment cleanup pass. Fixed NAME processing for additional documentation. Change-Id: Ide5b60c17ddbf3c6eafd20147981c59493fc8133 Reviewed-on: https://go-review.googlesource.com/c/go/+/722180 Reviewed-by: Junyang Shao <shaojunyang@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
1 parent 4d26d66 commit 74ebdd2

File tree

11 files changed

+248
-28
lines changed

11 files changed

+248
-28
lines changed

src/cmd/compile/internal/ssa/_gen/simdAMD64.rules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,8 +941,12 @@
941941
(ScaleFloat64x8 ...) => (VSCALEFPD512 ...)
942942
(Select128FromPairFloat32x8 ...) => (VPERM2F128256 ...)
943943
(Select128FromPairFloat64x4 ...) => (VPERM2F128256 ...)
944+
(Select128FromPairInt8x32 ...) => (VPERM2I128256 ...)
945+
(Select128FromPairInt16x16 ...) => (VPERM2I128256 ...)
944946
(Select128FromPairInt32x8 ...) => (VPERM2I128256 ...)
945947
(Select128FromPairInt64x4 ...) => (VPERM2I128256 ...)
948+
(Select128FromPairUint8x32 ...) => (VPERM2I128256 ...)
949+
(Select128FromPairUint16x16 ...) => (VPERM2I128256 ...)
946950
(Select128FromPairUint32x8 ...) => (VPERM2I128256 ...)
947951
(Select128FromPairUint64x4 ...) => (VPERM2I128256 ...)
948952
(SetElemFloat32x4 ...) => (VPINSRD128 ...)

src/cmd/compile/internal/ssa/_gen/simdgenericOps.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/compile/internal/ssa/opGen.go

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/compile/internal/ssa/rewriteAMD64.go

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/simd/_gen/simdgen/gen_simdTypes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ func ({{.Op1NameAndType "x"}}) {{.Go}}({{.Op2NameAndType "y"}}, {{.ImmName}} uin
351351
{{if .Documentation}}{{.Documentation}}
352352
//{{end}}
353353
// {{.ImmName}} result in better performance when they are constants, non-constant values will be translated into a jump table.
354-
// {{.ImmName}} should be between 0 and 3, inclusive; other values will result in a runtime panic.
354+
// {{.ImmName}} should be between 0 and 3, inclusive; other values may result in a runtime panic.
355355
//
356356
// Asm: {{.Asm}}, CPU Feature: {{.CPUFeature}}
357357
func ({{.Op1NameAndType "x"}}) {{.Go}}({{.ImmName}} uint8, {{.Op2NameAndType "y"}}) {{.GoType}}

src/simd/_gen/simdgen/godefs.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ func (o *Operation) SkipMaskedMethod() bool {
9898
return false
9999
}
100100

101+
var reForName = regexp.MustCompile(`\bNAME\b`)
102+
101103
func (o *Operation) DecodeUnified(v *unify.Value) error {
102104
if err := v.Decode(&o.rawOperation); err != nil {
103105
return err
@@ -117,7 +119,7 @@ func (o *Operation) DecodeUnified(v *unify.Value) error {
117119
} else {
118120
o.Documentation = "// UNDOCUMENTED"
119121
}
120-
o.Documentation = regexp.MustCompile(`\bNAME\b`).ReplaceAllString(o.Documentation, o.Go)
122+
o.Documentation = reForName.ReplaceAllString(o.Documentation, o.Go)
121123
if isMasked {
122124
o.Documentation += "\n//\n// This operation is applied selectively under a write mask."
123125
// Suppress generic op and method declaration for exported methods, if a mask is present.
@@ -128,7 +130,7 @@ func (o *Operation) DecodeUnified(v *unify.Value) error {
128130
}
129131
}
130132
if o.rawOperation.AddDoc != nil {
131-
o.Documentation += "\n" + *o.rawOperation.AddDoc
133+
o.Documentation += "\n" + reForName.ReplaceAllString(*o.rawOperation.AddDoc, o.Go)
132134
}
133135

134136
o.In = append(o.rawOperation.In, o.rawOperation.InVariant...)

src/simd/_gen/simdgen/ops/Moves/categories.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
// NAME concatenates selected elements from x and y into the lower and upper
136136
// halves of the output. The selection is chosen by the constant parameter h1h0l1l0
137137
// where each {h,l}{1,0} is two bits specify which element from y or x to select.
138-
// For example, {0,1,2,3}.concatSelectedConstant(0b_11_01_00_10, {4,5,6,7}) returns
138+
// For example, {0,1,2,3}.NAME(0b_11_01_00_10, {4,5,6,7}) returns
139139
// {2, 0, 5, 7} (don't forget that the binary constant is written big-endian).
140140
141141
- go: concatSelectedConstant
@@ -196,9 +196,12 @@
196196
// The selection is chosen by the constant parameter h1h0l1l0
197197
// where each {h,l}{1,0} is two bits specifying which element from y or x to select.
198198
// For example,
199-
// {0,1,2,3,8,9,10,11, 20,21,22,23,28,29,210,211}.NAME(
200-
// 0b_11_01_00_10, {4,5,6,7,12,13,14,15, 24,25,26,27,212,213,214,215})
199+
//
200+
// {0,1,2,3,8,9,10,11, 20,21,22,23,28,29,210,211}.NAME(
201+
// 0b_11_01_00_10, {4,5,6,7,12,13,14,15, 24,25,26,27,212,213,214,215})
202+
//
201203
// returns {2,0,5,7,10,8,13,15, 22,20,25,27,210,28,213,215}
204+
//
202205
// (don't forget that the binary constant is written big-endian).
203206
204207
- go: concatSelectedConstantGrouped
@@ -214,7 +217,7 @@
214217
// subvectors of x and y.
215218
//
216219
// For example {4,5,8,9,12,13,16,17}.NAME(0b11_00_11_10, {6,7,10,11,14,15,18,19})
217-
// returns {4,7,9,11,12,14,17,19}; bit 0 is zero, selecting element 0 from x's
220+
// returns {4,7,9,11,12,14,17,19}; bit 0 is zero, selecting element 0 from x's
218221
// least 128-bits (4), then 1, selects the element 1 from y's least 128-bits (7),
219222
// then 1, selecting element 1 from x's next 128 bits (9), then 1,
220223
// selecting element 1 from y's upper 128 bits (11). The next two 0 bits select
@@ -227,9 +230,8 @@
227230
commutative: false
228231
documentation: !string |-
229232
// NAME treats the 256-bit vectors x and y as a single vector of four
230-
// 128-bit elements, and returns a 256-bit result formed by
233+
// 128-bit elements, and returns a 256-bit result formed by
231234
// concatenating the two elements specified by lo and hi.
232-
// For example, {4,5}.NAME(3,0,{6,7}) returns {7,4}.
233235
234236
- go: ConcatShiftBytesRight
235237
commutative: false

src/simd/_gen/simdgen/ops/Moves/go.yaml

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,12 @@
837837
- go: Select128FromPair
838838
asm: VPERM2F128
839839
operandOrder: II
840+
addDoc: !string |-
841+
// For example,
842+
//
843+
// {40, 41, 50, 51}.NAME(3, 0, {60, 61, 70, 71})
844+
//
845+
// returns {70, 71, 40, 41}.
840846
in:
841847
- &v
842848
go: $t
@@ -854,6 +860,12 @@
854860
- go: Select128FromPair
855861
asm: VPERM2F128
856862
operandOrder: II
863+
addDoc: !string |-
864+
// For example,
865+
//
866+
// {40, 41, 42, 43, 50, 51, 52, 53}.NAME(3, 0, {60, 61, 62, 63, 70, 71, 72, 73})
867+
//
868+
// returns {70, 71, 72, 73, 40, 41, 42, 43}.
857869
in:
858870
- &v
859871
go: $t
@@ -872,6 +884,12 @@
872884
- go: Select128FromPair
873885
asm: VPERM2I128
874886
operandOrder: II
887+
addDoc: !string |-
888+
// For example,
889+
//
890+
// {40, 41, 50, 51}.NAME(3, 0, {60, 61, 70, 71})
891+
//
892+
// returns {70, 71, 40, 41}.
875893
in:
876894
- &v
877895
go: $t
@@ -890,6 +908,12 @@
890908
- go: Select128FromPair
891909
asm: VPERM2I128
892910
operandOrder: II
911+
addDoc: !string |-
912+
// For example,
913+
//
914+
// {40, 41, 42, 43, 50, 51, 52, 53}.NAME(3, 0, {60, 61, 62, 63, 70, 71, 72, 73})
915+
//
916+
// returns {70, 71, 72, 73, 40, 41, 42, 43}.
893917
in:
894918
- &v
895919
go: $t
@@ -905,6 +929,56 @@
905929
out:
906930
- *v
907931

932+
- go: Select128FromPair
933+
asm: VPERM2I128
934+
operandOrder: II
935+
addDoc: !string |-
936+
// For example,
937+
//
938+
// {40, 41, 42, 43, 44, 45, 46, 47, 50, 51, 52, 53, 54, 55, 56, 57}.NAME(3, 0,
939+
// {60, 61, 62, 63, 64, 65, 66, 67, 70, 71, 72, 73, 74, 75, 76, 77})
940+
//
941+
// returns {70, 71, 72, 73, 74, 75, 76, 77, 40, 41, 42, 43, 44, 45, 46, 47}.
942+
in:
943+
- &v
944+
go: $t
945+
class: vreg
946+
base: int|uint
947+
bits: 256
948+
OverwriteElementBits: 16
949+
- *v
950+
- class: immediate
951+
immOffset: 0
952+
name: "lo, hi"
953+
inVariant: []
954+
out:
955+
- *v
956+
957+
- go: Select128FromPair
958+
asm: VPERM2I128
959+
operandOrder: II
960+
addDoc: !string |-
961+
// For example,
962+
//
963+
// {0x40, 0x41, ..., 0x4f, 0x50, 0x51, ..., 0x5f}.NAME(3, 0,
964+
// {0x60, 0x61, ..., 0x6f, 0x70, 0x71, ..., 0x7f})
965+
//
966+
// returns {0x70, 0x71, ..., 0x7f, 0x40, 0x41, ..., 0x4f}.
967+
in:
968+
- &v
969+
go: $t
970+
class: vreg
971+
base: int|uint
972+
bits: 256
973+
OverwriteElementBits: 8
974+
- *v
975+
- class: immediate
976+
immOffset: 0
977+
name: "lo, hi"
978+
inVariant: []
979+
out:
980+
- *v
981+
908982
- go: ConcatShiftBytesRight
909983
asm: VPALIGNR
910984
in:
@@ -930,4 +1004,3 @@
9301004
immOffset: 0
9311005
out:
9321006
- *uint256512
933-

0 commit comments

Comments
 (0)