Skip to content

Commit 4efc26b

Browse files
ElvisWang123lukel97
authored andcommitted
!fixup, Address comments.
1 parent a7120a1 commit 4efc26b

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
@@ -790,7 +790,7 @@ class VPRecipeWithIRFlags : public VPSingleDefRecipe {
790790

791791
/// Set fast-math flags for this recipe.
792792
void setFastMathFlags(FastMathFlags FMFs) {
793-
OpType = OperationType::FPMathOp;
793+
assert(OpType == OperationType::FPMathOp);
794794
this->FMFs = FMFs;
795795
}
796796

@@ -2264,7 +2264,8 @@ class VPReductionRecipe : public VPRecipeWithIRFlags {
22642264
// The inloop reduction may across multiple scalar instruction and the
22652265
// underlying instruction may not contains the corresponding flags. Set the
22662266
// flags explicit from the redurrence descriptor.
2267-
setFastMathFlags(R.getFastMathFlags());
2267+
if (isa<FPMathOperator>(I))
2268+
setFastMathFlags(R.getFastMathFlags());
22682269
}
22692270

22702271
public:

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2413,8 +2413,7 @@ void VPReductionRecipe::print(raw_ostream &O, const Twine &Indent,
24132413
O << " = ";
24142414
getChainOp()->printAsOperand(O, SlotTracker);
24152415
O << " +";
2416-
if (isa_and_nonnull<FPMathOperator>(getUnderlyingValue()))
2417-
printFlags(O);
2416+
printFlags(O);
24182417
O << " reduce." << Instruction::getOpcodeName(RdxDesc.getOpcode()) << " (";
24192418
getVecOp()->printAsOperand(O, SlotTracker);
24202419
if (isConditional()) {
@@ -2435,8 +2434,7 @@ void VPReductionEVLRecipe::print(raw_ostream &O, const Twine &Indent,
24352434
O << " = ";
24362435
getChainOp()->printAsOperand(O, SlotTracker);
24372436
O << " +";
2438-
if (isa_and_nonnull<FPMathOperator>(getUnderlyingValue()))
2439-
printFlags(O);
2437+
printFlags(O);
24402438
O << " vp.reduce." << Instruction::getOpcodeName(RdxDesc.getOpcode()) << " (";
24412439
getVecOp()->printAsOperand(O, SlotTracker);
24422440
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)