Skip to content

Commit f5bd985

Browse files
michalpaszkowskiigcbot
authored andcommitted
Revert "Revisit MismatchDetected for LowerGEPForPrivMem"
Reverts a previous change which created a regression on LLVM 16 + Opaque Pointers in the following test case: SYCL_CTS-math_builtin_float_double_1_ocl
1 parent 8e65535 commit f5bd985

File tree

3 files changed

+6
-35
lines changed

3 files changed

+6
-35
lines changed

IGC/Compiler/CISACodeGen/LowerGEPForPrivMem.cpp

Lines changed: 5 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
auto DL = I.getParent()->getParent()->getParent()->getDataLayout();
@@ -593,26 +590,15 @@ bool IGC::SOALayoutChecker::MismatchDetected(Instruction &I) {
593590
allocaTy = arrTy->getElementType();
594591
} else if (auto *vec = dyn_cast<IGCLLVM::FixedVectorType>(allocaTy)) {
595592
allocaTy = vec->getElementType();
596-
} else if (auto *strct = dyn_cast<StructType>(allocaTy)){
597-
if (auto *arrTy = dyn_cast<ArrayType>(strct->getStructElementType(0))) {
598-
allocaTy = arrTy->getElementType();
599-
} else if (auto *vec = dyn_cast<IGCLLVM::FixedVectorType>(strct->getStructElementType(0))){
600-
allocaTy = vec->getElementType();
601-
}
602593
}
603594

604595
if (auto *arrTy = dyn_cast<ArrayType>(pUserTy)) {
605596
pUserTy = arrTy->getElementType();
606597
} else if (auto *vec = dyn_cast<IGCLLVM::FixedVectorType>(pUserTy)) {
607598
pUserTy = vec->getElementType();
608-
} else if (auto *strct = dyn_cast<StructType>(pUserTy)){
609-
if (auto *arrTy = dyn_cast<ArrayType>(strct->getStructElementType(0))) {
610-
pUserTy = arrTy->getElementType();
611-
} else if (auto *vec = dyn_cast<IGCLLVM::FixedVectorType>(strct->getStructElementType(0))){
612-
pUserTy = vec->getElementType();
613-
}
614599
}
615600
}
601+
616602
auto allocaSize = DL.getTypeAllocSize(allocaTy);
617603
auto vecTySize = DL.getTypeAllocSize(pUserTy);
618604

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(const SOALayoutChecker &) = delete;
@@ -88,10 +88,6 @@ class SOALayoutChecker : public llvm::InstVisitor<SOALayoutChecker, bool> {
8888
const llvm::DataLayout *pDL;
8989
std::unique_ptr<SOALayoutInfo> pInfo;
9090

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

IGC/Compiler/tests/PrivateMemoryResolution/SOA_promotion/soa-mismatch-detection.ll

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
1818
target triple = "spir64-unknown-unknown"
1919

2020
%"struct.ispc::vec_t" = type { i32, i32, i32 }
21-
%g = type { [512 x i32] }
2221

2322
; Function Attrs: nofree nosync nounwind
2423
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) {
@@ -56,16 +55,6 @@ exit:
5655
store <4 x i32> zeroinitializer, ptr %offset.i.i.i.i, align 4
5756
%offset_gep = getelementptr i8, ptr %offset.i.i.i.i, i32 16
5857
store i32 0, ptr %offset_gep, align 4
59-
; This case is valid because float and i32 have 32 bits
60-
; CHECK: insertelement <2 x float> {{.*}}, float {{.*}}, i32 0
61-
; CHECK: insertelement <2 x float> {{.*}}, float {{.*}}, i32 1
62-
%st = alloca %g
63-
%load3 = load <2 x float>, ptr %st
64-
65-
; This case is not valid because i32 and i8 have different sizes
66-
; CHECK: %load4 = load <2 x i8>, ptr {{.*}}
67-
%st2 = alloca %g
68-
%load4 = load <2 x i8>, ptr %st2
6958

7059
ret void
7160
}

0 commit comments

Comments
 (0)