fix(asm): carry the arm64 immediate to ZR through MOVZ
Assisted-by: GLM 5.3 Flash
This commit is contained in:
1 parent
d786b90fa1
commit
a9b54b6868
2 files changed
+34
-2
No files matched your search
@@ -1820,7 +1820,10 @@ func encodeARM64LoadImm(rd int, v int64, mnem string) ([]byte, error) {
|
||||
// `MOVD $4096, R27` is ORR $4096, not MOVZ $(1<<12)
|
||||
// - outside that band: MOVZ/MOVN first (C_MOVCON before C_BITCON), and
|
||||
// negative values reach MOVN before the bitmask test
|
||||
tryBitmaskFirst := d > 0 && (d <= 0xFFF || (d&0xFFF == 0 && d <= 0xFFF000))
|
||||
// The bitmask path exists only for a real register: omovconst guards it
|
||||
// with rt != REGZERO, so an immediate to ZR always rides the MOVZ/MOVN
|
||||
// sequence carrying the value.
|
||||
tryBitmaskFirst := rd != 31 && d > 0 && (d <= 0xFFF || (d&0xFFF == 0 && d <= 0xFFF000))
|
||||
|
||||
if tryBitmaskFirst {
|
||||
// Addcon-band immediate: try bitmask first (Go uses ORR for values
|
||||
@@ -1849,7 +1852,7 @@ func encodeARM64LoadImm(rd int, v int64, mnem string) ([]byte, error) {
|
||||
}
|
||||
|
||||
// For values outside the bitmask-first range that are not movcon: try bitmask.
|
||||
if !tryBitmaskFirst {
|
||||
if !tryBitmaskFirst && rd != 31 {
|
||||
N, immr, imms, ok := arm64Bitmask(uint64(d), int(sf))
|
||||
if ok {
|
||||
return a64wordLE(sf<<31 | 1<<29 | 0x24<<23 | N<<22 | immr<<16 | imms<<10 | 31<<5 | uint32(rd)), nil
|
||||
|
||||
Reference in new issue
Block a user