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
What operating system and processor architecture are you using (go env)?
linux + amd64
What did you do?
Compile
package main
var si []int = make([]int, 10)
var X interface{}
func use(y interface{}) {
X = y
}
func main() {
const ci64big int64 = 1 << 31
use(si[ci64big])
}
What did you expect to see?
To compile.
What did you see instead?
./foo.go:15: invalid instruction: 00054 (/tmp/foo.go:13) ADDQ $17179869184, CX
I believe the bug is here:
{name: "ADDQconst", argLength: 1, reg: gp11, asm: "ADDQ", aux: "Int64", resultInArg0: true, typ: "UInt64"}, // arg0 + auxint
or in the actual encoding of the instruction. We should probably fallback to LEAQ if the output goes to a different register.
You can add to registers other than AX, I think you're misreading that manual (it is just that the add to AX and the add to other registers is encoded differently). The problem is that you can't add a 64-bit immediate. Immediates are required to fit in sign-extended 32 bits. We need to fix this generally in our OP -> OPconst rewrite rules. I'll hack up a fix.
Please answer these questions before submitting your issue. Thanks!
go version
)?tip + patch https://go-review.googlesource.com/#/c/20833/3
go env
)?linux + amd64
Compile
To compile.
./foo.go:15: invalid instruction: 00054 (/tmp/foo.go:13) ADDQ $17179869184, CX
The manual http://support.amd.com/TechDocs/24594.pdf page 79 says that ADDQ imm only works with AX, but here CX is generated.
I believe the bug is here:
{name: "ADDQconst", argLength: 1, reg: gp11, asm: "ADDQ", aux: "Int64", resultInArg0: true, typ: "UInt64"}, // arg0 + auxint
or in the actual encoding of the instruction. We should probably fallback to LEAQ if the output goes to a different register.
@randall77
The text was updated successfully, but these errors were encountered: