@@ -436,13 +436,15 @@ legalizeGetHighLowi64Bytes(Instruction &I,
436
436
}
437
437
438
438
if (auto *Extract = dyn_cast<ExtractElementInst>(&I)) {
439
+ if (!dyn_cast<BitCastInst>(Extract->getVectorOperand ()))
440
+ return ;
439
441
auto *VecTy = dyn_cast<FixedVectorType>(Extract->getVectorOperandType ());
440
442
if (VecTy && VecTy->getElementType ()->isIntegerTy (32 ) &&
441
443
VecTy->getNumElements () == 2 ) {
442
444
if (auto *Index = dyn_cast<ConstantInt>(Extract->getIndexOperand ())) {
443
445
unsigned Idx = Index->getZExtValue ();
444
446
IRBuilder<> Builder (&I);
445
- assert (dyn_cast<BitCastInst>(Extract-> getVectorOperand ()));
447
+
446
448
auto *Replacement = ReplacedValues[Extract->getVectorOperand ()];
447
449
assert (Replacement && " The BitCast replacement should have been set "
448
450
" before working on ExtractElementInst." );
@@ -509,6 +511,11 @@ class DXILLegalizationPipeline {
509
511
LegalizationPipeline[Stage1].push_back (legalizeMemCpy);
510
512
LegalizationPipeline[Stage1].push_back (removeMemSet);
511
513
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.
512
519
LegalizationPipeline[Stage2].push_back (
513
520
downcastI64toI32InsertExtractElements);
514
521
}
0 commit comments