Skip to content

Commit b63a51b

Browse files
Copilotkovidgoyal
andcommitted
Fix ARM64: replace VMVN with WORD-encoded NOT instruction
Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
1 parent f2f2917 commit b63a51b

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

tools/simdstring/generate.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,12 @@ func encode_cmgt16b(a, b, dest Register) (ans uint32) {
404404
return 0x271<<21 | b.ARMId()<<16 | 0xd<<10 | a.ARMId()<<5 | dest.ARMId()
405405
}
406406

407+
func encode_not16b(src, dest Register) uint32 {
408+
// NOT Vd.16B, Vn.16B (alias of MVN)
409+
// Encoding: 0 Q 1 01110 size 10000 00101 10 Rn Rd (Q=1, size=00 for .16B)
410+
return 0x6E205800 | (src.ARMId() << 5) | dest.ARMId()
411+
}
412+
407413
func (f *Function) MaskForCountDestructive(vec, ans Register) {
408414
// vec is clobbered by this function
409415
f.Comment("Count the number of bytes to the first 0xff byte and put the result in", ans)
@@ -690,7 +696,8 @@ func (f *Function) Or(a, b, dest Register) {
690696

691697
func (f *Function) NotSelf(r Register) {
692698
if f.ISA.Goarch == ARM64 {
693-
f.instr("VMVN", r.ARMFullWidth(), r.ARMFullWidth())
699+
f.Comment("Go assembler doesn't support the VMVN instruction, below we have: NOT", r.ARMFullWidth()+",", r.ARMFullWidth())
700+
f.instr("WORD", fmt.Sprintf("$0x%x", encode_not16b(r, r)))
694701
f.AddTrailingComment(r, "= ~", r, "(bitwise NOT)")
695702
return
696703
}

0 commit comments

Comments
 (0)