Skip to content

Commit 1694f5e

Browse files
aratajewfda0
authored andcommitted
Add support for Freeze instruction in WIAnalysis pass
This change enables the `WIAnalysis` pass to correctly handle `Freeze` instructions. Without this enhancement, there is a risk of mistakenly identifying non-uniform allocas as uniform. (cherry picked from commit db79415)
1 parent b86a5f1 commit 1694f5e

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

IGC/Compiler/CISACodeGen/WIAnalysis.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,7 @@ void WIAnalysisRunner::calculate_dep(const Value* val)
842842
else if (const VAArgInst* VAI = dyn_cast<VAArgInst>(inst)) dep = calculate_dep(VAI);
843843
#if LLVM_VERSION_MAJOR >= 10
844844
else if (inst->getOpcode() == Instruction::FNeg) dep = calculate_dep_simple(inst);
845+
else if (inst->getOpcode() == Instruction::Freeze) dep = calculate_dep_simple(inst);
845846
#endif
846847

847848
if (m_func->hasFnAttribute("KMPLOCK"))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
;=========================== begin_copyright_notice ============================
2+
;
3+
; Copyright (C) 2025 Intel Corporation
4+
;
5+
; SPDX-License-Identifier: MIT
6+
;
7+
;============================ end_copyright_notice =============================
8+
9+
; REQUIRES: llvm-14-plus, regkeys
10+
; RUN: igc_opt --opaque-pointers --igc-pressure-printer -S --disable-output --regkey=RegPressureVerbocity=1 < %s 2>&1 | FileCheck %s
11+
12+
; ------------------------------------------------
13+
; WIAnalysis
14+
; ------------------------------------------------
15+
16+
; This test checks whether the 'alloca' instruction is correctly identified as non-uniform when non-uniform
17+
; value stored in it goes through a freeze instruction.
18+
19+
; CHECK: N: {{.*}} %a = alloca i16, align 2
20+
21+
; Function Attrs: convergent nounwind
22+
define spir_kernel void @test_uniform(<8 x i32> %r0, <8 x i32> %payloadHeader, i16 %localIdX, i32 %bufferOffset) {
23+
entry:
24+
%a = alloca i16
25+
%freezed_lid = freeze i16 %localIdX
26+
store i16 %freezed_lid, i16* %a, align 2
27+
ret void
28+
}
29+
30+
!igc.functions = !{!358}
31+
32+
!358 = !{void (<8 x i32>, <8 x i32>, i32)* @test_uniform, !359}
33+
!359 = !{!360, !361}
34+
!360 = !{!"function_type", i32 0}
35+
!361 = !{!"implicit_arg_desc", !362, !363, !366, !364}
36+
!362 = !{i32 0}
37+
!363 = !{i32 1}
38+
!364 = !{i32 15, !365}
39+
!365 = !{!"explicit_arg_num", i32 0}
40+
!366 = !{i32 8}

0 commit comments

Comments
 (0)