Bitcast in StatelessToStateful pass

The fix prevents crash in StatelessToStateful pass
if all ptr usees are bitcast instructions.
This commit is contained in:
Rybalov, Viacheslav G
2025-08-14 12:14:51 +00:00
committed by igcbot
parent a057740b8a
commit e2c4ba8d76
3 changed files with 86 additions and 1 deletions

View File

@ -522,7 +522,7 @@ bool StatelessToStateful::pointerIsFromKernelArgument(Value &ptr) {
static alignment_t determinePointerAlignment(Value *Ptr, const DataLayout &DL, AssumptionCache *AC,
Instruction *InsertionPt) {
alignment_t BestAlign = 0;
alignment_t BestAlign = 1;
// 1) Examine uses: look for loads/stores (which may carry explicit
// alignment) or a GEP that reveals an ABI alignment from its element

View File

@ -0,0 +1,44 @@
;=========================== begin_copyright_notice ============================
;
; Copyright (C) 2025 Intel Corporation
;
; SPDX-License-Identifier: MIT
;
;============================ end_copyright_notice =============================
; RUN: igc_opt --typed-pointers %s -S -o - -igc-stateless-to-stateful-resolution -igc-serialize-metadata -platformpvc | FileCheck %s
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-n8:16:32"
define spir_kernel void @test(i64 addrspace(1)* %dst, i32 %bufferOffset) {
entry:
; CHECK: %[[OFFSET:[0-9]+]] = add i32 %bufferOffset, 1
; CHECK: %[[PTR:[0-9]+]] = inttoptr i32 %[[OFFSET]] to i8 addrspace(131072)*
; CHECK: store i8 0, i8 addrspace(131072)* %[[PTR]], align 1
%bc = bitcast i64 addrspace(1)* %dst to i8 addrspace(1)*
%ptr = getelementptr inbounds i8, i8 addrspace(1)* %bc, i64 1
store i8 0, i8 addrspace(1)* %ptr, align 1
ret void
}
!IGCMetadata = !{!0}
!igc.functions = !{!1}
!0 = !{!"ModuleMD", !5, !16}
!1 = !{void (i64 addrspace(1)*, i32)* @test, !2}
!2 = !{!3, !14}
!3 = !{!"function_type", i32 0}
!4 = !{}
!5 = !{!"FuncMD", !6, !7}
!6 = !{!"FuncMDMap[0]", void (i64 addrspace(1)*, i32)* @test}
!7 = !{!"FuncMDValue[0]", !8}
!8 = !{!"resAllocMD", !9}
!9 = !{!"argAllocMDList", !10}
!10 = !{!"argAllocMDListVec[0]", !11}
!11 = !{!"type", i32 1}
!12 = !{!"extensionType", i32 -1}
!13 = !{!"indexType", i32 0}
!14 = !{!"implicit_arg_desc", !15}
!15 = !{i32 15}
!16 = !{!"compOpt", !17}
!17 = !{!"HasBufferOffsetArg", i1 true}

View File

@ -0,0 +1,41 @@
;=========================== begin_copyright_notice ============================
;
; Copyright (C) 2025 Intel Corporation
;
; SPDX-License-Identifier: MIT
;
;============================ end_copyright_notice =============================
; RUN: igc_opt --opaque-pointers %s -S -o - -igc-stateless-to-stateful-resolution -igc-serialize-metadata -platformpvc | FileCheck %s
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-n8:16:32"
define spir_kernel void @test(ptr addrspace(1) %dst, i32 %bufferOffset) {
entry:
; CHECK: %[[OFFSET:[0-9]+]] = add i32 %bufferOffset, 1
; CHECK: %[[PTR:[0-9]+]] = inttoptr i32 %[[OFFSET]] to ptr addrspace(131072)
; CHECK: store i8 0, ptr addrspace(131072) %[[PTR]], align 1
%bc = bitcast ptr addrspace(1) %dst to ptr addrspace(1)
%ptr = getelementptr inbounds i8, ptr addrspace(1) %bc, i64 1
store i8 0, ptr addrspace(1) %ptr, align 1
ret void
}
!IGCMetadata = !{!0}
!igc.functions = !{!10}
!0 = !{!"ModuleMD", !1, !8}
!1 = !{!"FuncMD", !2, !3}
!2 = !{!"FuncMDMap[0]", ptr @test}
!3 = !{!"FuncMDValue[0]", !4}
!4 = !{!"resAllocMD", !5}
!5 = !{!"argAllocMDList", !6}
!6 = !{!"argAllocMDListVec[0]", !7}
!7 = !{!"type", i32 1}
!8 = !{!"compOpt", !9}
!9 = !{!"HasBufferOffsetArg", i1 true}
!10 = !{ptr @test, !11}
!11 = !{!12, !13}
!12 = !{!"function_type", i32 0}
!13 = !{!"implicit_arg_desc", !14}
!14 = !{i32 15}