@@ -7623,53 +7623,72 @@ bool CombinerHelper::matchUnmergeValuesAnyExtBuildVector(const MachineInstr &MI,
7623
7623
7624
7624
LLT DstTy = MRI.getType (Unmerge->getReg (0 ));
7625
7625
7626
+ // $bv:_((<8 x s8>) = G_BUILD_VECTOR ....
7627
+ // $anyext:_(<8 x s16>) = G_ANYEXT $bv
7628
+ // $uv:_(<4 x s16>), $uv1:_(<4 x s16>) = G_UNMERGE_VALUES $any
7629
+ //
7630
+ // ->
7631
+ //
7632
+ // $any:_(s16) = G_ANY $bv[0]
7633
+ // $any1:_(s16) = G_ANY bv[1]
7634
+ // $any2:_(s16) = G_ANY bv[2]
7635
+ // $any3:_(s16) = G_ANY bv[3]
7636
+ // $any4:_(s16) = G_ANY $bv[4]
7637
+ // $any5:_(s16) = G_ANY $bv[5]
7638
+ // $any6:_(s16) = G_ANY $bv[6]
7639
+ // $any7:_(s16) = G_ANY $bv[7]
7640
+ // $uv:_(<4 x s16>) = G_BUILD_VECTOR $any, $any1, $any2, $any3
7641
+ // $uv1:_(<4 x s16>) = G_BUILD_VECTOR $any4, $any5, $any6, $any7
7642
+
7626
7643
// We want to unmerge into vectors.
7627
7644
if (!DstTy.isFixedVector ())
7628
7645
return false ;
7629
7646
7630
- if (const GAnyExt *Any = dyn_cast<GAnyExt>(Source)) {
7631
- const MachineInstr *NextSource = MRI.getVRegDef (Any->getSrcReg ());
7647
+ const GAnyExt *Any = dyn_cast<GAnyExt>(Source);
7648
+ if (!Any)
7649
+ return false ;
7632
7650
7633
- if (const GBuildVector *BV = dyn_cast<GBuildVector>(NextSource)) {
7634
- // G_UNMERGE_VALUES G_ANYEXT G_BUILD_VECTOR
7651
+ const MachineInstr *NextSource = MRI.getVRegDef (Any->getSrcReg ());
7635
7652
7636
- if (!MRI. hasOneNonDBGUse (BV-> getReg ( 0 )))
7637
- return false ;
7653
+ if ( const GBuildVector *BV = dyn_cast<GBuildVector>(NextSource)) {
7654
+ // G_UNMERGE_VALUES G_ANYEXT G_BUILD_VECTOR
7638
7655
7639
- // FIXME: check element types?
7640
- if (BV->getNumSources () % Unmerge->getNumDefs () != 0 )
7641
- return false ;
7656
+ if (!MRI.hasOneNonDBGUse (BV->getReg (0 )))
7657
+ return false ;
7642
7658
7643
- LLT BigBvTy = MRI. getType (BV-> getReg ( 0 ));
7644
- LLT SmallBvTy = DstTy;
7645
- LLT SmallBvElemenTy = SmallBvTy. getElementType () ;
7659
+ // FIXME: check element types?
7660
+ if (BV-> getNumSources () % Unmerge-> getNumDefs () != 0 )
7661
+ return false ;
7646
7662
7647
- if (! isLegalOrBeforeLegalizer (
7648
- {TargetOpcode::G_BUILD_VECTOR, { SmallBvTy, SmallBvElemenTy}}))
7649
- return false ;
7663
+ LLT BigBvTy = MRI. getType (BV-> getReg ( 0 ));
7664
+ LLT SmallBvTy = DstTy;
7665
+ LLT SmallBvElemenTy = SmallBvTy. getElementType () ;
7650
7666
7651
- // We check the legality of scalar anyext.
7652
- if (!isLegalOrBeforeLegalizer (
7653
- {TargetOpcode::G_ANYEXT,
7654
- {SmallBvElemenTy, BigBvTy.getElementType ()}}))
7655
- return false ;
7667
+ if (!isLegalOrBeforeLegalizer (
7668
+ {TargetOpcode::G_BUILD_VECTOR, {SmallBvTy, SmallBvElemenTy}}))
7669
+ return false ;
7656
7670
7657
- MatchInfo = [=](MachineIRBuilder &B) {
7658
- // Build into each G_UNMERGE_VALUES def
7659
- // a small build vector with anyext from the source build vector.
7660
- for (unsigned I = 0 ; I < Unmerge->getNumDefs (); ++I) {
7661
- SmallVector<Register> Ops;
7662
- for (unsigned J = 0 ; J < SmallBvTy.getNumElements (); ++J) {
7663
- Register SourceArray =
7664
- BV->getSourceReg (I * SmallBvTy.getNumElements () + J);
7665
- auto AnyExt = B.buildAnyExt (SmallBvElemenTy, SourceArray);
7666
- Ops.push_back (AnyExt.getReg (0 ));
7667
- }
7668
- B.buildBuildVector (Unmerge->getOperand (I).getReg (), Ops);
7669
- };
7671
+ // We check the legality of scalar anyext.
7672
+ if (!isLegalOrBeforeLegalizer (
7673
+ {TargetOpcode::G_ANYEXT,
7674
+ {SmallBvElemenTy, BigBvTy.getElementType ()}}))
7675
+ return false ;
7676
+
7677
+ MatchInfo = [=](MachineIRBuilder &B) {
7678
+ // Build into each G_UNMERGE_VALUES def
7679
+ // a small build vector with anyext from the source build vector.
7680
+ for (unsigned I = 0 ; I < Unmerge->getNumDefs (); ++I) {
7681
+ SmallVector<Register> Ops;
7682
+ for (unsigned J = 0 ; J < SmallBvTy.getNumElements (); ++J) {
7683
+ Register SourceArray =
7684
+ BV->getSourceReg (I * SmallBvTy.getNumElements () + J);
7685
+ auto AnyExt = B.buildAnyExt (SmallBvElemenTy, SourceArray);
7686
+ Ops.push_back (AnyExt.getReg (0 ));
7687
+ }
7688
+ B.buildBuildVector (Unmerge->getOperand (I).getReg (), Ops);
7670
7689
};
7671
- return true ;
7672
7690
};
7691
+ return true ;
7673
7692
};
7674
7693
7675
7694
return false ;
0 commit comments