@@ -5195,7 +5195,11 @@ inline UNATIVE_OFFSET emitter::emitInsSizeSVCalcDisp(instrDesc* id, code_t code,
5195
5195
{
5196
5196
ssize_t compressedDsp;
5197
5197
5198
- if (TryEvexCompressDisp8Byte(id, dsp, &compressedDsp, &dspInByte))
5198
+ // Only the scaling factor of the original EVEX instructions can be changed by embedded broadcast.
5199
+ // If the instruction does not have tuple type info, say extended EVEX from APX, the scaling factor is
5200
+ // constantly 1, then this optimization cannot be performed, and whether disp8 or disp32 should be applied
5201
+ // only depends dspInByte.
5202
+ if (TryEvexCompressDisp8Byte(id, dsp, &compressedDsp, &dspInByte) && hasTupleTypeInfo(ins))
5199
5203
{
5200
5204
SetEvexCompressedDisplacement(id);
5201
5205
}
@@ -5368,7 +5372,7 @@ UNATIVE_OFFSET emitter::emitInsSizeAM(instrDesc* id, code_t code)
5368
5372
{
5369
5373
ssize_t compressedDsp;
5370
5374
5371
- if (TryEvexCompressDisp8Byte(id, dsp, &compressedDsp, &dspInByte))
5375
+ if (TryEvexCompressDisp8Byte(id, dsp, &compressedDsp, &dspInByte) && hasTupleTypeInfo(ins) )
5372
5376
{
5373
5377
SetEvexCompressedDisplacement(id);
5374
5378
}
@@ -14672,13 +14676,16 @@ BYTE* emitter::emitOutputAM(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc)
14672
14676
assert(isCompressed && dspInByte);
14673
14677
dsp = compressedDsp;
14674
14678
}
14675
- else if (TakesEvexPrefix(id) || TakesApxExtendedEvexPrefix(id ))
14679
+ else if (TakesEvexPrefix(id) && !IsBMIInstruction(ins ))
14676
14680
{
14677
- assert(!TryEvexCompressDisp8Byte(id, dsp, &compressedDsp, &dspInByte));
14681
+ assert(!( TryEvexCompressDisp8Byte(id, dsp, &compressedDsp, &dspInByte) && hasTupleTypeInfo(ins) ));
14678
14682
dspInByte = false;
14679
14683
}
14680
14684
else
14681
14685
{
14686
+ // TODO-XArch-APX: for now, Extended Evex instruction will not have compressed displacement, or more
14687
+ // accurately, extended evex may not have compressed displacement optimization as the scaling factor is
14688
+ // constantly 1.
14682
14689
dspInByte = ((signed char)dsp == (ssize_t)dsp);
14683
14690
}
14684
14691
dspIsZero = (dsp == 0);
@@ -15556,7 +15563,7 @@ BYTE* emitter::emitOutputSV(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc)
15556
15563
assert(isCompressed && dspInByte);
15557
15564
dsp = (int)compressedDsp;
15558
15565
}
15559
- else if (TakesEvexPrefix(id) || TakesApxExtendedEvexPrefix(id ))
15566
+ else if (TakesEvexPrefix(id) && !IsBMIInstruction(ins ))
15560
15567
{
15561
15568
#if FEATURE_FIXED_OUT_ARGS
15562
15569
// TODO-AMD64-CQ: We should be able to accurately predict this when FEATURE_FIXED_OUT_ARGS
@@ -17904,6 +17911,7 @@ BYTE* emitter::emitOutputLJ(insGroup* ig, BYTE* dst, instrDesc* i)
17904
17911
idAmd->idCodeSize(sz);
17905
17912
17906
17913
code = insCodeRM(ins);
17914
+ code = AddX86PrefixIfNeeded(id, code, id->idOpSize());
17907
17915
code |= (insEncodeReg345(id, id->idReg1(), EA_PTRSIZE, &code) << 8);
17908
17916
17909
17917
dst = emitOutputAM(dst, idAmd, code, nullptr);
0 commit comments