Skip to content

Commit b878de8

Browse files
krystian-andrzejewskigfxbot
authored andcommitted
Store3D doesn't allow to emit store wider than 128 bits. The LoadStorePointer pattern match doesn't consider the restrictions
Change-Id: Ic39b791812e41ff496a64f1d13b9c65300f9ed5e
1 parent 2d949e6 commit b878de8

File tree

1 file changed

+56
-48
lines changed

1 file changed

+56
-48
lines changed

IGC/Compiler/CISACodeGen/PatternMatchPass.cpp

Lines changed: 56 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void CodeGenPatternMatch::CodeGenNode( llvm::DomTreeNode* node )
9696
}
9797
llvm::BasicBlock* bb = node->getBlock();
9898
CodeGenBlock(bb);
99-
}
99+
}
100100

101101

102102
bool CodeGenPatternMatch::runOnFunction(llvm::Function &F)
@@ -108,7 +108,7 @@ bool CodeGenPatternMatch::runOnFunction(llvm::Function &F)
108108

109109
delete[] m_blocks;
110110
m_blocks = nullptr;
111-
111+
112112
m_ctx = getAnalysis<CodeGenContextWrapper>().getCodeGenContext();
113113

114114
MetaDataUtils *pMdUtils = getAnalysis<MetaDataUtilsWrapper>().getMetaDataUtils();
@@ -121,7 +121,7 @@ bool CodeGenPatternMatch::runOnFunction(llvm::Function &F)
121121
m_AllowContractions = true;
122122
if(m_ctx->m_DriverInfo.NeedCheckContractionAllowed())
123123
{
124-
m_AllowContractions =
124+
m_AllowContractions =
125125
modMD->compOpt.FastRelaxedMath ||
126126
modMD->compOpt.MadEnable;
127127
}
@@ -152,7 +152,7 @@ inline bool HasSideEffect(llvm::Instruction& inst)
152152

153153
inline bool HasPhiUse(llvm::Value& inst)
154154
{
155-
for (auto UI = inst.user_begin(), E = inst.user_end(); UI != E; ++UI)
155+
for (auto UI = inst.user_begin(), E = inst.user_end(); UI != E; ++UI)
156156
{
157157
llvm::User *U = *UI;
158158
if( llvm::isa<llvm::PHINode>(U))
@@ -725,7 +725,7 @@ CodeGenPatternMatch::isIntegerSatTrunc(llvm::SelectInst *SI) {
725725
// since src is a source of a trunc instruction, and dst
726726
// have the same width as its destination.
727727
return std::make_tuple(nullptr, false, false);
728-
}
728+
}
729729

730730
if (CI->getValue() != UMax && CI->getValue() != SMax)
731731
return std::make_tuple(nullptr, false, false);
@@ -836,7 +836,7 @@ void CodeGenPatternMatch::visitCastInst(llvm::CastInst &I)
836836
}
837837
else if (I.getOpcode() == Instruction::Trunc)
838838
{
839-
match =
839+
match =
840840
MatchModifier(I);
841841
}
842842
else
@@ -1004,12 +1004,12 @@ void CodeGenPatternMatch::visitBinaryOperator(llvm::BinaryOperator &I)
10041004
MatchModifier(I);
10051005
break;
10061006
case Instruction::And:
1007-
match =
1007+
match =
10081008
MatchBoolOp(I) ||
10091009
MatchLogicAlu(I);
10101010
break;
10111011
case Instruction::Or:
1012-
match =
1012+
match =
10131013
MatchBoolOp(I) ||
10141014
MatchLogicAlu(I);
10151015
break;
@@ -1026,7 +1026,7 @@ void CodeGenPatternMatch::visitBinaryOperator(llvm::BinaryOperator &I)
10261026

10271027
void CodeGenPatternMatch::visitCmpInst(llvm::CmpInst &I)
10281028
{
1029-
bool match = MatchCondModifier(I) ||
1029+
bool match = MatchCondModifier(I) ||
10301030
MatchModifier(I);
10311031
assert(match);
10321032
}
@@ -1109,7 +1109,7 @@ void CodeGenPatternMatch::visitCallInst(CallInst &I)
11091109
break;
11101110
case GenISAIntrinsic::GenISA_simdBlockRead:
11111111
case GenISAIntrinsic::GenISA_simdBlockWrite:
1112-
match = MatchBlockReadWritePointer(*CI) ||
1112+
match = MatchBlockReadWritePointer(*CI) ||
11131113
MatchSingleInstruction(*CI);
11141114
break;
11151115
default:
@@ -1203,7 +1203,7 @@ void CodeGenPatternMatch::visitIntrinsicInst(llvm::IntrinsicInst &I)
12031203
break;
12041204
}
12051205
assert(match && "no pattern found");
1206-
}
1206+
}
12071207

12081208
void CodeGenPatternMatch::visitStoreInst(StoreInst &I)
12091209
{
@@ -1556,7 +1556,7 @@ bool CodeGenPatternMatch::MatchFrc(llvm::BinaryOperator& I)
15561556
return found;
15571557
}
15581558

1559-
SSource CodeGenPatternMatch::GetSource(llvm::Value* value, bool modifier, bool regioning)
1559+
SSource CodeGenPatternMatch::GetSource(llvm::Value* value, bool modifier, bool regioning)
15601560
{
15611561
llvm::Value* sourceValue = value;
15621562
e_modifier mod = EMOD_NONE;
@@ -1645,7 +1645,7 @@ bool CodeGenPatternMatch::MatchMad( llvm::BinaryOperator& I )
16451645
pass->Mad(sources, modifier);
16461646
}
16471647
};
1648-
1648+
16491649
if (m_ctx->getModuleMetaData()->isPrecise)
16501650
{
16511651
return false;
@@ -1724,9 +1724,9 @@ bool CodeGenPatternMatch::MatchMad( llvm::BinaryOperator& I )
17241724
{
17251725
MadPattern *pattern = new (m_allocator) MadPattern();
17261726
for(int i=0; i<3; i++)
1727-
{
1727+
{
17281728
pattern->sources[i] = GetSource(sources[i], src_mod[i], false);
1729-
if (isa<Constant>(sources[i]) &&
1729+
if (isa<Constant>(sources[i]) &&
17301730
(!m_Platform.support16BitImmSrcForMad() ||
17311731
(sources[i]->getType()->getTypeID() != llvm::Type::HalfTyID) || i == 1))
17321732
{
@@ -1740,7 +1740,7 @@ bool CodeGenPatternMatch::MatchMad( llvm::BinaryOperator& I )
17401740
return found;
17411741
}
17421742

1743-
// match simdblockRead/Write with preceding inttoptr if possible
1743+
// match simdblockRead/Write with preceding inttoptr if possible
17441744
// to save a copy move
17451745
bool CodeGenPatternMatch::MatchBlockReadWritePointer(llvm::GenIntrinsicInst& I)
17461746
{
@@ -1818,6 +1818,14 @@ bool CodeGenPatternMatch::MatchLoadStorePointer(llvm::Instruction& I, llvm::Valu
18181818
{
18191819
return false;
18201820
}
1821+
1822+
// Store3d supports only types equal or less than 128 bits.
1823+
StoreInst* storeInst = dyn_cast<StoreInst>(&I);
1824+
if (storeInst && storeInst->getValueOperand()->getType()->getPrimitiveSizeInBits() > 128)
1825+
{
1826+
return false;
1827+
}
1828+
18211829
if (i2p || (ptr && ptr->getIntrinsicID() == GenISAIntrinsic::GenISA_OWordPtr))
18221830
{
18231831
LoadStorePointerPattern *pattern = new (m_allocator) LoadStorePointerPattern();
@@ -1996,9 +2004,9 @@ bool CodeGenPatternMatch::MatchLrp(llvm::BinaryOperator& I)
19962004

19972005
if (!found)
19982006
{
1999-
// match the case: dst = src2 - (src0 * src2) + (src0 * src1);
2000-
// match the case: dst = (src0 * src1) + src2 - (src0 * src2);
2001-
// match the case: dst = src2 + (src0 * src1) - (src0 * src2);
2007+
// match the case: dst = src2 - (src0 * src2) + (src0 * src1);
2008+
// match the case: dst = (src0 * src1) + src2 - (src0 * src2);
2009+
// match the case: dst = src2 + (src0 * src1) - (src0 * src2);
20022010
if (I.getOpcode() == Instruction::FAdd || I.getOpcode() == Instruction::FSub)
20032011
{
20042012
// dst = op[0] +/- op[1] +/- op[2]
@@ -2068,7 +2076,7 @@ bool CodeGenPatternMatch::MatchLrp(llvm::BinaryOperator& I)
20682076
// abort the cases marked as "skip" in the comment above
20692077
break;
20702078
}
2071-
2079+
20722080
sources[0] = op[i]->getOperand(srci);
20732081
sources[1] = op[k] == op[i]->getOperand(1 - srci) ? op[j]->getOperand(1 - srcj) : op[i]->getOperand(1 - srci);
20742082
sources[2] = op[k];
@@ -2141,20 +2149,20 @@ bool CodeGenPatternMatch::MatchCmpSext(llvm::Instruction& I)
21412149
pass->Cmp( inst->getPredicate(), sources, modifier );
21422150
}
21432151
};
2144-
bool match = false;
2152+
bool match = false;
21452153

21462154
if( CmpInst* cmpInst = dyn_cast<CmpInst>(I.getOperand(0)) )
21472155
{
21482156
if( cmpInst->getOperand(0)->getType()->getPrimitiveSizeInBits() == I.getType()->getPrimitiveSizeInBits() )
21492157
{
21502158
CmpSextPattern *pattern = new (m_allocator) CmpSextPattern();
21512159
bool supportModifer = SupportsModifier(cmpInst);
2152-
2160+
21532161
pattern->inst = cmpInst;
21542162
pattern->sources[0] = GetSource(cmpInst->getOperand(0), supportModifer, false);
21552163
pattern->sources[1] = GetSource(cmpInst->getOperand(1), supportModifer, false);
21562164
AddPattern(pattern);
2157-
match = true;
2165+
match = true;
21582166
}
21592167
}
21602168

@@ -2420,16 +2428,16 @@ bool CodeGenPatternMatch::BitcastSearch(SSource& source, llvm::Value*& value, bo
24202428
if (auto bTInst = dyn_cast<BitCastInst>(elemInst->getOperand(0)))
24212429
{
24222430
// Pattern Matching (Instruction) + ExtractElem + (Vector)Bitcast
2423-
//
2431+
//
24242432
// In order to set the regioning for the ALU operand
24252433
// I require three things:
24262434
// -The first is the source number of elements
24272435
// -The second is the destination number of elements
24282436
// -The third is the index from the extract element
2429-
//
2437+
//
24302438
// For example if I have <4 x i32> to <16 x i8> all I need is
2431-
// the 4 (vstride) and the i8 (b) in this case the operand would look
2432-
// like this -> r22.x <4;1,0>:b
2439+
// the 4 (vstride) and the i8 (b) in this case the operand would look
2440+
// like this -> r22.x <4;1,0>:b
24332441
// x is calculated below and later on using the simdsize
24342442

24352443
uint32_t index, srcNElts, dstNElts, nEltsRatio;
@@ -2466,7 +2474,7 @@ bool CodeGenPatternMatch::BitcastSearch(SSource& source, llvm::Value*& value, bo
24662474
}
24672475
return false;
24682476
}
2469-
2477+
24702478

24712479
bool CodeGenPatternMatch::MatchModifier(llvm::Instruction& I, bool SupportSrc0Mod)
24722480
{
@@ -2539,7 +2547,7 @@ bool CodeGenPatternMatch::MatchSingleInstruction(llvm::Instruction& I)
25392547
}
25402548
}
25412549
AddPattern(pattern);
2542-
return true;
2550+
return true;
25432551
}
25442552

25452553
bool CodeGenPatternMatch::MatchBranch(llvm::BranchInst& I)
@@ -2596,18 +2604,18 @@ bool CodeGenPatternMatch::MatchSatModifier(llvm::Instruction& I)
25962604
else
25972605
{
25982606
pass->Mov(source, mod);
2599-
}
2607+
}
26002608
}
26012609
};
2602-
bool match = false;
2610+
bool match = false;
26032611
llvm::Value* source = nullptr;
26042612
if(isSat(&I, source))
26052613
{
26062614
SatPattern *satPattern = new (m_allocator) SatPattern();
26072615
if(llvm::Instruction* inst = llvm::dyn_cast<Instruction>(source))
26082616
{
2609-
// As an heuristic we only match saturate if the instruction has one use
2610-
// to avoid duplicating expensive instructions and increasing reg pressure
2617+
// As an heuristic we only match saturate if the instruction has one use
2618+
// to avoid duplicating expensive instructions and increasing reg pressure
26112619
// without improve code quality this may be refined in the future
26122620
if(inst->hasOneUse() && SupportsSaturate(inst))
26132621
{
@@ -2772,7 +2780,7 @@ bool CodeGenPatternMatch::MatchPow(llvm::IntrinsicInst& I)
27722780
pass->Pow(sources, modifier);
27732781
}
27742782
};
2775-
bool found = false;
2783+
bool found = false;
27762784
llvm::Value* source0 = NULL;
27772785
llvm::Value* source1 = NULL;
27782786
if(I.getIntrinsicID() == Intrinsic::exp2)
@@ -2794,7 +2802,7 @@ bool CodeGenPatternMatch::MatchPow(llvm::IntrinsicInst& I)
27942802
}
27952803
}
27962804
}
2797-
}
2805+
}
27982806
}
27992807
if(found)
28002808
{
@@ -2889,7 +2897,7 @@ bool CodeGenPatternMatch::MatchBoolOp(llvm::BinaryOperator& I)
28892897
return found;
28902898
}
28912899

2892-
//
2900+
//
28932901
// Assume that V is of type T (integer) with N bits;
28942902
// and amt is of integer type too.
28952903
//
@@ -2917,7 +2925,7 @@ bool CodeGenPatternMatch::MatchBoolOp(llvm::BinaryOperator& I)
29172925
// ror can be handled similarly. Note that
29182926
// ror (x, amt) = ((unsigned)x >> amt) | ( x << (N - amt))
29192927
// = rol (x, N - amt);
2920-
//
2928+
//
29212929
bool CodeGenPatternMatch::MatchRotate(llvm::Instruction& I)
29222930
{
29232931
using namespace llvm::PatternMatch;
@@ -2967,7 +2975,7 @@ bool CodeGenPatternMatch::MatchRotate(llvm::Instruction& I)
29672975
{
29682976
assert(false && "Should be invoked with Or/Trunc instruction");
29692977
}
2970-
2978+
29712979
// Do rotate only if
29722980
// 1) type is W/DW (HW only supports W/DW); and
29732981
// 2) both operands are instructions.
@@ -3088,7 +3096,7 @@ bool CodeGenPatternMatch::MatchRotate(llvm::Instruction& I)
30883096
match(X1, m_And(m_Value(X2), m_SpecificInt(typeMask))) &&
30893097
(match(X2, m_Sub(m_SpecificInt(typeWidth), m_Value(X0))) ||
30903098
match(X2, m_Sub(m_Zero(), m_Value(X0)))));
3091-
3099+
30923100
if (isReverse)
30933101
{
30943102
Amt = X0;
@@ -3101,7 +3109,7 @@ bool CodeGenPatternMatch::MatchRotate(llvm::Instruction& I)
31013109
{
31023110
return false;
31033111
}
3104-
3112+
31053113
// Found the pattern.
31063114
RotatePattern *pattern = new (m_allocator) RotatePattern();
31073115
pattern->instruction = &I;
@@ -3246,7 +3254,7 @@ bool CodeGenPatternMatch::MatchDbgInstruction(llvm::DbgInfoIntrinsic& I)
32463254
assert(false && "Unhandled Dbg intrinsic");
32473255
}
32483256
AddPattern(pattern);
3249-
return true;
3257+
return true;
32503258
}
32513259

32523260
bool CodeGenPatternMatch::MatchAvg(llvm::Instruction& I)
@@ -3417,7 +3425,7 @@ bool CodeGenPatternMatch::MatchRegisterRegion(llvm::GenIntrinsicInst& I)
34173425
{
34183426
uint shiftFactor = int_cast<uint>(simDOffSetInst->getZExtValue());
34193427
//Check to make sure we dont end up with an invalid Vertical Stride.
3420-
//Only 1, 2, 4, 8, 16 are supported.
3428+
//Only 1, 2, 4, 8, 16 are supported.
34213429
if (shiftFactor <= 4)
34223430
{
34233431
verticalStride = (int)pow(2, shiftFactor);
@@ -3635,7 +3643,7 @@ bool isAbs(llvm::Value* abs, e_modifier& mod, llvm::Value*& source)
36353643
return true;
36363644
}
36373645
}
3638-
3646+
36393647
llvm::SelectInst* select = llvm::dyn_cast<llvm::SelectInst>(abs);
36403648
if (!select)
36413649
return false;
@@ -3656,7 +3664,7 @@ bool isAbs(llvm::Value* abs, e_modifier& mod, llvm::Value*& source)
36563664
{
36573665
if(cmpSource == select->getOperand(1+sourceIndex))
36583666
{
3659-
llvm::BinaryOperator* negate =
3667+
llvm::BinaryOperator* negate =
36603668
llvm::dyn_cast<llvm::BinaryOperator>(select->getOperand(1+(1-sourceIndex)));
36613669
llvm::Value* negateSource = NULL;
36623670
if(negate && IsNegate(*negate, negateSource) && negateSource == cmpSource)
@@ -3669,7 +3677,7 @@ bool isAbs(llvm::Value* abs, e_modifier& mod, llvm::Value*& source)
36693677
}
36703678
break;
36713679
}
3672-
}
3680+
}
36733681
break;
36743682
}
36753683
}
@@ -3904,7 +3912,7 @@ bool isSat(llvm::Instruction* sat, llvm::Value*& source)
39043912
found = true;
39053913
source = maxSources[1-j];
39063914
break;
3907-
}
3915+
}
39083916
}
39093917
}
39103918
break;
@@ -3927,7 +3935,7 @@ bool isSat(llvm::Instruction* sat, llvm::Value*& source)
39273935
found = true;
39283936
source = maxSources[1-j];
39293937
break;
3930-
}
3938+
}
39313939
}
39323940
}
39333941
break;
@@ -3941,7 +3949,7 @@ uint CodeGenPatternMatch::GetBlockId(llvm::BasicBlock* block)
39413949
{
39423950
auto it = m_blockMap.find(block);
39433951
assert(it!=m_blockMap.end());
3944-
3952+
39453953
uint blockID = it->second->id;
39463954
return blockID;
39473955
}

0 commit comments

Comments
 (0)