Skip to content

Commit 06c1222

Browse files
Arm64: Fix loads and stores for stack allocated vectors and masks (#128037)
Code introduced in #125491 asserts that addressing is always frame pointer based, but it is possible for it to be stack pointer based. Remove the assertion and select the correct register for codegen. Fixes #127955
1 parent e694e81 commit 06c1222

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

src/coreclr/jit/emitarm64.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8243,7 +8243,7 @@ void emitter::emitIns_R_S(instruction ins, emitAttr attr, regNumber reg1, int va
82438243
int base = m_compiler->lvaFrameAddress(varx, &FPbased);
82448244
int disp = base + offs;
82458245
imm = disp;
8246-
reg2 = encodingSPtoZR(FPbased ? REG_FPBASE : REG_SPBASE);
8246+
reg2 = FPbased ? REG_FPBASE : REG_SPBASE;
82478247

82488248
// TODO-ARM64-CQ: use unscaled loads?
82498249
/* Figure out the encoding format of the instruction */
@@ -8312,7 +8312,6 @@ void emitter::emitIns_R_S(instruction ins, emitAttr attr, regNumber reg1, int va
83128312
case INS_sve_ldr:
83138313
{
83148314
assert(isPredicateRegister(reg1) || isVectorRegister(reg1));
8315-
assert(FPbased);
83168315

83178316
isSimple = false;
83188317
size = EA_SCALABLE;
@@ -8321,7 +8320,7 @@ void emitter::emitIns_R_S(instruction ins, emitAttr attr, regNumber reg1, int va
83218320

83228321
useRegForImm = true;
83238322
regNumber rsvdReg = codeGen->rsGetRsvdReg();
8324-
codeGen->instGen_Set_Reg_To_Base_Plus_Imm(EA_PTRSIZE, rsvdReg, REG_FP, imm);
8323+
codeGen->instGen_Set_Reg_To_Base_Plus_Imm(EA_PTRSIZE, rsvdReg, reg2, imm);
83258324

83268325
reg2 = rsvdReg;
83278326
imm = 0;
@@ -8394,7 +8393,7 @@ void emitter::emitIns_R_S(instruction ins, emitAttr attr, regNumber reg1, int va
83948393
id->idInsOpt(opt);
83958394

83968395
id->idReg1(reg1);
8397-
id->idReg2(reg2);
8396+
id->idReg2(encodingSPtoZR(reg2));
83988397
id->idReg3(reg3);
83998398
id->idAddr()->iiaLclVar.initLclVarAddr(varx, offs);
84008399
id->idSetIsLclVar();
@@ -8555,7 +8554,7 @@ void emitter::emitIns_S_R(instruction ins, emitAttr attr, regNumber reg1, int va
85558554
imm = disp;
85568555

85578556
// TODO-ARM64-CQ: with compLocallocUsed, should we use REG_SAVED_LOCALLOC_SP instead?
8558-
reg2 = encodingSPtoZR(FPbased ? REG_FPBASE : REG_SPBASE);
8557+
reg2 = FPbased ? REG_FPBASE : REG_SPBASE;
85598558

85608559
// TODO-ARM64-CQ: use unscaled loads?
85618560
/* Figure out the encoding format of the instruction */
@@ -8590,15 +8589,14 @@ void emitter::emitIns_S_R(instruction ins, emitAttr attr, regNumber reg1, int va
85908589
case INS_sve_str:
85918590
{
85928591
assert(isVectorRegister(reg1) || isPredicateRegister(reg1));
8593-
assert(FPbased);
85948592
isSimple = false;
85958593
size = EA_SCALABLE;
85968594
attr = size;
85978595
fmt = isPredicateRegister(reg1) ? IF_SVE_JG_2A : IF_SVE_JH_2A;
85988596

85998597
useRegForImm = true;
86008598
regNumber rsvdReg = codeGen->rsGetRsvdReg();
8601-
codeGen->instGen_Set_Reg_To_Base_Plus_Imm(EA_PTRSIZE, rsvdReg, REG_FP, imm);
8599+
codeGen->instGen_Set_Reg_To_Base_Plus_Imm(EA_PTRSIZE, rsvdReg, reg2, imm);
86028600
reg2 = rsvdReg;
86038601
imm = 0;
86048602
}
@@ -8678,7 +8676,7 @@ void emitter::emitIns_S_R(instruction ins, emitAttr attr, regNumber reg1, int va
86788676
id->idInsOpt(INS_OPTS_NONE);
86798677

86808678
id->idReg1(reg1);
8681-
id->idReg2(reg2);
8679+
id->idReg2(encodingSPtoZR(reg2));
86828680
id->idAddr()->iiaLclVar.initLclVarAddr(varx, offs);
86838681
id->idSetIsLclVar();
86848682

0 commit comments

Comments
 (0)