Skip to content

Commit 642be1c

Browse files
mshelegopszymich
authored andcommitted
[IGC VC] Prevent assert in GenXUnbaling
Do not call Instruction::comesBefore() if instructions are in different basic blocks - this results in assertion (cherry picked from commit e166627)
1 parent 2b085bb commit 642be1c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

IGC/VectorCompiler/lib/GenXCodeGen/GenXUnbaling.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,9 @@ bool canBeSafelyHoisted(Instruction *Inst, Instruction *InsertBefore) {
442442
if (!InsertBefore->comesBefore(Inst))
443443
return false;
444444
auto IsDefinedAtInsertPoint = [InsertBefore](Value *V) {
445-
return !isa<Instruction>(V) ||
446-
cast<Instruction>(V)->comesBefore(InsertBefore);
445+
auto *Inst = dyn_cast<Instruction>(V);
446+
return !Inst || Inst->getParent() == InsertBefore->getParent() &&
447+
Inst->comesBefore(InsertBefore);
447448
};
448449
#endif
449450
return std::all_of(Inst->value_op_begin(), Inst->value_op_end(),

IGC/VectorCompiler/test/GenXUnbaling/debug-shorten-lr.ll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ entry:
3838
call void @llvm.dbg.value(metadata <16 x i32> %rdregioni, metadata !12, metadata !DIExpression()), !dbg !18
3939
%wrregioni = call <16 x i32> @llvm.genx.wrregioni.v16i32.v16i32.v16i32.i32.i1(<16 x i32> %rdregioni, <16 x i32> %load, i32 1, i32 1, i32 0, i16 4, i32 0, i1 true), !dbg !19
4040
call void @llvm.dbg.value(metadata <16 x i32> %wrregioni, metadata !13, metadata !DIExpression()), !dbg !19
41+
br label %body
42+
43+
body:
4144
%wrregioni2 = call <16 x i32> @llvm.genx.wrregioni.v16i32.v16i32.v16i32.i32.i1(<16 x i32> %wrregioni, <16 x i32> %load, i32 1, i32 1, i32 0, i16 6, i32 0, i1 true), !dbg !20
4245
call void @llvm.dbg.value(metadata <16 x i32> %wrregioni2, metadata !14, metadata !DIExpression()), !dbg !20
4346
%rdregioni3 = call <16 x i32> @llvm.genx.rdregioni.v16i32.v16i32.i16(<16 x i32> %wrregioni, i32 1, i32 1, i32 0, i16 0, i32 0), !dbg !21

0 commit comments

Comments
 (0)