Skip to content

Commit 942a14d

Browse files
committed
!fixup, Remove unneeded checks and check undelryingInstr is FPMO or not.
1 parent 0473b05 commit 942a14d

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,8 +2224,7 @@ void VPReductionRecipe::execute(VPTransformState &State) {
22242224
RecurKind Kind = RdxDesc.getRecurrenceKind();
22252225
// Propagate the fast-math flags carried by the underlying instruction.
22262226
IRBuilderBase::FastMathFlagGuard FMFGuard(State.Builder);
2227-
if (hasFastMathFlags())
2228-
State.Builder.setFastMathFlags(getFastMathFlags());
2227+
State.Builder.setFastMathFlags(getFastMathFlags());
22292228
State.setDebugLocFrom(getDebugLoc());
22302229
Value *NewVecOp = State.get(getVecOp());
22312230
if (VPValue *Cond = getCondOp()) {
@@ -2276,8 +2275,7 @@ void VPReductionEVLRecipe::execute(VPTransformState &State) {
22762275
// Propagate the fast-math flags carried by the underlying instruction.
22772276
IRBuilderBase::FastMathFlagGuard FMFGuard(Builder);
22782277
const RecurrenceDescriptor &RdxDesc = getRecurrenceDescriptor();
2279-
if (hasFastMathFlags())
2280-
Builder.setFastMathFlags(getFastMathFlags());
2278+
Builder.setFastMathFlags(getFastMathFlags());
22812279

22822280
RecurKind Kind = RdxDesc.getRecurrenceKind();
22832281
Value *Prev = State.get(getChainOp(), /*IsScalar*/ true);
@@ -2314,8 +2312,7 @@ InstructionCost VPReductionRecipe::computeCost(ElementCount VF,
23142312
Type *ElementTy = Ctx.Types.inferScalarType(this);
23152313
auto *VectorTy = cast<VectorType>(toVectorTy(ElementTy, VF));
23162314
unsigned Opcode = RdxDesc.getOpcode();
2317-
FastMathFlags FMFs =
2318-
hasFastMathFlags() ? getFastMathFlags() : FastMathFlags();
2315+
FastMathFlags FMFs = getFastMathFlags();
23192316

23202317
// TODO: Support any-of and in-loop reductions.
23212318
assert(
@@ -2351,7 +2348,8 @@ void VPReductionRecipe::print(raw_ostream &O, const Twine &Indent,
23512348
O << " = ";
23522349
getChainOp()->printAsOperand(O, SlotTracker);
23532350
O << " +";
2354-
printFlags(O);
2351+
if (isa<FPMathOperator>(getUnderlyingInstr()))
2352+
printFlags(O);
23552353
O << " reduce." << Instruction::getOpcodeName(RdxDesc.getOpcode()) << " (";
23562354
getVecOp()->printAsOperand(O, SlotTracker);
23572355
if (isConditional()) {
@@ -2372,7 +2370,8 @@ void VPReductionEVLRecipe::print(raw_ostream &O, const Twine &Indent,
23722370
O << " = ";
23732371
getChainOp()->printAsOperand(O, SlotTracker);
23742372
O << " +";
2375-
printFlags(O);
2373+
if (isa<FPMathOperator>(getUnderlyingInstr()))
2374+
printFlags(O);
23762375
O << " vp.reduce." << Instruction::getOpcodeName(RdxDesc.getOpcode()) << " (";
23772376
getVecOp()->printAsOperand(O, SlotTracker);
23782377
O << ", ";

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

Lines changed: 2 additions & 2 deletions
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]]> + reassoc nsz arcp contract afn vp.reduce.add (ir<[[LD1]]>, vp<[[EVL]]>)
104+
; IF-EVL-INLOOP-NEXT: REDUCE ir<[[ADD:%.+]]> = ir<[[RDX_PHI]]> + 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]]>
@@ -196,7 +196,7 @@ define i32 @reduction(ptr %a, i64 %n, i32 %start) {
196196
; NO-VP-INLOOP-NEXT: CLONE ir<[[GEP1:%.+]]> = getelementptr inbounds ir<%a>, vp<[[ST]]>
197197
; NO-VP-INLOOP-NEXT: vp<[[PTR1:%[0-9]+]]> = vector-pointer ir<[[GEP1]]>
198198
; NO-VP-INLOOP-NEXT: WIDEN ir<[[LD1:%.+]]> = load vp<[[PTR1]]>
199-
; NO-VP-INLOOP-NEXT: REDUCE ir<[[ADD:%.+]]> = ir<[[RDX_PHI]]> + reassoc nsz arcp contract afn reduce.add (ir<[[LD1]]>)
199+
; NO-VP-INLOOP-NEXT: REDUCE ir<[[ADD:%.+]]> = ir<[[RDX_PHI]]> + reduce.add (ir<[[LD1]]>)
200200
; NO-VP-INLOOP-NEXT: EMIT vp<[[IV_NEXT_EXIT:%.+]]> = add nuw vp<[[IV]]>, vp<[[VFUF]]>
201201
; NO-VP-INLOOP-NEXT: EMIT branch-on-count vp<[[IV_NEXT_EXIT]]>, vp<[[VTC]]>
202202
; NO-VP-INLOOP-NEXT: No successors

0 commit comments

Comments
 (0)