@@ -527,13 +527,15 @@ legalizeGetHighLowi64Bytes(Instruction &I,
527
527
}
528
528
529
529
if (auto *Extract = dyn_cast<ExtractElementInst>(&I)) {
530
+ if (!dyn_cast<BitCastInst>(Extract->getVectorOperand ()))
531
+ return ;
530
532
auto *VecTy = dyn_cast<FixedVectorType>(Extract->getVectorOperandType ());
531
533
if (VecTy && VecTy->getElementType ()->isIntegerTy (32 ) &&
532
534
VecTy->getNumElements () == 2 ) {
533
535
if (auto *Index = dyn_cast<ConstantInt>(Extract->getIndexOperand ())) {
534
536
unsigned Idx = Index->getZExtValue ();
535
537
IRBuilder<> Builder (&I);
536
- assert (dyn_cast<BitCastInst>(Extract-> getVectorOperand ()));
538
+
537
539
auto *Replacement = ReplacedValues[Extract->getVectorOperand ()];
538
540
assert (Replacement && " The BitCast replacement should have been set "
539
541
" before working on ExtractElementInst." );
@@ -600,6 +602,11 @@ class DXILLegalizationPipeline {
600
602
LegalizationPipeline[Stage1].push_back (legalizeMemCpy);
601
603
LegalizationPipeline[Stage1].push_back (removeMemSet);
602
604
LegalizationPipeline[Stage1].push_back (updateFnegToFsub);
605
+ // Note: legalizeGetHighLowi64Bytes and
606
+ // downcastI64toI32InsertExtractElements both modify extractelement, so they
607
+ // must run staggered stages. legalizeGetHighLowi64Bytes runs first b\c it
608
+ // removes extractelements, reducing the number that
609
+ // downcastI64toI32InsertExtractElements needs to handle.
603
610
LegalizationPipeline[Stage2].push_back (
604
611
downcastI64toI32InsertExtractElements);
605
612
}
0 commit comments