@@ -492,10 +492,13 @@ emitter::code_t emitter::AddRexWPrefix(instruction ins, code_t code)
492
492
if (UseVEXEncoding () && IsAVXInstruction (ins))
493
493
{
494
494
// 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));
496
498
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
+ }
499
502
}
500
503
#ifdef _TARGET_AMD64_
501
504
return emitter::code_t (code | 0x4800000000ULL );
@@ -512,10 +515,13 @@ emitter::code_t emitter::AddRexRPrefix(instruction ins, code_t code)
512
515
if (UseVEXEncoding () && IsAVXInstruction (ins))
513
516
{
514
517
// Right now support 3-byte VEX prefix
515
- assert (hasVexPrefix (code));
518
+ if (TakesVexPrefix (ins))
519
+ {
520
+ assert (hasVexPrefix (code));
516
521
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
+ }
519
525
}
520
526
521
527
return code | 0x4400000000ULL ;
@@ -526,10 +532,13 @@ emitter::code_t emitter::AddRexXPrefix(instruction ins, code_t code)
526
532
if (UseVEXEncoding () && IsAVXInstruction (ins))
527
533
{
528
534
// Right now support 3-byte VEX prefix
529
- assert (hasVexPrefix (code));
535
+ if (TakesVexPrefix (ins))
536
+ {
537
+ assert (hasVexPrefix (code));
530
538
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
+ }
533
542
}
534
543
535
544
return code | 0x4200000000ULL ;
@@ -540,10 +549,13 @@ emitter::code_t emitter::AddRexBPrefix(instruction ins, code_t code)
540
549
if (UseVEXEncoding () && IsAVXInstruction (ins))
541
550
{
542
551
// Right now support 3-byte VEX prefix
543
- assert (hasVexPrefix (code));
552
+ if (TakesVexPrefix (ins))
553
+ {
554
+ assert (hasVexPrefix (code));
544
555
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
+ }
547
559
}
548
560
549
561
return code | 0x4100000000ULL ;
0 commit comments