Skip to content

Commit

Permalink
[release/8.0] Arm64: Pass the small size accurately to emitIns_valid_…
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
github-actions[bot] and kunalspathak committed Sep 14, 2023
1 parent 3aec961 commit 1978fc2
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/coreclr/jit/codegenarm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,19 +327,38 @@ bool CodeGen::genInstrWithConstant(instruction ins,
break;

case INS_strb:
assert(size == EA_1BYTE);
immFitsInIns = emitter::emitIns_valid_imm_for_ldst_offset(imm, EA_1BYTE);
break;

case INS_strh:
assert(size == EA_2BYTE);
immFitsInIns = emitter::emitIns_valid_imm_for_ldst_offset(imm, EA_2BYTE);
break;

case INS_str:
// reg1 is a source register for store instructions
assert(tmpReg != reg1); // regTmp can not match any source register
immFitsInIns = emitter::emitIns_valid_imm_for_ldst_offset(imm, size);
break;

case INS_ldrb:
case INS_ldrsb:
immFitsInIns = emitter::emitIns_valid_imm_for_ldst_offset(imm, EA_1BYTE);
break;

case INS_ldrh:
case INS_ldrsh:
immFitsInIns = emitter::emitIns_valid_imm_for_ldst_offset(imm, EA_2BYTE);
break;

case INS_ldrsw:
case INS_ldrb:
case INS_ldrh:
assert(size == EA_4BYTE);
immFitsInIns = emitter::emitIns_valid_imm_for_ldst_offset(imm, EA_4BYTE);
break;

case INS_ldr:
assert((size == EA_4BYTE) || (size == EA_8BYTE) || (size == EA_16BYTE));
immFitsInIns = emitter::emitIns_valid_imm_for_ldst_offset(imm, size);
break;

Expand Down

0 comments on commit 1978fc2

Please sign in to comment.