@@ -648,6 +648,10 @@ Value *VPInstruction::generate(VPTransformState &State) {
648648 for (unsigned Part = 0 ; Part < UF; ++Part)
649649 RdxParts[Part] = State.get (getOperand (1 + Part), PhiR->isInLoop ());
650650
651+ IRBuilderBase::FastMathFlagGuard FMFG (Builder);
652+ if (hasFastMathFlags ())
653+ Builder.setFastMathFlags (getFastMathFlags ());
654+
651655 // If the vector reduction can be performed in a smaller type, we truncate
652656 // then extend the loop exit value to enable InstCombine to evaluate the
653657 // entire expression in the smaller type.
@@ -663,8 +667,6 @@ Value *VPInstruction::generate(VPTransformState &State) {
663667 ReducedPartRdx = RdxParts[UF - 1 ];
664668 } else {
665669 // Floating-point operations should have some FMF to enable the reduction.
666- IRBuilderBase::FastMathFlagGuard FMFG (Builder);
667- Builder.setFastMathFlags (RdxDesc.getFastMathFlags ());
668670 for (unsigned Part = 1 ; Part < UF; ++Part) {
669671 Value *RdxPart = RdxParts[Part];
670672 if (RecurrenceDescriptor::isMinMaxRecurrenceKind (RK))
@@ -684,9 +686,6 @@ Value *VPInstruction::generate(VPTransformState &State) {
684686 // TODO: Support in-order reductions based on the recurrence descriptor.
685687 // All ops in the reduction inherit fast-math-flags from the recurrence
686688 // descriptor.
687- IRBuilderBase::FastMathFlagGuard FMFG (Builder);
688- Builder.setFastMathFlags (RdxDesc.getFastMathFlags ());
689-
690689 if (RecurrenceDescriptor::isAnyOfRecurrenceKind (RK))
691690 ReducedPartRdx =
692691 createAnyOfReduction (Builder, ReducedPartRdx, RdxDesc, OrigPhi);
@@ -1599,7 +1598,8 @@ bool VPIRFlags::flagsValidForOpcode(unsigned Opcode) const {
15991598 Opcode == Instruction::FSub || Opcode == Instruction::FNeg ||
16001599 Opcode == Instruction::FDiv || Opcode == Instruction::FRem ||
16011600 Opcode == Instruction::FCmp || Opcode == Instruction::Select ||
1602- Opcode == VPInstruction::WideIVStep;
1601+ Opcode == VPInstruction::WideIVStep ||
1602+ Opcode == VPInstruction::ComputeReductionResult;
16031603 case OperationType::NonNegOp:
16041604 return Opcode == Instruction::ZExt;
16051605 break ;
0 commit comments