@@ -576,40 +576,37 @@ bool IGC::SOALayoutChecker::MismatchDetected(Instruction &I) {
576576 if (!allocaIsVecOrArr)
577577 return false ;
578578
579- bool useOldAlgorithm = ! useNewAlgo (pInfo-> baseType );
579+ auto DL = I. getParent ()-> getParent ()-> getParent ()-> getDataLayout ( );
580580
581- if (useOldAlgorithm) {
582- auto DL = I.getParent ()->getParent ()->getParent ()->getDataLayout ();
581+ Type *pUserTy = I.getType ();
583582
584- Type *pUserTy = I.getType ();
583+ if (auto *storeInst = dyn_cast<StoreInst>(&I))
584+ pUserTy = storeInst->getValueOperand ()->getType ();
585585
586- if (auto *storeInst = dyn_cast<StoreInst>(&I))
587- pUserTy = storeInst->getValueOperand ()->getType ();
588-
589- if (auto *pgep = dyn_cast<GetElementPtrInst>(parentLevelInst)) {
590- allocaTy = pgep->getResultElementType ();
591- } else {
592- if (auto *arrTy = dyn_cast<ArrayType>(allocaTy)) {
593- allocaTy = arrTy->getElementType ();
594- } else if (auto *vec = dyn_cast<IGCLLVM::FixedVectorType>(allocaTy)) {
595- allocaTy = vec->getElementType ();
596- }
586+ if (auto *pgep = dyn_cast<GetElementPtrInst>(parentLevelInst)) {
587+ allocaTy = pgep->getResultElementType ();
588+ } else {
589+ if (auto *arrTy = dyn_cast<ArrayType>(allocaTy)) {
590+ allocaTy = arrTy->getElementType ();
591+ } else if (auto *vec = dyn_cast<IGCLLVM::FixedVectorType>(allocaTy)) {
592+ allocaTy = vec->getElementType ();
593+ }
597594
598- if (auto *arrTy = dyn_cast<ArrayType>(pUserTy)) {
599- pUserTy = arrTy->getElementType ();
600- } else if (auto *vec = dyn_cast<IGCLLVM::FixedVectorType>(pUserTy)) {
601- pUserTy = vec->getElementType ();
602- }
595+ if (auto *arrTy = dyn_cast<ArrayType>(pUserTy)) {
596+ pUserTy = arrTy->getElementType ();
597+ } else if (auto *vec = dyn_cast<IGCLLVM::FixedVectorType>(pUserTy)) {
598+ pUserTy = vec->getElementType ();
603599 }
600+ }
604601
605- auto allocaSize = DL.getTypeAllocSize (allocaTy);
606- auto vecTySize = DL.getTypeAllocSize (pUserTy);
602+ auto allocaSize = DL.getTypeAllocSize (allocaTy);
603+ auto vecTySize = DL.getTypeAllocSize (pUserTy);
607604
608- if (vecTySize != allocaSize) {
609- pInfo->canUseSOALayout = false ;
610- return true ;
611- }
605+ if (vecTySize != allocaSize) {
606+ pInfo->canUseSOALayout = false ;
607+ return true ;
612608 }
609+
613610 return false ;
614611}
615612
0 commit comments