Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 181e81b

Browse files
committed
Updating emitxarch to check TakesVexPrefix(ins) when adding REX bits.
1 parent 8f77ecf commit 181e81b

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

src/jit/emitxarch.cpp

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -492,10 +492,13 @@ emitter::code_t emitter::AddRexWPrefix(instruction ins, code_t code)
492492
if (UseVEXEncoding() && IsAVXInstruction(ins))
493493
{
494494
// W-bit is available only in 3-byte VEX prefix that starts with byte C4.
495-
assert(hasVexPrefix(code));
495+
if (TakesVexPrefix(ins))
496+
{
497+
assert(hasVexPrefix(code));
496498

497-
// W-bit is the only bit that is added in non bit-inverted form.
498-
return emitter::code_t(code | 0x00008000000000ULL);
499+
// W-bit is the only bit that is added in non bit-inverted form.
500+
return emitter::code_t(code | 0x00008000000000ULL);
501+
}
499502
}
500503
#ifdef _TARGET_AMD64_
501504
return emitter::code_t(code | 0x4800000000ULL);
@@ -512,10 +515,13 @@ emitter::code_t emitter::AddRexRPrefix(instruction ins, code_t code)
512515
if (UseVEXEncoding() && IsAVXInstruction(ins))
513516
{
514517
// Right now support 3-byte VEX prefix
515-
assert(hasVexPrefix(code));
518+
if (TakesVexPrefix(ins))
519+
{
520+
assert(hasVexPrefix(code));
516521

517-
// R-bit is added in bit-inverted form.
518-
return code & 0xFF7FFFFFFFFFFFULL;
522+
// R-bit is added in bit-inverted form.
523+
return code & 0xFF7FFFFFFFFFFFULL;
524+
}
519525
}
520526

521527
return code | 0x4400000000ULL;
@@ -526,10 +532,13 @@ emitter::code_t emitter::AddRexXPrefix(instruction ins, code_t code)
526532
if (UseVEXEncoding() && IsAVXInstruction(ins))
527533
{
528534
// Right now support 3-byte VEX prefix
529-
assert(hasVexPrefix(code));
535+
if (TakesVexPrefix(ins))
536+
{
537+
assert(hasVexPrefix(code));
530538

531-
// X-bit is added in bit-inverted form.
532-
return code & 0xFFBFFFFFFFFFFFULL;
539+
// X-bit is added in bit-inverted form.
540+
return code & 0xFFBFFFFFFFFFFFULL;
541+
}
533542
}
534543

535544
return code | 0x4200000000ULL;
@@ -540,10 +549,13 @@ emitter::code_t emitter::AddRexBPrefix(instruction ins, code_t code)
540549
if (UseVEXEncoding() && IsAVXInstruction(ins))
541550
{
542551
// Right now support 3-byte VEX prefix
543-
assert(hasVexPrefix(code));
552+
if (TakesVexPrefix(ins))
553+
{
554+
assert(hasVexPrefix(code));
544555

545-
// B-bit is added in bit-inverted form.
546-
return code & 0xFFDFFFFFFFFFFFULL;
556+
// B-bit is added in bit-inverted form.
557+
return code & 0xFFDFFFFFFFFFFFULL;
558+
}
547559
}
548560

549561
return code | 0x4100000000ULL;

0 commit comments

Comments
 (0)