@@ -26,13 +26,11 @@ SPDX-License-Identifier: MIT
26
26
#include < stack>
27
27
#include < sstream>
28
28
#include " Probe/Assertion.h"
29
- #include < llvmWrapper/IR/PatternMatch.h>
30
29
31
30
using namespace llvm ;
32
31
using namespace IGC ;
33
32
using namespace IGC ::IGCMD;
34
33
using namespace IGC ::Debug;
35
- using namespace llvm ::PatternMatch;
36
34
37
35
static cl::opt<bool > PrintWiaCheck (
38
36
" print-wia-check" , cl::init(false ), cl::Hidden,
@@ -1257,134 +1255,6 @@ WIAnalysis::WIDependancy WIAnalysisRunner::calculate_dep(const LoadInst* inst)
1257
1255
return calculate_dep_simple (inst);
1258
1256
}
1259
1257
1260
- // This functions checks if result of inst is sub_group_id value.
1261
- // In other words, it checks the following pattern:
1262
- //
1263
- // %localSizeX = extractelement <3 x i32> %localSize, i32 0
1264
- // %localSizeY = extractelement <3 x i32> %localSize, i32 1
1265
- // %localIdZZext = zext i16 %localIdZ to i32
1266
- // %mul1 = mul i32 %localSizeY, %localIdZzext
1267
- // %localIdYZext = zext i16 %localIdY to i32
1268
- // %add1 = add i32 %mul1, %localIdYZext
1269
- // %mul2 = mul i32 %add1, %localSizeX
1270
- // %add2 = add i32 %mul2, %localIdX4
1271
- // %simdSize = call i32 @llvm.genx.GenISA.simdSize()
1272
- //
1273
- // pattern 1:
1274
- // %lshr1 = lshr i32 %simdSize, 4
1275
- // %lshr2 = lshr i32 %add2, 3
1276
- // %sgid = lshr i32 %lshr2, %lshr1
1277
- //
1278
- // or
1279
- //
1280
- // pattern 2:
1281
- // %sgid = udiv i32 %add2, %simdSize
1282
- //
1283
- // This pattern matching can be removed, when get_subgroup_id call is inlined after applying the WIAnalysis.
1284
- bool WIAnalysisRunner::check_sg_id (const Instruction* inst)
1285
- {
1286
- const Value *val = cast<Value>(inst);
1287
- Value *lshrInst1 = nullptr ;
1288
- Value *lshrInst2 = nullptr ;
1289
- Value *addInst1 = nullptr ;
1290
- Value *addInst2 = nullptr ;
1291
- Value *callVal1 = nullptr ;
1292
- Value *extrVal1 = nullptr ;
1293
- Value *extrVal2 = nullptr ;
1294
- Value *mulInst1 = nullptr ;
1295
- Value *mulInst2 = nullptr ;
1296
- Value *localIdX = nullptr ;
1297
- Value *localIdY = nullptr ;
1298
- Value *localIdZ = nullptr ;
1299
-
1300
- FunctionInfoMetaDataHandle funcInfoMD = m_pMdUtils->getFunctionsInfoItem (m_func);
1301
- SubGroupSizeMetaDataHandle subGroupSize = funcInfoMD->getSubGroupSize ();
1302
- // If subGroupSize is not set in the metadata, then we need to check the pattern with llvm.genx.GenISA.simdSize call.
1303
- if (subGroupSize->hasValue ())
1304
- {
1305
- uint32_t simdSize = (uint32_t )subGroupSize->getSIMDSize ();
1306
- IGC_ASSERT (simdSize == 8 || simdSize == 16 || simdSize == 32 );
1307
- uint32_t power = 0 ;
1308
- if (simdSize == 32 )
1309
- {
1310
- power = 5 ;
1311
- }
1312
- else if (simdSize == 16 )
1313
- {
1314
- power = 4 ;
1315
- }
1316
- else
1317
- {
1318
- power = 3 ;
1319
- }
1320
-
1321
- auto lshrPat1 = m_LShr (m_Value (addInst1), m_SpecificInt (power));
1322
- if (!match (val, lshrPat1))
1323
- return false ;
1324
- }
1325
- else
1326
- {
1327
- auto lshrPat1 = m_LShr (m_Value (lshrInst1), m_Value (lshrInst2));
1328
-
1329
- // Check pattern 1.
1330
- if (match (val, lshrPat1))
1331
- {
1332
- auto lshrPat2 = m_LShr (m_Value (addInst1), m_SpecificInt (3 ));
1333
- auto lshrPat3 = m_LShr (m_Value (callVal1), m_SpecificInt (4 ));
1334
-
1335
- match (lshrInst1, lshrPat2);
1336
- match (lshrInst2, lshrPat3);
1337
- }
1338
-
1339
- // If pattern 1 was not found, check pattern 2.
1340
- if (!callVal1 || !addInst1)
1341
- {
1342
- auto udivPat1 = m_UDiv (m_Value (addInst1), m_Value (callVal1));
1343
- if (!match (val, udivPat1))
1344
- return false ;
1345
- }
1346
-
1347
- GenIntrinsicInst *genInst = dyn_cast<GenIntrinsicInst>(callVal1);
1348
- if (!genInst || (genInst->getIntrinsicID () != GenISAIntrinsic::GenISA_simdSize))
1349
- return false ;
1350
- }
1351
-
1352
- auto addPat11 = m_Add (m_Value (mulInst1), m_ZExt (m_Value (localIdX)));
1353
- auto addPat12 = m_Add (m_ZExt (m_Value (localIdX)), m_Value (mulInst1));
1354
- if (!match (addInst1, addPat11) && !match (addInst1, addPat12))
1355
- return false ;
1356
-
1357
- auto mulPat11 = m_Mul (m_ExtractElt (m_Value (extrVal1), m_SpecificInt (0 )), m_Value (addInst2));
1358
- auto mulPat12 = m_Mul (m_Value (addInst2), m_ExtractElt (m_Value (extrVal1), m_SpecificInt (0 )));
1359
- if (!match (mulInst1, mulPat11) && !match (mulInst1, mulPat12))
1360
- return false ;
1361
-
1362
- auto addPat21 = m_Add (m_Value (mulInst2), m_ZExt (m_Value (localIdY)));
1363
- auto addPat22 = m_Add (m_ZExt (m_Value (localIdY)), m_Value (mulInst2));
1364
- if (!match (addInst2, addPat21) && !match (addInst2, addPat22))
1365
- return false ;
1366
-
1367
- auto mulPat21 = m_Mul (m_ExtractElt (m_Value (extrVal2), m_SpecificInt (1 )), m_ZExt (m_Value (localIdZ)));
1368
- auto mulPat22 = m_Mul (m_ZExt (m_Value (localIdZ)), m_ExtractElt (m_Value (extrVal2), m_SpecificInt (1 )));
1369
- if (!match (mulInst2, mulPat21) && !match (mulInst2, mulPat22))
1370
- return false ;
1371
-
1372
- ImplicitArgs implicitArgs (*m_func, m_pMdUtils);
1373
- Value *argX = implicitArgs.getImplicitArgValue (*m_func, ImplicitArg::LOCAL_ID_X, m_pMdUtils);
1374
- Value *argY = implicitArgs.getImplicitArgValue (*m_func, ImplicitArg::LOCAL_ID_Y, m_pMdUtils);
1375
- Value *argZ = implicitArgs.getImplicitArgValue (*m_func, ImplicitArg::LOCAL_ID_Z, m_pMdUtils);
1376
- Value *localSize = implicitArgs.getImplicitArgValue (*m_func, ImplicitArg::LOCAL_SIZE, m_pMdUtils);
1377
- Value *enqLocalSize = implicitArgs.getImplicitArgValue (*m_func, ImplicitArg::ENQUEUED_LOCAL_WORK_SIZE, m_pMdUtils);
1378
-
1379
- if ((localIdX != argX) || (localIdY != argY) || (localIdZ != argZ))
1380
- return false ;
1381
-
1382
- if ((localSize != extrVal1) && (enqLocalSize != extrVal1) || (localSize != extrVal2) && (enqLocalSize != extrVal2))
1383
- return false ;
1384
-
1385
- return true ;
1386
- }
1387
-
1388
1258
WIAnalysis::WIDependancy WIAnalysisRunner::calculate_dep (
1389
1259
const BinaryOperator* inst)
1390
1260
{
@@ -1397,11 +1267,6 @@ WIAnalysis::WIDependancy WIAnalysisRunner::calculate_dep(
1397
1267
WIAnalysis::WIDependancy dep1 = getDependency (op1);
1398
1268
IGC_ASSERT (dep1 < WIAnalysis::NumDeps);
1399
1269
1400
- if (check_sg_id (inst))
1401
- {
1402
- return WIAnalysis::UNIFORM_THREAD;
1403
- }
1404
-
1405
1270
// For whatever binary operation,
1406
1271
// uniform returns uniform
1407
1272
WIAnalysis::WIDependancy dep = select_conversion[dep0][dep1];
0 commit comments