@@ -144,6 +144,7 @@ bool VPRecipeBase::mayHaveSideEffects() const {
144
144
case VPInstruction::FirstOrderRecurrenceSplice:
145
145
case VPInstruction::LogicalAnd:
146
146
case VPInstruction::PtrAdd:
147
+ case VPInstruction::MergeUntilPivot:
147
148
return false ;
148
149
default :
149
150
return true ;
@@ -673,7 +674,18 @@ Value *VPInstruction::generatePerPart(VPTransformState &State, unsigned Part) {
673
674
}
674
675
return NewPhi;
675
676
}
677
+ case VPInstruction::MergeUntilPivot: {
678
+ assert (Part == 0 && " No unrolling expected for predicated vectorization." );
679
+ Value *Cond = State.get (getOperand (0 ), Part);
680
+ Value *OnTrue = State.get (getOperand (1 ), Part);
681
+ Value *OnFalse = State.get (getOperand (2 ), Part);
682
+ Value *Pivot = State.get (getOperand (3 ), VPIteration (0 , 0 ));
683
+ assert (Pivot->getType ()->isIntegerTy () && " Pivot should be an integer." );
676
684
685
+ return Builder.CreateIntrinsic (Intrinsic::vp_merge, {OnTrue->getType ()},
686
+ {Cond, OnTrue, OnFalse, Pivot}, nullptr ,
687
+ Name);
688
+ }
677
689
default :
678
690
llvm_unreachable (" Unsupported opcode for instruction" );
679
691
}
@@ -764,6 +776,9 @@ bool VPInstruction::onlyFirstLaneUsed(const VPValue *Op) const {
764
776
case VPInstruction::BranchOnCond:
765
777
case VPInstruction::ResumePhi:
766
778
return true ;
779
+ case VPInstruction::MergeUntilPivot:
780
+ // Pivot must be an integer.
781
+ return Op == getOperand (3 );
767
782
};
768
783
llvm_unreachable (" switch should return" );
769
784
}
@@ -782,6 +797,7 @@ bool VPInstruction::onlyFirstPartUsed(const VPValue *Op) const {
782
797
case VPInstruction::BranchOnCount:
783
798
case VPInstruction::BranchOnCond:
784
799
case VPInstruction::CanonicalIVIncrementForPart:
800
+ case VPInstruction::MergeUntilPivot:
785
801
return true ;
786
802
};
787
803
llvm_unreachable (" switch should return" );
@@ -848,6 +864,9 @@ void VPInstruction::print(raw_ostream &O, const Twine &Indent,
848
864
case VPInstruction::PtrAdd:
849
865
O << " ptradd" ;
850
866
break ;
867
+ case VPInstruction::MergeUntilPivot:
868
+ O << " merge-until-pivot" ;
869
+ break ;
851
870
default :
852
871
O << Instruction::getOpcodeName (getOpcode ());
853
872
}
0 commit comments