@@ -654,9 +654,8 @@ void VPRecipeWithIRFlags::printFlags(raw_ostream &O) const {
654
654
655
655
void VPWidenRecipe::execute (VPTransformState &State) {
656
656
State.setDebugLocFrom (getDebugLoc ());
657
- auto &I = *cast<Instruction>(getUnderlyingValue ());
658
657
auto &Builder = State.Builder ;
659
- switch (I. getOpcode () ) {
658
+ switch (Opcode ) {
660
659
case Instruction::Call:
661
660
case Instruction::Br:
662
661
case Instruction::PHI:
@@ -688,14 +687,14 @@ void VPWidenRecipe::execute(VPTransformState &State) {
688
687
for (VPValue *VPOp : operands ())
689
688
Ops.push_back (State.get (VPOp, Part));
690
689
691
- Value *V = Builder.CreateNAryOp (I. getOpcode () , Ops);
690
+ Value *V = Builder.CreateNAryOp (Opcode , Ops);
692
691
693
692
if (auto *VecOp = dyn_cast<Instruction>(V))
694
693
setFlags (VecOp);
695
694
696
695
// Use this vector value for all users of the original instruction.
697
696
State.set (this , V, Part);
698
- State.addMetadata (V, &I );
697
+ State.addMetadata (V, dyn_cast_or_null<Instruction>( getUnderlyingValue ()) );
699
698
}
700
699
701
700
break ;
@@ -712,29 +711,30 @@ void VPWidenRecipe::execute(VPTransformState &State) {
712
711
case Instruction::ICmp:
713
712
case Instruction::FCmp: {
714
713
// Widen compares. Generate vector compares.
715
- bool FCmp = (I.getOpcode () == Instruction::FCmp);
716
- auto *Cmp = cast<CmpInst>(&I);
714
+ bool FCmp = Opcode == Instruction::FCmp;
717
715
for (unsigned Part = 0 ; Part < State.UF ; ++Part) {
718
716
Value *A = State.get (getOperand (0 ), Part);
719
717
Value *B = State.get (getOperand (1 ), Part);
720
718
Value *C = nullptr ;
721
719
if (FCmp) {
722
720
// Propagate fast math flags.
723
721
IRBuilder<>::FastMathFlagGuard FMFG (Builder);
724
- Builder.setFastMathFlags (Cmp->getFastMathFlags ());
725
- C = Builder.CreateFCmp (Cmp->getPredicate (), A, B);
722
+ if (auto *I = dyn_cast_or_null<Instruction>(getUnderlyingValue ()))
723
+ Builder.setFastMathFlags (I->getFastMathFlags ());
724
+ C = Builder.CreateFCmp (getPredicate (), A, B);
726
725
} else {
727
- C = Builder.CreateICmp (Cmp-> getPredicate (), A, B);
726
+ C = Builder.CreateICmp (getPredicate (), A, B);
728
727
}
729
728
State.set (this , C, Part);
730
- State.addMetadata (C, &I );
729
+ State.addMetadata (C, dyn_cast_or_null<Instruction>( getUnderlyingValue ()) );
731
730
}
732
731
733
732
break ;
734
733
}
735
734
default :
736
735
// This instruction is not vectorized by simple widening.
737
- LLVM_DEBUG (dbgs () << " LV: Found an unhandled instruction: " << I);
736
+ LLVM_DEBUG (dbgs () << " LV: Found an unhandled opcode : "
737
+ << Instruction::getOpcodeName (Opcode));
738
738
llvm_unreachable (" Unhandled instruction!" );
739
739
} // end of switch.
740
740
}
@@ -743,8 +743,7 @@ void VPWidenRecipe::print(raw_ostream &O, const Twine &Indent,
743
743
VPSlotTracker &SlotTracker) const {
744
744
O << Indent << " WIDEN " ;
745
745
printAsOperand (O, SlotTracker);
746
- const Instruction *UI = getUnderlyingInstr ();
747
- O << " = " << UI->getOpcodeName ();
746
+ O << " = " << Instruction::getOpcodeName (Opcode);
748
747
printFlags (O);
749
748
printOperands (O, SlotTracker);
750
749
}
0 commit comments