Skip to content

Commit 60b92e1

Browse files
sys-igcigcbot
authored andcommitted
[Autobackout][FunctionalRegression]Revert of change: 8ca8577: Fix legalizePhiInstruction for vector types
Build extra bitcast before zext instruction for correct vector types legalization
1 parent 8ca8577 commit 60b92e1

File tree

2 files changed

+7
-65
lines changed

2 files changed

+7
-65
lines changed

IGC/Compiler/Legalizer/PeepholeTypeLegalizer.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -192,34 +192,32 @@ void PeepholeTypeLegalizer::legalizePhiInstruction(Instruction &I) {
192192
if (!I.getType()->isIntOrIntVectorTy() || isLegalInteger(srcWidth) || srcWidth == 1) // nothing to legalize
193193
return;
194194

195-
unsigned numElements =
196-
I.getType()->isVectorTy() ? (unsigned)cast<IGCLLVM::FixedVectorType>(I.getType())->getNumElements() : 1;
197195
unsigned quotient = 0, promoteToInt = 0;
198-
promoteInt(srcWidth * numElements, quotient, promoteToInt, DL->getLargestLegalIntTypeSizeInBits());
196+
promoteInt(srcWidth, quotient, promoteToInt, DL->getLargestLegalIntTypeSizeInBits());
199197

200198
PHINode *oldPhi = cast<PHINode>(&I);
201199
Value *result = nullptr;
202200

203201
if (quotient > 1) {
204-
Type *newVecType = IGCLLVM::FixedVectorType::get(Type::getIntNTy(I.getContext(), promoteToInt), quotient);
202+
unsigned numElements =
203+
I.getType()->isVectorTy() ? (unsigned)cast<IGCLLVM::FixedVectorType>(I.getType())->getNumElements() : 1;
204+
Type *newVecType =
205+
IGCLLVM::FixedVectorType::get(Type::getIntNTy(I.getContext(), promoteToInt), quotient * numElements);
205206
Type *newLargeIntType = Type::getIntNTy(I.getContext(), promoteToInt * quotient);
206-
Type *newOrigIntType = Type::getIntNTy(I.getContext(), srcWidth * numElements);
207207

208208
PHINode *newPhi = m_builder->CreatePHI(newVecType, oldPhi->getNumIncomingValues());
209209
for (unsigned i = 0; i < oldPhi->getNumIncomingValues(); i++) {
210210
Value *incomingValue = oldPhi->getIncomingValue(i);
211211

212212
m_builder->SetInsertPoint(oldPhi->getIncomingBlock(i)->getTerminator());
213-
Value *newOrigValue = m_builder->CreateBitCast(incomingValue, newOrigIntType);
214-
Value *newLargeIntValue = m_builder->CreateZExt(newOrigValue, newLargeIntType);
213+
Value *newLargeIntValue = m_builder->CreateZExt(incomingValue, newLargeIntType);
215214
Value *newVecValue = m_builder->CreateBitCast(newLargeIntValue, newVecType);
216215
newPhi->addIncoming(newVecValue, oldPhi->getIncomingBlock(i));
217216
}
218217
// Cast back to original type
219218
m_builder->SetInsertPoint(newPhi->getParent()->getFirstNonPHI());
220219
Value *NewLargeIntPhi = m_builder->CreateBitCast(newPhi, newLargeIntType);
221-
Value *NewOrigIntPhi = m_builder->CreateTrunc(NewLargeIntPhi, newOrigIntType);
222-
result = m_builder->CreateBitCast(NewOrigIntPhi, oldPhi->getType());
220+
result = m_builder->CreateTrunc(NewLargeIntPhi, oldPhi->getType());
223221
} else {
224222
// quotient == 1 (integer promotion)
225223
Type *newType = Type::getIntNTy(I.getContext(), promoteToInt);

IGC/Compiler/tests/PeepholeTypeLegalizer/phi_legalize.ll

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)