Skip to content

Commit d3118b2

Browse files
[ESIMD] Fix a crash lowering __esimd_unpack_mask (#3196)
Co-authored-by: kbobrovs <[email protected]>
1 parent c5566b2 commit d3118b2

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

llvm/lib/SYCLLowerIR/LowerESIMD.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,8 @@ static void translateUnPackMask(CallInst &CI) {
726726
llvm::Value *TransCI = Builder.CreateZExt(
727727
Arg0, llvm::FixedVectorType::get(llvm::Type::getInt16Ty(Context), N));
728728
TransCI->takeName(&CI);
729-
cast<llvm::Instruction>(TransCI)->setDebugLoc(CI.getDebugLoc());
729+
if (llvm::Instruction *TransCInst = dyn_cast<llvm::Instruction>(TransCI))
730+
TransCInst->setDebugLoc(CI.getDebugLoc());
730731
CI.replaceAllUsesWith(TransCI);
731732
}
732733

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2+
; RUN: opt -LowerESIMD -S < %s | FileCheck %s
3+
4+
; This test checks that there is no crash while lowering
5+
; __esimd_unpack_mask when its argument is an integer constant.
6+
7+
define spir_func <32 x i16> @_Z3foov() {
8+
; CHECK-LABEL: @_Z3foov(
9+
; CHECK-NEXT: ret <32 x i16> zext (<32 x i1> bitcast (<1 x i32> <i32 1717986918> to <32 x i1>) to <32 x i16>)
10+
;
11+
%call.i.i = call spir_func <32 x i16> @_Z19__esimd_unpack_maskILi32EEN2cl4sycl5INTEL3gpu11vector_typeItXT_EE4typeEj(i32 1717986918)
12+
ret <32 x i16> %call.i.i
13+
}
14+
15+
declare dso_local spir_func <32 x i16> @_Z19__esimd_unpack_maskILi32EEN2cl4sycl5INTEL3gpu11vector_typeItXT_EE4typeEj(i32)

0 commit comments

Comments
 (0)