@@ -1455,10 +1455,9 @@ InstructionCost VPWidenRecipe::computeCost(ElementCount VF,
14551455
14561456void VPWidenEVLRecipe::execute (VPTransformState &State) {
14571457 unsigned Opcode = getOpcode ();
1458- // TODO: Support other opcodes
14591458 if (Opcode == Instruction::ICmp || Opcode == Instruction::FCmp) {
1460- Value *Op1 = State.get (getOperand (0 ), 0 );
1461- Value *Op2 = State.get (getOperand (1 ), 0 );
1459+ Value *Op1 = State.get (getOperand (0 ));
1460+ Value *Op2 = State.get (getOperand (1 ));
14621461 auto &Ctx = State.Builder .getContext ();
14631462 Value *Pred = MetadataAsValue::get (
14641463 Ctx, MDString::get (Ctx, CmpInst::getPredicateName (getPredicate ())));
@@ -1471,46 +1470,45 @@ void VPWidenEVLRecipe::execute(VPTransformState &State) {
14711470 VectorType *RetType = VectorType::get (Type::getInt1Ty (Ctx), State.VF );
14721471 Value *VPInst = Builder.createVectorInstruction (Opcode, RetType,
14731472 {Op1, Op2, Pred}, " vp.op" );
1474- if (auto *VecOp = dyn_cast<CastInst >(VPInst))
1475- VecOp-> copyIRFlags ( getUnderlyingInstr ( ));
1473+ if (isa<FPMathOperator >(VPInst))
1474+ setFlags (cast<Instruction>(VPInst ));
14761475
1477- State.set (this , VPInst, 0 );
1476+ State.set (this , VPInst);
14781477 State.addMetadata (VPInst,
14791478 dyn_cast_or_null<Instruction>(getUnderlyingValue ()));
14801479 return ;
14811480 }
14821481
1483- if (! Instruction::isBinaryOp (Opcode) && ! Instruction::isUnaryOp (Opcode))
1484- llvm_unreachable ( " Unsupported opcode in VPWidenEVLRecipe::execute " );
1482+ if (Instruction::isBinaryOp (Opcode) || Instruction::isUnaryOp (Opcode)) {
1483+ State. setDebugLocFrom ( getDebugLoc () );
14851484
1486- State.setDebugLocFrom (getDebugLoc ());
1487-
1488- assert (State.get (getOperand (0 ))->getType ()->isVectorTy () &&
1489- " VPWidenEVLRecipe should not be used for scalars" );
1485+ assert (State.get (getOperand (0 ))->getType ()->isVectorTy () &&
1486+ " VPWidenEVLRecipe should not be used for scalars" );
14901487
1491- VPValue *EVL = getEVL ();
1492- Value *EVLArg = State.get (EVL, /* NeedsScalar=*/ true );
1493- IRBuilderBase &BuilderIR = State.Builder ;
1494- VectorBuilder Builder (BuilderIR);
1495- Value *Mask = BuilderIR.CreateVectorSplat (State.VF , BuilderIR.getTrue ());
1488+ VPValue *EVL = getEVL ();
1489+ Value *EVLArg = State.get (EVL, /* NeedsScalar=*/ true );
1490+ IRBuilderBase &BuilderIR = State.Builder ;
1491+ VectorBuilder Builder (BuilderIR);
1492+ Value *Mask = BuilderIR.CreateVectorSplat (State.VF , BuilderIR.getTrue ());
14961493
1497- SmallVector<Value *, 4 > Ops;
1498- for (unsigned I = 0 , E = getNumOperands () - 1 ; I < E; ++I) {
1499- VPValue *VPOp = getOperand (I);
1500- Ops.push_back (State.get (VPOp));
1501- }
1494+ SmallVector<Value *, 4 > Ops;
1495+ for (unsigned I = 0 , E = getNumOperands () - 1 ; I < E; ++I) {
1496+ VPValue *VPOp = getOperand (I);
1497+ Ops.push_back (State.get (VPOp));
1498+ }
15021499
1503- Builder.setMask (Mask).setEVL (EVLArg);
1504- Value *VPInst =
1505- Builder. createVectorInstruction (Opcode, Ops[ 0 ]-> getType (), Ops, " vp.op" );
1506- // Currently vp-intrinsics only accept FMF flags.
1507- // TODO: Enable other flags when support is added.
1508- if (isa<FPMathOperator>(VPInst))
1509- setFlags (cast<Instruction>(VPInst));
1500+ Builder.setMask (Mask).setEVL (EVLArg);
1501+ Value *VPInst = Builder. createVectorInstruction (Opcode, Ops[ 0 ]-> getType (),
1502+ Ops, " vp.op" );
1503+ // Currently vp-intrinsics only accept FMF flags.
1504+ // TODO: Enable other flags when support is added.
1505+ if (isa<FPMathOperator>(VPInst))
1506+ setFlags (cast<Instruction>(VPInst));
15101507
1511- State.set (this , VPInst);
1512- State.addMetadata (VPInst,
1513- dyn_cast_or_null<Instruction>(getUnderlyingValue ()));
1508+ State.set (this , VPInst);
1509+ State.addMetadata (VPInst,
1510+ dyn_cast_or_null<Instruction>(getUnderlyingValue ()));
1511+ }
15141512}
15151513
15161514#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
0 commit comments