Skip to content

Commit f7116fc

Browse files
committed
address pr feedback
1 parent 359af41 commit f7116fc

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

llvm/lib/Target/DirectX/DXILLegalizePass.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,13 +436,15 @@ legalizeGetHighLowi64Bytes(Instruction &I,
436436
}
437437

438438
if (auto *Extract = dyn_cast<ExtractElementInst>(&I)) {
439+
if (!dyn_cast<BitCastInst>(Extract->getVectorOperand()))
440+
return;
439441
auto *VecTy = dyn_cast<FixedVectorType>(Extract->getVectorOperandType());
440442
if (VecTy && VecTy->getElementType()->isIntegerTy(32) &&
441443
VecTy->getNumElements() == 2) {
442444
if (auto *Index = dyn_cast<ConstantInt>(Extract->getIndexOperand())) {
443445
unsigned Idx = Index->getZExtValue();
444446
IRBuilder<> Builder(&I);
445-
assert(dyn_cast<BitCastInst>(Extract->getVectorOperand()));
447+
446448
auto *Replacement = ReplacedValues[Extract->getVectorOperand()];
447449
assert(Replacement && "The BitCast replacement should have been set "
448450
"before working on ExtractElementInst.");
@@ -509,6 +511,11 @@ class DXILLegalizationPipeline {
509511
LegalizationPipeline[Stage1].push_back(legalizeMemCpy);
510512
LegalizationPipeline[Stage1].push_back(removeMemSet);
511513
LegalizationPipeline[Stage1].push_back(updateFnegToFsub);
514+
// Note: legalizeGetHighLowi64Bytes and
515+
// downcastI64toI32InsertExtractElements both modify extractelement, so they
516+
// must run staggered stages. legalizeGetHighLowi64Bytes runs first b\c it
517+
// removes extractelements, reducing the number that
518+
// downcastI64toI32InsertExtractElements needs to handle.
512519
LegalizationPipeline[Stage2].push_back(
513520
downcastI64toI32InsertExtractElements);
514521
}

0 commit comments

Comments
 (0)