Skip to content

Commit ab675a9

Browse files
authored
[SYCL][ESIMD] Fix for an assertion when lowering esimd_unpack_mask (#4719)
esimd_unpack_mask call with a constant argument may trigger an assertion in ESIMD lowering pass when it tries to cast a constant value to instruction. Signed-off-by: Sergey Dmitriev <[email protected]>
1 parent 8d979f0 commit ab675a9

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

llvm/lib/SYCLLowerIR/LowerESIMD.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,8 @@ static void translateUnPackMask(CallInst &CI) {
789789
if (Width > N) {
790790
llvm::Type *Ty = llvm::IntegerType::get(Context, N);
791791
Arg0 = Builder.CreateTrunc(Arg0, Ty);
792-
cast<llvm::Instruction>(Arg0)->setDebugLoc(CI.getDebugLoc());
792+
if (auto *Trunc = dyn_cast<llvm::Instruction>(Arg0))
793+
Trunc->setDebugLoc(CI.getDebugLoc());
793794
}
794795
assert(Arg0->getType()->getPrimitiveSizeInBits() == N);
795796
Arg0 = Builder.CreateBitCast(

llvm/test/SYCLLowerIR/esimd_lower_crash_zext.ll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,13 @@ define spir_func <32 x i16> @_Z3foov() {
1313
}
1414

1515
declare dso_local spir_func <32 x i16> @_Z19__esimd_unpack_maskILi32EEN2cl4sycl5INTEL3gpu11vector_typeItXT_EE4typeEj(i32)
16+
17+
define spir_func <16 x i16> @_Z3barv() {
18+
; CHECK-LABEL: @_Z3barv(
19+
; CHECK: ret <16 x i16> zext (<16 x i1> bitcast (<1 x i16> <i16 15> to <16 x i1>) to <16 x i16>)
20+
;
21+
%call.i.i = call spir_func <16 x i16> @_Z19__esimd_unpack_maskILi16EEN2cl4sycl3ext5intel12experimental5esimd6detail11vector_typeItXT_EE4typeEj(i32 15)
22+
ret <16 x i16> %call.i.i
23+
}
24+
25+
declare dso_local spir_func <16 x i16> @_Z19__esimd_unpack_maskILi16EEN2cl4sycl3ext5intel12experimental5esimd6detail11vector_typeItXT_EE4typeEj(i32)

0 commit comments

Comments
 (0)