Skip to content

Commit 07b5790

Browse files
committed
!fixup, Address comments.
1 parent d60f933 commit 07b5790

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ class VPRecipeWithIRFlags : public VPSingleDefRecipe {
792792

793793
/// Set fast-math flags for this recipe.
794794
void setFastMathFlags(FastMathFlags FMFs) {
795-
OpType = OperationType::FPMathOp;
795+
assert(OpType == OperationType::FPMathOp);
796796
this->FMFs = FMFs;
797797
}
798798

@@ -2314,7 +2314,8 @@ class VPReductionRecipe : public VPRecipeWithIRFlags {
23142314
// The inloop reduction may across multiple scalar instruction and the
23152315
// underlying instruction may not contains the corresponding flags. Set the
23162316
// flags explicit from the redurrence descriptor.
2317-
setFastMathFlags(R.getFastMathFlags());
2317+
if (isa<FPMathOperator>(I))
2318+
setFastMathFlags(R.getFastMathFlags());
23182319
}
23192320

23202321
public:

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2351,8 +2351,7 @@ void VPReductionRecipe::print(raw_ostream &O, const Twine &Indent,
23512351
O << " = ";
23522352
getChainOp()->printAsOperand(O, SlotTracker);
23532353
O << " +";
2354-
if (isa_and_nonnull<FPMathOperator>(getUnderlyingValue()))
2355-
printFlags(O);
2354+
printFlags(O);
23562355
O << " reduce." << Instruction::getOpcodeName(RdxDesc.getOpcode()) << " (";
23572356
getVecOp()->printAsOperand(O, SlotTracker);
23582357
if (isConditional()) {
@@ -2373,8 +2372,7 @@ void VPReductionEVLRecipe::print(raw_ostream &O, const Twine &Indent,
23732372
O << " = ";
23742373
getChainOp()->printAsOperand(O, SlotTracker);
23752374
O << " +";
2376-
if (isa_and_nonnull<FPMathOperator>(getUnderlyingValue()))
2377-
printFlags(O);
2375+
printFlags(O);
23782376
O << " vp.reduce." << Instruction::getOpcodeName(RdxDesc.getOpcode()) << " (";
23792377
getVecOp()->printAsOperand(O, SlotTracker);
23802378
O << ", ";

llvm/test/Transforms/LoopVectorize/RISCV/vplan-vp-intrinsics-reduction.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ define i32 @reduction(ptr %a, i64 %n, i32 %start) {
101101
; IF-EVL-INLOOP-NEXT: CLONE ir<[[GEP1:%.+]]> = getelementptr inbounds ir<%a>, vp<[[ST]]>
102102
; IF-EVL-INLOOP-NEXT: vp<[[PTR1:%[0-9]+]]> = vector-pointer ir<[[GEP1]]>
103103
; IF-EVL-INLOOP-NEXT: WIDEN ir<[[LD1:%.+]]> = vp.load vp<[[PTR1]]>, vp<[[EVL]]>
104-
; IF-EVL-INLOOP-NEXT: REDUCE ir<[[ADD:%.+]]> = ir<[[RDX_PHI]]> + vp.reduce.add (ir<[[LD1]]>, vp<[[EVL]]>)
104+
; IF-EVL-INLOOP-NEXT: REDUCE ir<[[ADD:%.+]]> = ir<[[RDX_PHI]]> + nsw vp.reduce.add (ir<[[LD1]]>, vp<[[EVL]]>)
105105
; IF-EVL-INLOOP-NEXT: SCALAR-CAST vp<[[CAST:%[0-9]+]]> = zext vp<[[EVL]]> to i64
106106
; IF-EVL-INLOOP-NEXT: EMIT vp<[[IV_NEXT]]> = add vp<[[CAST]]>, vp<[[EVL_PHI]]>
107107
; IF-EVL-INLOOP-NEXT: EMIT vp<[[IV_NEXT_EXIT:%.+]]> = add vp<[[IV]]>, vp<[[VFUF]]>

0 commit comments

Comments
 (0)