Skip to content

Commit e0deacd

Browse files
committed
Revert "cmd/compile: disable mem+op operations on 386"
This reverts commit CL 224837. Reason for revert: Reverting partial reverts of 222782. Update #37881 Change-Id: Ie9bf84d6e17ed214abe538965e5ff03936886826 Reviewed-on: https://go-review.googlesource.com/c/go/+/225217 Reviewed-by: Bryan C. Mills <[email protected]>
1 parent f975485 commit e0deacd

File tree

3 files changed

+61
-19
lines changed

3 files changed

+61
-19
lines changed

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

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -204,23 +204,22 @@ var combine = map[[2]Op]Op{
204204
[2]Op{Op386MOVWstoreconst, Op386LEAL2}: Op386MOVWstoreconstidx2,
205205
[2]Op{Op386MOVLstoreconst, Op386LEAL1}: Op386MOVLstoreconstidx1,
206206
[2]Op{Op386MOVLstoreconst, Op386LEAL4}: Op386MOVLstoreconstidx4,
207-
/*
208-
[2]Op{Op386ADDLload, Op386LEAL4}: Op386ADDLloadidx4,
209-
[2]Op{Op386SUBLload, Op386LEAL4}: Op386SUBLloadidx4,
210-
[2]Op{Op386MULLload, Op386LEAL4}: Op386MULLloadidx4,
211-
[2]Op{Op386ANDLload, Op386LEAL4}: Op386ANDLloadidx4,
212-
[2]Op{Op386ORLload, Op386LEAL4}: Op386ORLloadidx4,
213-
[2]Op{Op386XORLload, Op386LEAL4}: Op386XORLloadidx4,
214-
215-
[2]Op{Op386ADDLmodify, Op386LEAL4}: Op386ADDLmodifyidx4,
216-
[2]Op{Op386SUBLmodify, Op386LEAL4}: Op386SUBLmodifyidx4,
217-
[2]Op{Op386ANDLmodify, Op386LEAL4}: Op386ANDLmodifyidx4,
218-
[2]Op{Op386ORLmodify, Op386LEAL4}: Op386ORLmodifyidx4,
219-
[2]Op{Op386XORLmodify, Op386LEAL4}: Op386XORLmodifyidx4,
220-
221-
[2]Op{Op386ADDLconstmodify, Op386LEAL4}: Op386ADDLconstmodifyidx4,
222-
[2]Op{Op386ANDLconstmodify, Op386LEAL4}: Op386ANDLconstmodifyidx4,
223-
[2]Op{Op386ORLconstmodify, Op386LEAL4}: Op386ORLconstmodifyidx4,
224-
[2]Op{Op386XORLconstmodify, Op386LEAL4}: Op386XORLconstmodifyidx4,
225-
*/
207+
208+
[2]Op{Op386ADDLload, Op386LEAL4}: Op386ADDLloadidx4,
209+
[2]Op{Op386SUBLload, Op386LEAL4}: Op386SUBLloadidx4,
210+
[2]Op{Op386MULLload, Op386LEAL4}: Op386MULLloadidx4,
211+
[2]Op{Op386ANDLload, Op386LEAL4}: Op386ANDLloadidx4,
212+
[2]Op{Op386ORLload, Op386LEAL4}: Op386ORLloadidx4,
213+
[2]Op{Op386XORLload, Op386LEAL4}: Op386XORLloadidx4,
214+
215+
[2]Op{Op386ADDLmodify, Op386LEAL4}: Op386ADDLmodifyidx4,
216+
[2]Op{Op386SUBLmodify, Op386LEAL4}: Op386SUBLmodifyidx4,
217+
[2]Op{Op386ANDLmodify, Op386LEAL4}: Op386ANDLmodifyidx4,
218+
[2]Op{Op386ORLmodify, Op386LEAL4}: Op386ORLmodifyidx4,
219+
[2]Op{Op386XORLmodify, Op386LEAL4}: Op386XORLmodifyidx4,
220+
221+
[2]Op{Op386ADDLconstmodify, Op386LEAL4}: Op386ADDLconstmodifyidx4,
222+
[2]Op{Op386ANDLconstmodify, Op386LEAL4}: Op386ANDLconstmodifyidx4,
223+
[2]Op{Op386ORLconstmodify, Op386LEAL4}: Op386ORLconstmodifyidx4,
224+
[2]Op{Op386XORLconstmodify, Op386LEAL4}: Op386XORLconstmodifyidx4,
226225
}

test/codegen/arithmetic.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,13 @@ func SubMem(arr []int, b, c, d int) int {
2727
arr[4]--
2828
// 386:`ADDL\s[$]-20,\s20\([A-Z]+\)`
2929
arr[5] -= 20
30+
// 386:`SUBL\s\([A-Z]+\)\([A-Z]+\*4\),\s[A-Z]+`
3031
ef -= arr[b]
32+
// 386:`SUBL\s[A-Z]+,\s\([A-Z]+\)\([A-Z]+\*4\)`
3133
arr[c] -= b
34+
// 386:`ADDL\s[$]-15,\s\([A-Z]+\)\([A-Z]+\*4\)`
3235
arr[d] -= 15
36+
// 386:`DECL\s\([A-Z]+\)\([A-Z]+\*4\)`
3337
arr[b]--
3438
// amd64:`DECQ\s64\([A-Z]+\)`
3539
arr[8]--

test/codegen/memops.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,3 +204,42 @@ func idxFloat64(x, y []float64, i int) {
204204
// 386/sse2: `MOVSD\tX[0-9]+, 8\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[18]\)`
205205
y[16*i+1] = t
206206
}
207+
208+
func idxLoadPlusOp(x []int32, i int) int32 {
209+
s := x[0]
210+
// 386: `ADDL\t4\([A-Z]+\)\([A-Z]+\*4\), [A-Z]+`
211+
s += x[i+1]
212+
// 386: `SUBL\t8\([A-Z]+\)\([A-Z]+\*4\), [A-Z]+`
213+
s -= x[i+2]
214+
// 386: `IMULL\t12\([A-Z]+\)\([A-Z]+\*4\), [A-Z]+`
215+
s *= x[i+3]
216+
// 386: `ANDL\t16\([A-Z]+\)\([A-Z]+\*4\), [A-Z]+`
217+
s &= x[i+4]
218+
// 386: `ORL\t20\([A-Z]+\)\([A-Z]+\*4\), [A-Z]+`
219+
s |= x[i+5]
220+
// 386: `XORL\t24\([A-Z]+\)\([A-Z]+\*4\), [A-Z]+`
221+
s ^= x[i+6]
222+
return s
223+
}
224+
225+
func idxStorePlusOp(x []int32, i int, v int32) {
226+
// 386: `ADDL\t[A-Z]+, 4\([A-Z]+\)\([A-Z]+\*4\)`
227+
x[i+1] += v
228+
// 386: `SUBL\t[A-Z]+, 8\([A-Z]+\)\([A-Z]+\*4\)`
229+
x[i+2] -= v
230+
// 386: `ANDL\t[A-Z]+, 12\([A-Z]+\)\([A-Z]+\*4\)`
231+
x[i+3] &= v
232+
// 386: `ORL\t[A-Z]+, 16\([A-Z]+\)\([A-Z]+\*4\)`
233+
x[i+4] |= v
234+
// 386: `XORL\t[A-Z]+, 20\([A-Z]+\)\([A-Z]+\*4\)`
235+
x[i+5] ^= v
236+
237+
// 386: `ADDL\t[$]77, 24\([A-Z]+\)\([A-Z]+\*4\)`
238+
x[i+6] += 77
239+
// 386: `ANDL\t[$]77, 28\([A-Z]+\)\([A-Z]+\*4\)`
240+
x[i+7] &= 77
241+
// 386: `ORL\t[$]77, 32\([A-Z]+\)\([A-Z]+\*4\)`
242+
x[i+8] |= 77
243+
// 386: `XORL\t[$]77, 36\([A-Z]+\)\([A-Z]+\*4\)`
244+
x[i+9] ^= 77
245+
}

0 commit comments

Comments
 (0)