Skip to content

Commit 6963a59

Browse files
authored
Arm64: Don't use GT_LEA for masks (#128684)
genCreateAddrMode() will need rewrites for scalable vectors/masks. Until then, avoid using LEA nodes. In addition, remove invalid code for LDR/STR from the emitter. The emitter expects the offset to be a multiple of the VL/PL Fixes #127605
1 parent f2d5042 commit 6963a59

4 files changed

Lines changed: 12 additions & 46 deletions

File tree

src/coreclr/jit/emitarm64.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2523,13 +2523,6 @@ emitter::code_t emitter::emitInsCode(instruction ins, insFormat fmt)
25232523
return (imm >= -256) && (imm <= 255);
25242524
}
25252525

2526-
// true if this 'imm' can be encoded as the offset in an unscaled ldr/str instruction
2527-
/*static*/ bool emitter::emitIns_valid_imm_for_scaled_sve_ldst_offset(INT64 imm)
2528-
{
2529-
// TODO-SVE: This assumes 128bit SVE.
2530-
return ((imm % 16) == 0 && (imm / 16) <= 255 && (imm / 16) >= -256);
2531-
}
2532-
25332526
// true if this 'imm' can be encoded as the offset in a ldr/str instruction
25342527
/*static*/ bool emitter::emitIns_valid_imm_for_ldst_offset(INT64 imm, emitAttr attr)
25352528
{

src/coreclr/jit/emitarm64.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,9 +1058,6 @@ static bool emitIns_valid_imm_for_ldst_offset(INT64 imm, emitAttr size);
10581058
// true if this 'imm' can be encoded as the offset in an unscaled ldr/str instruction
10591059
static bool emitIns_valid_imm_for_unscaled_ldst_offset(INT64 imm);
10601060

1061-
// true if this 'imm' can be encoded as the offset in an scaled SVE ldr/str instruction
1062-
static bool emitIns_valid_imm_for_scaled_sve_ldst_offset(INT64 imm);
1063-
10641061
// true if this 'imm' can be encoded as a input operand to a ccmp instruction
10651062
static bool emitIns_valid_imm_for_ccmp(INT64 imm);
10661063

src/coreclr/jit/emitarm64sve.cpp

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2741,27 +2741,12 @@ void emitter::emitInsSve_R_R_I(instruction ins,
27412741
case INS_sve_ldr:
27422742
assert(insOptsNone(opt));
27432743
assert(isScalableVectorSize(size));
2744-
assert(isGeneralRegister(reg2)); // nnnnn
2744+
assert(isGeneralRegisterOrSP(reg2)); // nnnnn
27452745
assert(insScalableOptsNone(sopt));
2746-
2747-
// imm is the number of bytes to offset by. The instruction requires a multiple of the
2748-
// vector length ([#imm mul vl]). If it doesn't fit then stash the resulting address
2749-
// into a register.
2750-
if (emitIns_valid_imm_for_scaled_sve_ldst_offset(imm))
2751-
{
2752-
// TODO-SVE: This assumes 128bit SVE.
2753-
imm = imm / 16;
2754-
}
2755-
else
2756-
{
2757-
regNumber rsvdReg = codeGen->rsGetRsvdReg();
2758-
codeGen->instGen_Set_Reg_To_Base_Plus_Imm(EA_PTRSIZE, rsvdReg, reg2, imm);
2759-
reg2 = rsvdReg;
2760-
imm = 0;
2761-
}
2762-
27632746
assert(isValidSimm<9>(imm));
27642747

2748+
reg2 = encodingSPtoZR(reg2);
2749+
27652750
if (isVectorRegister(reg1))
27662751
{
27672752
fmt = IF_SVE_IE_2A;
@@ -2776,27 +2761,12 @@ void emitter::emitInsSve_R_R_I(instruction ins,
27762761
case INS_sve_str:
27772762
assert(insOptsNone(opt));
27782763
assert(isScalableVectorSize(size));
2779-
assert(isGeneralRegister(reg2)); // nnnnn
2764+
assert(isGeneralRegisterOrSP(reg2)); // nnnnn
27802765
assert(insScalableOptsNone(sopt));
2781-
2782-
// imm is the number of bytes to offset by. The instruction requires a multiple of the
2783-
// vector length ([#imm mul vl]). If it doesn't fit then stash the resulting address
2784-
// into a register.
2785-
if (emitIns_valid_imm_for_scaled_sve_ldst_offset(imm))
2786-
{
2787-
// TODO-SVE: This assumes 128bit SVE.
2788-
imm = imm / 16;
2789-
}
2790-
else
2791-
{
2792-
regNumber rsvdReg = codeGen->rsGetRsvdReg();
2793-
codeGen->instGen_Set_Reg_To_Base_Plus_Imm(EA_PTRSIZE, rsvdReg, reg2, imm);
2794-
reg2 = rsvdReg;
2795-
imm = 0;
2796-
}
2797-
27982766
assert(isValidSimm<9>(imm));
27992767

2768+
reg2 = encodingSPtoZR(reg2);
2769+
28002770
if (isVectorRegister(reg1))
28012771
{
28022772
fmt = IF_SVE_JH_2A;

src/coreclr/jit/lower.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7679,6 +7679,12 @@ bool Lowering::TryCreateAddrMode(GenTree* addr, bool isContainable, GenTree* par
76797679
// because we won't be able to use ldar/star
76807680
return false;
76817681
}
7682+
7683+
// TODO-SVE: Create an addressable node containing an index scaled by VL or PL
7684+
if (parent->TypeIs(TYP_MASK, TYP_SIMD))
7685+
{
7686+
return false;
7687+
}
76827688
#endif
76837689

76847690
GenTree* base = nullptr;

0 commit comments

Comments
 (0)