Skip to content

Commit e166627

Browse files
mshelegoigcbot
authored andcommitted
[IGC VC] Prevent assert in GenXUnbaling
Do not call Instruction::comesBefore() if instructions are in different basic blocks - this results in assertion
1 parent ae84fc3 commit e166627

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
@@ -443,8 +443,9 @@ bool canBeSafelyHoisted(Instruction *Inst, Instruction *InsertBefore) {
443443
if (!InsertBefore->comesBefore(Inst))
444444
return false;
445445
auto IsDefinedAtInsertPoint = [InsertBefore](Value *V) {
446-
return !isa<Instruction>(V) ||
447-
cast<Instruction>(V)->comesBefore(InsertBefore);
446+
auto *Inst = dyn_cast<Instruction>(V);
447+
return !Inst || Inst->getParent() == InsertBefore->getParent() &&
448+
Inst->comesBefore(InsertBefore);
448449
};
449450
#endif
450451
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)