You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to optimize exp_amd64.s using VADDSD to combine a MOVSD and ADDSD instructions. But for that to work, the 3rd operand needs to be a memory location. When I was loading the memory to a register and then doing VADDSD it was working fine. But when I tried to access the memory location directly, it gave garbage.
Sample code -
Below is a code which tries to do VADDSD and VSUBSD. In first variation, they try to operate on registers, next, they work on memory operands.
// +build amd64
#include "textflag.h"
DATA mydata<>+0(SB)/8, $-8.75
GLOBL mydata<>+0(SB), RODATA, $8
// func vADDSDReg(x) float64
TEXT ·vADDSDReg(SB),NOSPLIT,$0
MOVSD x+0(FP), X0
MOVSD mydata<>+0(SB), X1
// VADDSD X1, X0, X1 (dest op on left)
BYTE $0xC5; BYTE $0xFB; BYTE $0x58; BYTE $0xC9
MOVSD X1, ret+8(FP)
RET
// func vADDSDMem(x) float64
TEXT ·vADDSDMem(SB),NOSPLIT,$0
MOVSD x+0(FP), X0
// VADDSD xmm1, xmm0, [rip+0x3feaa] (dest op on left)
BYTE $0xC5; BYTE $0xFB; BYTE $0x58; BYTE $0x0D; BYTE $0xAA; BYTE $0xFE; BYTE $0x03; BYTE $0x00
MOVSD X1, ret+8(FP)
RET
// func vSUBSDReg(x) float64
TEXT ·vSUBSDReg(SB),NOSPLIT,$0
MOVSD x+0(FP), X0
MOVSD mydata<>+0(SB), X1
// VSUBSD X1, X0, X1 (dest op on left)
BYTE $0xC5; BYTE $0xFB; BYTE $0x5C; BYTE $0xC9
MOVSD X1, ret+8(FP)
RET
// func vSUBSDMem(x) float64
TEXT ·vSUBSDMem(SB),NOSPLIT,$0
MOVSD x+0(FP), X0
// VSUBSD xmm1, xmm0, [rip+0x3fe6a] (dest op on left)
BYTE $0xC5; BYTE $0xFB; BYTE $0x5C; BYTE $0x0D; BYTE $0x6A; BYTE $0xFE; BYTE $0x03; BYTE $0x00
MOVSD X1, ret+8(FP)
RET
The rip hex offsets were extracted by doing a usual MOVSD mydata<>+0(SB), X1. And doing an objdump -d on the binary to get the actual instruction.
I haven't thoroughly checked every other command. But I am fairly confident that will happen on all unsupported instructions which try to use a memory operand.
Attached code for easy download and repro - bug.zip
The text was updated successfully, but these errors were encountered:
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?master (1/2 days old). go version devel +60e743b Mon Sep 4 15:25:00 2017 +0530 linux/amd64
Does this issue reproduce with the latest release?
No. With Go 1.9, it works fine.
What operating system and processor architecture are you using (
go env
)?What did you do?
I was trying to optimize exp_amd64.s using
VADDSD
to combine aMOVSD
andADDSD
instructions. But for that to work, the 3rd operand needs to be a memory location. When I was loading the memory to a register and then doingVADDSD
it was working fine. But when I tried to access the memory location directly, it gave garbage.Sample code -
Below is a code which tries to do
VADDSD
andVSUBSD
. In first variation, they try to operate on registers, next, they work on memory operands.The
rip
hex offsets were extracted by doing a usualMOVSD mydata<>+0(SB), X1
. And doing anobjdump -d
on the binary to get the actual instruction.And the corresponding Go code which runs them-
What did you expect to see?
With Go 1.9
With Go master
What did you see instead?
With Go 1.9
With Go master
I haven't thoroughly checked every other command. But I am fairly confident that will happen on all unsupported instructions which try to use a memory operand.
Attached code for easy download and repro - bug.zip
The text was updated successfully, but these errors were encountered: