@@ -661,6 +661,8 @@ void vISAVerifier::verifyRegion(const CISA_INST *inst, unsigned i) {
661
661
(exec_sz - 1 ) * h_stride_val * VN_size + VN_size - 1 ;
662
662
}
663
663
664
+ unsigned grfSize = irBuilder->getGRFSize ();
665
+
664
666
// Check if the operand may touch more than 2 GRFs due to bad alignment
665
667
// So far vISA is able to handle the splitting of:
666
668
// moves, logic, cmp and arithmetic instructions
@@ -669,35 +671,43 @@ void vISAVerifier::verifyRegion(const CISA_INST *inst, unsigned i) {
669
671
ISA_Inst_Table[opcode].type != ISA_Inst_Compare &&
670
672
ISA_Inst_Table[opcode].type != ISA_Inst_Arith) {
671
673
REPORT_INSTRUCTION (
672
- options, (irBuilder-> getGRFSize () * 2u ) > last_region_elt_byte,
674
+ options, (grfSize * 2u ) > last_region_elt_byte,
673
675
" CISA operand region access out of 2 GRF boundary (within %d "
674
676
" bytes): %d" ,
675
- (irBuilder-> getGRFSize () * 2 ), last_region_elt_byte);
677
+ (grfSize * 2 ), last_region_elt_byte);
676
678
677
679
// check if the operand may touch more than 2 GRFs due to bad alignment
678
680
unsigned startByte =
679
681
getStartByteOffset (header, var, numPreDefinedVars) +
680
- row_offset * irBuilder-> getGRFSize () +
682
+ row_offset * grfSize +
681
683
col_offset * CISATypeTable[var->getType ()].typeSize ;
682
684
unsigned endByte = startByte + last_region_elt_byte;
683
- unsigned startGRF = startByte / irBuilder-> getGRFSize () ;
684
- unsigned endGRF = endByte / irBuilder-> getGRFSize () ;
685
+ unsigned startGRF = startByte / grfSize ;
686
+ unsigned endGRF = endByte / grfSize ;
685
687
REPORT_INSTRUCTION (
686
688
options, endGRF == startGRF || endGRF == (startGRF + 1 ),
687
689
" CISA operand accesses more than 2 GRF due to mis-alignment: start "
688
690
" byte offset = %d, end byte offset = %d" ,
689
691
startByte, endByte);
690
692
}
691
693
692
- unsigned firstElementIndex =
693
- row_offset * irBuilder->getGRFSize () + col_offset * VN_size;
694
+ unsigned firstElementIndex = row_offset * grfSize + col_offset * VN_size;
694
695
695
696
for (int i = 0 ; i < exec_sz / width_val; i++) {
696
697
for (int j = 0 ; j < width_val; j++) {
697
698
unsigned region_offset =
698
699
firstElementIndex +
699
700
(((i * v_stride_val) + (j * h_stride_val)) * VN_size);
700
701
702
+ // Madw instruction has both low and high results. So, need to check
703
+ // the offset of high result.
704
+ unsigned hiOffset = 0 ;
705
+ if (inst->opcode == ISA_MADW) {
706
+ hiOffset = (region_offset - firstElementIndex + 1 + grfSize - 1 ) &
707
+ (~(grfSize - 1 )); // GRF-aligned
708
+ region_offset += hiOffset;
709
+ }
710
+
701
711
if (region_offset >= var_size) {
702
712
#ifndef DLL_MODE
703
713
std::cout << " WARNING: CISA region and offset cause an out of "
@@ -709,15 +719,28 @@ void vISAVerifier::verifyRegion(const CISA_INST *inst, unsigned i) {
709
719
std::cout << " The access fails the following check to determine "
710
720
" correct bounds (see CISA manual section 5.1 "
711
721
" Region-based Addressing):\n " ;
712
- std::cout << " (row_offset * GRF_SIZE + col_offset * type_size) + "
713
- " (((i * v_stride) + (j * h_stride)) * type_size) < "
714
- " type_size * num_elements:\n " ;
715
- std::cout << " (" << (int )row_offset << " * "
716
- << (int )irBuilder->getGRFSize () << " + "
717
- << (int )col_offset << " * " << VN_size << " ) + (((" << i
718
- << " * " << v_stride_val << " ) + (" << j << " * "
719
- << h_stride_val << " )) * " << VN_size << " ) < " << VN_size
720
- << " * " << num_elements << " \n " ;
722
+ if (inst->opcode == ISA_MADW) {
723
+ std::cout
724
+ << " (row_offset * GRF_SIZE + col_offset * type_size) + "
725
+ " (((i * v_stride) + (j * h_stride)) * type_size) + "
726
+ " high_offset < type_size * num_elements:\n " ;
727
+ std::cout << " (" << (int )row_offset << " * " << grfSize << " + "
728
+ << (int )col_offset << " * " << VN_size << " ) + (((" << i
729
+ << " * " << v_stride_val << " ) + (" << j << " * "
730
+ << h_stride_val << " )) * " << VN_size << " ) + "
731
+ << hiOffset << " < " << VN_size << " * "
732
+ << num_elements << " \n " ;
733
+ } else {
734
+ std::cout
735
+ << " (row_offset * GRF_SIZE + col_offset * type_size) + "
736
+ " (((i * v_stride) + (j * h_stride)) * type_size) < "
737
+ " type_size * num_elements:\n " ;
738
+ std::cout << " (" << (int )row_offset << " * " << grfSize << " + "
739
+ << (int )col_offset << " * " << VN_size << " ) + (((" << i
740
+ << " * " << v_stride_val << " ) + (" << j << " * "
741
+ << h_stride_val << " )) * " << VN_size << " ) < "
742
+ << VN_size << " * " << num_elements << " \n " ;
743
+ }
721
744
std::cout << " Violating Instruction: "
722
745
<< header->printInstruction (inst, options)
723
746
<< " \n " ;
0 commit comments