Skip to content

Commit ba7f4cd

Browse files
igorban-inteligcbot
authored andcommitted
Disable SIMDCF for multi-use EM instructions
For instruction with multiply input: if it use more than one EM - it is incorrect. For such instructions - we will deoptimize SIMDCF
1 parent bf1393d commit ba7f4cd

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

IGC/VectorCompiler/lib/GenXCodeGen/GenXSimdCFConformance.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ class GenXSimdCFConformance {
281281
SetVector<SimpleValue> EMVals;
282282
std::map<CallInst *, SetVector<SimpleValue>> RMVals;
283283
bool lowerSimdCF = false;
284+
SmallSet<Instruction *, 32> CrossInsts;
284285

285286
private:
286287
// GotoJoinEVs: container for goto/join Extract Value (EV) info. Also
@@ -364,6 +365,7 @@ class GenXSimdCFConformance {
364365
EMProducers.clear();
365366
LoweredEMValsMap.clear();
366367
BlocksToOptimize.clear();
368+
CrossInsts.clear();
367369
}
368370
DominatorTree *getDomTree(Function *F);
369371

@@ -852,6 +854,7 @@ void GenXSimdCFConformance::gatherEMVals() {
852854
if (!isa<Constant>(j->getValue()))
853855
EMVals.insert(*j);
854856
}
857+
CrossInsts.clear();
855858
}
856859

857860
/***********************************************************************
@@ -882,6 +885,7 @@ void GenXSimdCFConformance::gatherRMVals() {
882885
RMValsEntry->insert(*j);
883886
}
884887
}
888+
CrossInsts.clear();
885889
}
886890

887891
/***********************************************************************
@@ -2753,6 +2757,12 @@ bool GenXSimdCFConformance::getConnectedVals(
27532757
for (auto ui = Val.getValue()->use_begin(), ue = Val.getValue()->use_end();
27542758
ui != ue; ++ui) {
27552759
auto User = cast<Instruction>(ui->getUser());
2760+
// Can't have 2 difference EMs in one instruction
2761+
if (!isa<PHINode>(User) && !isa<CallInst>(User) &&
2762+
!isa<ExtractValueInst>(User) && !CrossInsts.insert(User).second) {
2763+
LLVM_DEBUG(dbgs() << "Found multy-EM use instruction:\n" << *User);
2764+
lowerSimdCF = true;
2765+
}
27562766
LLVM_DEBUG(dbgs() << "getConnectedVals: -> geted " << *User << "\n");
27572767
if (auto Phi = dyn_cast<PHINode>(User)) {
27582768
// Use in phi node. Add the phi result.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
;=========================== begin_copyright_notice ============================
2+
;
3+
; Copyright (C) 2022 Intel Corporation
4+
;
5+
; SPDX-License-Identifier: MIT
6+
;
7+
;============================ end_copyright_notice =============================
8+
;
9+
; RUN: opt %use_old_pass_manager% -GenXEarlySimdCFConformance -march=genx64 -mtriple=spir64-unknown-unknown -mcpu=Gen9 -S < %s | FileCheck %s
10+
; ------------------------------------------------
11+
; GenXEarlySimdCFConformance
12+
; ------------------------------------------------
13+
14+
; CHECK: foo
15+
; CHECK-NOT: = tail call {.*}simdcf.goto
16+
define spir_kernel void @foo() {
17+
.afterjoin.i.i72:
18+
%goto.extractem145.i.i69 = extractvalue { <32 x i1>, <32 x i1>, i1 } zeroinitializer, 0
19+
br label %if.then5.i.vec32.i.i118
20+
21+
if.then5.i.vec32.i.i118: ; preds = %.afterjoin.i.i72
22+
%goto.i.i.i114 = tail call { <32 x i1>, <32 x i1>, i1 } @llvm.genx.simdcf.goto.v32i1.v32i1(<32 x i1> %goto.extractem145.i.i69, <32 x i1> zeroinitializer, <32 x i1> zeroinitializer)
23+
%goto.extractem.i.i.i115 = extractvalue { <32 x i1>, <32 x i1>, i1 } zeroinitializer, 0
24+
br label %if.end.thread.vec32.i.i.i131
25+
26+
if.end.thread.vec32.i.i.i131: ; preds = %if.then5.i.vec32.i.i118
27+
; Here select with 2 em-inputs - will be deoptimized
28+
%0 = select <32 x i1> %goto.extractem145.i.i69, <32 x i1> %goto.extractem145.i.i69, <32 x i1> zeroinitializer
29+
ret void
30+
}
31+
32+
declare { <32 x i1>, <32 x i1>, i1 } @llvm.genx.simdcf.goto.v32i1.v32i1(<32 x i1>, <32 x i1>, <32 x i1>)
33+
34+
attributes #0 = { nofree nosync nounwind readnone speculatable willreturn }

0 commit comments

Comments
 (0)