@@ -648,6 +648,10 @@ Value *VPInstruction::generate(VPTransformState &State) {
648
648
for (unsigned Part = 0 ; Part < UF; ++Part)
649
649
RdxParts[Part] = State.get (getOperand (1 + Part), PhiR->isInLoop ());
650
650
651
+ IRBuilderBase::FastMathFlagGuard FMFG (Builder);
652
+ if (hasFastMathFlags ())
653
+ Builder.setFastMathFlags (getFastMathFlags ());
654
+
651
655
// If the vector reduction can be performed in a smaller type, we truncate
652
656
// then extend the loop exit value to enable InstCombine to evaluate the
653
657
// entire expression in the smaller type.
@@ -663,8 +667,6 @@ Value *VPInstruction::generate(VPTransformState &State) {
663
667
ReducedPartRdx = RdxParts[UF - 1 ];
664
668
} else {
665
669
// Floating-point operations should have some FMF to enable the reduction.
666
- IRBuilderBase::FastMathFlagGuard FMFG (Builder);
667
- Builder.setFastMathFlags (RdxDesc.getFastMathFlags ());
668
670
for (unsigned Part = 1 ; Part < UF; ++Part) {
669
671
Value *RdxPart = RdxParts[Part];
670
672
if (RecurrenceDescriptor::isMinMaxRecurrenceKind (RK))
@@ -684,9 +686,6 @@ Value *VPInstruction::generate(VPTransformState &State) {
684
686
// TODO: Support in-order reductions based on the recurrence descriptor.
685
687
// All ops in the reduction inherit fast-math-flags from the recurrence
686
688
// descriptor.
687
- IRBuilderBase::FastMathFlagGuard FMFG (Builder);
688
- Builder.setFastMathFlags (RdxDesc.getFastMathFlags ());
689
-
690
689
if (RecurrenceDescriptor::isAnyOfRecurrenceKind (RK))
691
690
ReducedPartRdx =
692
691
createAnyOfReduction (Builder, ReducedPartRdx, RdxDesc, OrigPhi);
@@ -1599,7 +1598,8 @@ bool VPIRFlags::flagsValidForOpcode(unsigned Opcode) const {
1599
1598
Opcode == Instruction::FSub || Opcode == Instruction::FNeg ||
1600
1599
Opcode == Instruction::FDiv || Opcode == Instruction::FRem ||
1601
1600
Opcode == Instruction::FCmp || Opcode == Instruction::Select ||
1602
- Opcode == VPInstruction::WideIVStep;
1601
+ Opcode == VPInstruction::WideIVStep ||
1602
+ Opcode == VPInstruction::ComputeReductionResult;
1603
1603
case OperationType::NonNegOp:
1604
1604
return Opcode == Instruction::ZExt;
1605
1605
break ;
0 commit comments