Skip to content

Commit 1978fc2

Browse files
[release/8.0] Arm64: Pass the small size accurately to emitIns_valid_imm_for_ldst_offset (#92041)
* Pass the right size to check if immediate will fit or not * Revert "Pass the right size to check if immediate will fit or not" This reverts commit d7c511a. * review feedback * fix the size to be passed to the instruction * fix the assert --------- Co-authored-by: Kunal Pathak <Kunal.Pathak@microsoft.com>
1 parent 3aec961 commit 1978fc2

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/coreclr/jit/codegenarm64.cpp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,19 +327,38 @@ bool CodeGen::genInstrWithConstant(instruction ins,
327327
break;
328328

329329
case INS_strb:
330+
assert(size == EA_1BYTE);
331+
immFitsInIns = emitter::emitIns_valid_imm_for_ldst_offset(imm, EA_1BYTE);
332+
break;
333+
330334
case INS_strh:
335+
assert(size == EA_2BYTE);
336+
immFitsInIns = emitter::emitIns_valid_imm_for_ldst_offset(imm, EA_2BYTE);
337+
break;
338+
331339
case INS_str:
332340
// reg1 is a source register for store instructions
333341
assert(tmpReg != reg1); // regTmp can not match any source register
334342
immFitsInIns = emitter::emitIns_valid_imm_for_ldst_offset(imm, size);
335343
break;
336344

345+
case INS_ldrb:
337346
case INS_ldrsb:
347+
immFitsInIns = emitter::emitIns_valid_imm_for_ldst_offset(imm, EA_1BYTE);
348+
break;
349+
350+
case INS_ldrh:
338351
case INS_ldrsh:
352+
immFitsInIns = emitter::emitIns_valid_imm_for_ldst_offset(imm, EA_2BYTE);
353+
break;
354+
339355
case INS_ldrsw:
340-
case INS_ldrb:
341-
case INS_ldrh:
356+
assert(size == EA_4BYTE);
357+
immFitsInIns = emitter::emitIns_valid_imm_for_ldst_offset(imm, EA_4BYTE);
358+
break;
359+
342360
case INS_ldr:
361+
assert((size == EA_4BYTE) || (size == EA_8BYTE) || (size == EA_16BYTE));
343362
immFitsInIns = emitter::emitIns_valid_imm_for_ldst_offset(imm, size);
344363
break;
345364

0 commit comments

Comments
 (0)