@@ -594,10 +594,9 @@ Value *VPInstruction::generate(VPTransformState &State) {
594594 return Builder.CreateCmp (CmpInst::Predicate::ICMP_ULT, VIVElem0, ScalarTC,
595595 Name);
596596
597- auto *Int1Ty = Type::getInt1Ty (Builder.getContext ());
598- auto PredTy = VectorType::get (
599- Int1Ty, State.VF * cast<ConstantInt>(getOperand (2 )->getLiveInIRValue ())
600- ->getZExtValue ());
597+ ElementCount EC = State.VF .multiplyCoefficientBy (
598+ cast<ConstantInt>(getOperand (2 )->getLiveInIRValue ())->getZExtValue ());
599+ auto *PredTy = VectorType::get (Builder.getInt1Ty (), EC);
601600 return Builder.CreateIntrinsic (Intrinsic::get_active_lane_mask,
602601 {PredTy, ScalarTC->getType ()},
603602 {VIVElem0, ScalarTC}, nullptr , Name);
@@ -627,7 +626,7 @@ Value *VPInstruction::generate(VPTransformState &State) {
627626 Value *Step = createStepForVF (Builder, ScalarTC->getType (), State.VF , UF);
628627 Value *Sub = Builder.CreateSub (ScalarTC, Step);
629628 Value *Cmp = Builder.CreateICmp (CmpInst::Predicate::ICMP_UGT, ScalarTC, Step);
630- Value *Zero = ConstantInt::get (ScalarTC->getType (), 0 );
629+ Value *Zero = ConstantInt::getNullValue (ScalarTC->getType ());
631630 return Builder.CreateSelect (Cmp, Sub, Zero);
632631 }
633632 case VPInstruction::ExplicitVectorLength: {
@@ -639,11 +638,11 @@ Value *VPInstruction::generate(VPTransformState &State) {
639638 " Requested vector length should be an integer." );
640639
641640 assert (State.VF .isScalable () && " Expected scalable vector factor." );
642- Value *VFArg = State. Builder .getInt32 (State.VF .getKnownMinValue ());
641+ Value *VFArg = Builder.getInt32 (State.VF .getKnownMinValue ());
643642
644- Value *EVL = State. Builder .CreateIntrinsic (
645- State. Builder .getInt32Ty (), Intrinsic::experimental_get_vector_length,
646- {AVL, VFArg, State. Builder .getTrue ()});
643+ Value *EVL = Builder.CreateIntrinsic (
644+ Builder.getInt32Ty (), Intrinsic::experimental_get_vector_length,
645+ {AVL, VFArg, Builder.getTrue ()});
647646 return EVL;
648647 }
649648 case VPInstruction::CanonicalIVIncrementForPart: {
@@ -697,8 +696,8 @@ Value *VPInstruction::generate(VPTransformState &State) {
697696 auto NumOfElements = ElementCount::getFixed (getNumOperands ());
698697 Value *Res = PoisonValue::get (toVectorizedTy (ScalarTy, NumOfElements));
699698 for (const auto &[Idx, Op] : enumerate(operands ()))
700- Res = State. Builder .CreateInsertElement (Res, State.get (Op, true ),
701- State. Builder .getInt32 (Idx));
699+ Res = Builder.CreateInsertElement (Res, State.get (Op, true ),
700+ Builder.getInt32 (Idx));
702701 return Res;
703702 }
704703 case VPInstruction::ReductionStartVector: {
@@ -711,9 +710,8 @@ Value *VPInstruction::generate(VPTransformState &State) {
711710 ElementCount VF = State.VF .divideCoefficientBy (
712711 cast<ConstantInt>(getOperand (2 )->getLiveInIRValue ())->getZExtValue ());
713712 auto *Iden = Builder.CreateVectorSplat (VF, State.get (getOperand (1 ), true ));
714- Constant *Zero = Builder.getInt32 (0 );
715713 return Builder.CreateInsertElement (Iden, State.get (getOperand (0 ), true ),
716- Zero );
714+ Builder. getInt32 ( 0 ) );
717715 }
718716 case VPInstruction::ComputeAnyOfResult: {
719717 // FIXME: The cross-recipe dependency on VPReductionPHIRecipe is temporary
@@ -790,14 +788,12 @@ Value *VPInstruction::generate(VPTransformState &State) {
790788 if (RecurrenceDescriptor::isMinMaxRecurrenceKind (RK))
791789 ReducedPartRdx = createMinMaxOp (Builder, RK, ReducedPartRdx, RdxPart);
792790 else {
793- Instruction::BinaryOps Opcode;
794791 // For sub-recurrences, each UF's reduction variable is already
795792 // negative, we need to do: reduce.add(-acc_uf0 + -acc_uf1)
796- if (RK == RecurKind::Sub)
797- Opcode = Instruction::Add;
798- else
799- Opcode =
800- (Instruction::BinaryOps)RecurrenceDescriptor::getOpcode (RK);
793+ Instruction::BinaryOps Opcode =
794+ RK == RecurKind::Sub
795+ ? Instruction::Add
796+ : (Instruction::BinaryOps)RecurrenceDescriptor::getOpcode (RK);
801797 ReducedPartRdx =
802798 Builder.CreateBinOp (Opcode, RdxPart, ReducedPartRdx, " bin.rdx" );
803799 }
@@ -862,7 +858,7 @@ Value *VPInstruction::generate(VPTransformState &State) {
862858 Value *LaneToExtract = State.get (getOperand (0 ), true );
863859 Type *IdxTy = State.TypeAnalysis .inferScalarType (getOperand (0 ));
864860 Value *Res = nullptr ;
865- Value *RuntimeVF = getRuntimeVF (State. Builder , IdxTy, State.VF );
861+ Value *RuntimeVF = getRuntimeVF (Builder, IdxTy, State.VF );
866862
867863 for (unsigned Idx = 1 ; Idx != getNumOperands (); ++Idx) {
868864 Value *VectorStart =
@@ -892,8 +888,7 @@ Value *VPInstruction::generate(VPTransformState &State) {
892888 // If there are multiple operands, create a chain of selects to pick the
893889 // first operand with an active lane and add the number of lanes of the
894890 // preceding operands.
895- Value *RuntimeVF =
896- getRuntimeVF (State.Builder , State.Builder .getInt64Ty (), State.VF );
891+ Value *RuntimeVF = getRuntimeVF (Builder, Builder.getInt64Ty (), State.VF );
897892 unsigned LastOpIdx = getNumOperands () - 1 ;
898893 Value *Res = nullptr ;
899894 for (int Idx = LastOpIdx; Idx >= 0 ; --Idx) {
0 commit comments