Skip to content

Commit 5a47189

Browse files
sys-igcigcbot
authored andcommitted
[Autobackout][FunctionalRegression]Revert of change: 78fcf82: Revisit MismatchDetected for LowerGEPForPrivMem
MismatchDetected solved assert in the PrivateMemoryResolution pass caused by mismatched widths. LowerGEPForPrivMem solves that case but in case of alloca over the allowed size it will leave mismatched widths for the later PrivateMemoryResolution causing the assert to fail. Extended mismatch detection for cases with struct of array/struct of vector.
1 parent 7b02f68 commit 5a47189

File tree

3 files changed

+5
-38
lines changed

3 files changed

+5
-38
lines changed

IGC/Compiler/CISACodeGen/LowerGEPForPrivMem.cpp

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ StatusPrivArr2Reg LowerGEPForPrivMem::CheckIfAllocaPromotable(llvm::AllocaInst *
282282

283283
allowedAllocaSizeInBytes = (allowedAllocaSizeInBytes * 8) / SIMDSize;
284284
}
285-
SOALayoutChecker checker(*pAlloca, m_ctx->type == ShaderType::OPENCL_SHADER, true);
285+
SOALayoutChecker checker(*pAlloca, m_ctx->type == ShaderType::OPENCL_SHADER);
286286
SOALayoutInfo SOAInfo = checker.getOrGatherInfo();
287287
if (!SOAInfo.canUseSOALayout) {
288288
return StatusPrivArr2Reg::CannotUseSOALayout;
@@ -357,7 +357,7 @@ StatusPrivArr2Reg LowerGEPForPrivMem::CheckIfAllocaPromotable(llvm::AllocaInst *
357357
return StatusPrivArr2Reg::OK;
358358
}
359359

360-
SOALayoutChecker::SOALayoutChecker(AllocaInst &allocaToCheck, bool isOCL, bool mismatchedWidthsSupport) : allocaRef(allocaToCheck), mismatchedWidthsSupport(mismatchedWidthsSupport) {
360+
SOALayoutChecker::SOALayoutChecker(AllocaInst &allocaToCheck, bool isOCL) : allocaRef(allocaToCheck) {
361361
auto F = allocaToCheck.getParent()->getParent();
362362
pDL = &F->getParent()->getDataLayout();
363363
newAlgoControl = IGC_GET_FLAG_VALUE(EnablePrivMemNewSOATranspose);
@@ -571,12 +571,9 @@ bool IGC::SOALayoutChecker::MismatchDetected(Instruction &I) {
571571
return false;
572572

573573
Type *allocaTy = allocaRef.getAllocatedType();
574-
bool allocaIsVecOrArrOrStruct = allocaTy->isVectorTy() || allocaTy->isArrayTy() || allocaTy->isStructTy();
574+
bool allocaIsVecOrArr = allocaTy->isVectorTy() || allocaTy->isArrayTy();
575575

576-
if (!allocaIsVecOrArrOrStruct)
577-
return false;
578-
579-
if(mismatchedWidthsSupport)
576+
if (!allocaIsVecOrArr)
580577
return false;
581578

582579
bool useOldAlgorithm = !useNewAlgo(pInfo->baseType);
@@ -596,24 +593,12 @@ bool IGC::SOALayoutChecker::MismatchDetected(Instruction &I) {
596593
allocaTy = arrTy->getElementType();
597594
} else if (auto *vec = dyn_cast<IGCLLVM::FixedVectorType>(allocaTy)) {
598595
allocaTy = vec->getElementType();
599-
} else if (auto *strct = dyn_cast<StructType>(allocaTy)){
600-
if (auto *arrTy = dyn_cast<ArrayType>(strct->getStructElementType(0))) {
601-
allocaTy = arrTy->getElementType();
602-
} else if (auto *vec = dyn_cast<IGCLLVM::FixedVectorType>(strct->getStructElementType(0))){
603-
allocaTy = vec->getElementType();
604-
}
605596
}
606597

607598
if (auto *arrTy = dyn_cast<ArrayType>(pUserTy)) {
608599
pUserTy = arrTy->getElementType();
609600
} else if (auto *vec = dyn_cast<IGCLLVM::FixedVectorType>(pUserTy)) {
610601
pUserTy = vec->getElementType();
611-
} else if (auto *strct = dyn_cast<StructType>(pUserTy)){
612-
if (auto *arrTy = dyn_cast<ArrayType>(strct->getStructElementType(0))) {
613-
pUserTy = arrTy->getElementType();
614-
} else if (auto *vec = dyn_cast<IGCLLVM::FixedVectorType>(strct->getStructElementType(0))){
615-
pUserTy = vec->getElementType();
616-
}
617602
}
618603
}
619604

IGC/Compiler/CISACodeGen/LowerGEPForPrivMem.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class SOALayoutChecker : public llvm::InstVisitor<SOALayoutChecker, bool> {
7070
friend llvm::InstVisitor<SOALayoutChecker, bool>;
7171

7272
// isOCL is for testing, it will be removed once testing is done.
73-
SOALayoutChecker(llvm::AllocaInst &allocaToCheck, bool isOCL, bool mismatchedWidthsSupport=false);
73+
SOALayoutChecker(llvm::AllocaInst &allocaToCheck, bool isOCL);
7474
SOALayoutChecker() = delete;
7575
~SOALayoutChecker() = default;
7676
SOALayoutChecker(SOALayoutChecker &) = delete;
@@ -87,10 +87,6 @@ class SOALayoutChecker : public llvm::InstVisitor<SOALayoutChecker, bool> {
8787
const llvm::DataLayout *pDL;
8888
std::unique_ptr<SOALayoutInfo> pInfo;
8989

90-
// If mismatched widths reach PrivateMemoryResolution, it should turn off optimization
91-
// But if they reach LowerGEPForPrivMemPass they get resolved properly
92-
bool mismatchedWidthsSupport;
93-
9490
// ===== fields for new algo =====
9591
// todo: combine the new and old together
9692
//

IGC/Compiler/tests/PrivateMemoryResolution/SOA_promotion/soa-nested-load.ll

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-n8:16:32"
1919
target triple = "spir64-unknown-unknown"
2020

21-
%g = type { [512 x i32] }
22-
2321
; Function Attrs: nofree nosync nounwind
2422
define spir_kernel void @test(ptr nocapture writeonly %d, <8 x i32> %r0, <8 x i32> %payloadHeader, <3 x i32> %enqueuedLocalSize, i16 %localIdX, i16 %localIdY, i16 %localIdZ, ptr nocapture readnone %privateBase) {
2523
entry:
@@ -45,18 +43,6 @@ exit:
4543
; CHECK: %load2 = load i8, ptr %arr3
4644
%arr3 = alloca [512 x i32]
4745
%load2 = load i8, ptr %arr3
48-
49-
; This case is valid because float and i32 have 32 bits
50-
; CHECK: insertelement <2 x float> {{.*}}, float {{.*}}, i32 0
51-
; CHECK: insertelement <2 x float> {{.*}}, float {{.*}}, i32 1
52-
%st = alloca %g
53-
%load3 = load <2 x float>, ptr %st
54-
55-
; This case is not valid because i32 and i8 have different sizes
56-
; CHECK: %load4 = load <2 x i8>, ptr %st2
57-
%st2 = alloca %g
58-
%load4 = load <2 x i8>, ptr %st2
59-
6046
ret void
6147
}
6248

0 commit comments

Comments
 (0)