Skip to content

Commit 54e8e3b

Browse files
stefan-iligcbot
authored andcommitted
Change default SIMD size guess for PVC family
Change PVC SIMD size guess to help with register pressure calculation.
1 parent 10de478 commit 54e8e3b

File tree

2 files changed

+66
-8
lines changed

2 files changed

+66
-8
lines changed

IGC/Compiler/CISACodeGen/IGCLivenessAnalysis.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ SIMDMode IGCLivenessAnalysisBase::bestGuessSIMDSize(Function *F) {
5757
return SIMDMode::SIMD32;
5858
}
5959

60-
auto FG = FGA ? FGA->getGroup(F) : nullptr;
61-
bool hasStackCall = (FG && FG->hasStackCall()) || (F && F->hasFnAttribute("visaStackCall"));
62-
bool isIndirectGroup = FG && FGA->isIndirectCallGroup(FG);
63-
bool hasSubroutine = FG && !FG->isSingle() && !hasStackCall && !isIndirectGroup;
64-
6560
// if we can find metadata with stipulations how we should compile we use it
6661
if (F && MDUtils->findFunctionsInfoItem(F) != MDUtils->end_FunctionsInfo()) {
6762
IGC::IGCMD::FunctionInfoMetaDataHandle funcInfoMD = MDUtils->getFunctionsInfoItem(F);
@@ -72,8 +67,15 @@ SIMDMode IGCLivenessAnalysisBase::bestGuessSIMDSize(Function *F) {
7267

7368
// rule for pvc
7469
if (CGCtx->platform.isProductChildOf(IGFX_PVC)) {
75-
if (hasSubroutine)
70+
bool abortOnSpills =
71+
IGC_GET_FLAG_VALUE(AllowSIMD16DropForXE2Plus) && (CGCtx->platform.isCoreXE2() || CGCtx->platform.isCoreXE3());
72+
auto FG = FGA ? FGA->getGroup(F) : nullptr;
73+
bool hasStackCall = (FG && FG->hasStackCall()) || (F && F->hasFnAttribute("visaStackCall"));
74+
bool isIndirectGroup = FG && FGA->isIndirectCallGroup(FG);
75+
bool hasSubroutine = FG && !FG->isSingle() && !hasStackCall && !isIndirectGroup;
76+
if (abortOnSpills || hasSubroutine) {
7677
return SIMDMode::SIMD16;
78+
}
7779
return SIMDMode::SIMD32;
7880
}
7981

@@ -128,7 +130,7 @@ unsigned int IGCLivenessAnalysisBase::addOperandsToSet(llvm::Instruction *Inst,
128130
if (Phi)
129131
return 0;
130132

131-
// do not process debug instructions and lifetimehints in any way
133+
// do not process debug instructions and lifetimehints in any way
132134
if (Inst->isDebugOrPseudoInst() || Inst->isLifetimeStartOrEnd())
133135
return 0;
134136

@@ -573,7 +575,6 @@ bool IGCRegisterPressurePrinter::runOnFunction(llvm::Function &F) {
573575
return false;
574576
}
575577

576-
577578
char IGCRegisterPressurePublisher::ID = 0;
578579
// Register pass to igc-opt
579580
#define PASS_FLAG3 "igc-pressure-publisher"
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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: regkeys
10+
; UNSUPPORTED: system-windows
11+
; Test that for platforms PVC (and newer) with abort on spill we correctly guess SIMD16 as SIMD size and based on it calculate correct register pressure.
12+
; For estimate of SIMD32 register pressure wiuld be 16 and rematerialization would be done.
13+
14+
; RUN: igc_opt -platformlnl --typed-pointers %s -S -o - -igc-clone-address-arithmetic --regkey=RematChainLimit=10 --regkey=RematFlowThreshold=100 --regkey=RematRPELimit=10 --dce | FileCheck %s
15+
16+
; CHECK-NOT: remat
17+
define spir_kernel void @main(double addrspace(1)* %base, i64 %offset, i64 %I, i64 %J) {
18+
19+
%baseArith = ptrtoint double addrspace(1)* %base to i64
20+
%basePtr = mul nuw nsw i64 %offset, 207368
21+
%offsetI = mul nsw i64 %I, 1288
22+
%offsetJ = shl nsw i64 %J, 3
23+
24+
%a0 = add i64 %baseArith, 100780848
25+
%a1 = add i64 %a0, %basePtr
26+
%a2 = add i64 %a1, %offsetI
27+
%a3 = add i64 %a2, %offsetJ
28+
%a4 = inttoptr i64 %a3 to double addrspace(1)*
29+
%r0 = load double, double addrspace(1)* %a4, align 8
30+
31+
%rr0 = fmul double %r0, 2.0
32+
33+
store double %rr0, double addrspace(1)* %a4
34+
ret void
35+
}
36+
37+
38+
define spir_func void @bar(double addrspace(1)* %base, i64 %offset, i64 %I, i64 %J) {
39+
%baseArith = ptrtoint double addrspace(1)* %base to i64
40+
%basePtr = mul nuw nsw i64 %offset, 207368
41+
%offsetI = mul nsw i64 %I, 1288
42+
%offsetJ = shl nsw i64 %J, 3
43+
44+
%a0 = add i64 %baseArith, 100780848
45+
%a1 = add i64 %a0, %basePtr
46+
%a2 = add i64 %a1, %offsetI
47+
%a3 = add i64 %a2, %offsetJ
48+
%a4 = inttoptr i64 %a3 to double addrspace(1)*
49+
%a5 = inttoptr i64 %a3 to i64 addrspace(1)*
50+
%r0 = load double, double addrspace(1)* %a4, align 8
51+
52+
%rr0 = fmul double %r0, 2.0
53+
54+
%cast_a5 = bitcast i64 addrspace(1)* %a5 to double addrspace(1)*
55+
store double %rr0, double addrspace(1)* %cast_a5
56+
ret void
57+
}

0 commit comments

Comments
 (0)