@@ -1455,10 +1455,9 @@ InstructionCost VPWidenRecipe::computeCost(ElementCount VF,
1455
1455
1456
1456
void VPWidenEVLRecipe::execute (VPTransformState &State) {
1457
1457
unsigned Opcode = getOpcode ();
1458
- // TODO: Support other opcodes
1459
1458
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 ));
1462
1461
auto &Ctx = State.Builder .getContext ();
1463
1462
Value *Pred = MetadataAsValue::get (
1464
1463
Ctx, MDString::get (Ctx, CmpInst::getPredicateName (getPredicate ())));
@@ -1471,46 +1470,45 @@ void VPWidenEVLRecipe::execute(VPTransformState &State) {
1471
1470
VectorType *RetType = VectorType::get (Type::getInt1Ty (Ctx), State.VF );
1472
1471
Value *VPInst = Builder.createVectorInstruction (Opcode, RetType,
1473
1472
{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 ));
1476
1475
1477
- State.set (this , VPInst, 0 );
1476
+ State.set (this , VPInst);
1478
1477
State.addMetadata (VPInst,
1479
1478
dyn_cast_or_null<Instruction>(getUnderlyingValue ()));
1480
1479
return ;
1481
1480
}
1482
1481
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 () );
1485
1484
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" );
1490
1487
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 ());
1496
1493
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
+ }
1502
1499
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));
1510
1507
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
+ }
1514
1512
}
1515
1513
1516
1514
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
0 commit comments