Skip to content

Commit 6c6ccb2

Browse files
committed
!fixup, Only set FMF for FMOperators and update after merge main.
1 parent e7d6f55 commit 6c6ccb2

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2249,8 +2249,12 @@ class VPReductionRecipe : public VPRecipeWithIRFlags {
22492249
VPReductionRecipe(const unsigned char SC, const RecurrenceDescriptor &R,
22502250
Instruction *I, ArrayRef<VPValue *> Operands,
22512251
VPValue *CondOp, bool IsOrdered, DebugLoc DL)
2252-
: VPRecipeWithIRFlags(SC, Operands, R.getFastMathFlags(), DL), RdxDesc(R),
2253-
IsOrdered(IsOrdered) {
2252+
: VPRecipeWithIRFlags(SC, Operands,
2253+
isa_and_nonnull<FPMathOperator>(I)
2254+
? R.getFastMathFlags()
2255+
: FastMathFlags(),
2256+
DL),
2257+
RdxDesc(R), IsOrdered(IsOrdered) {
22542258
if (CondOp) {
22552259
IsConditional = true;
22562260
addOperand(CondOp);

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2397,8 +2397,7 @@ void VPReductionRecipe::print(raw_ostream &O, const Twine &Indent,
23972397
O << " = ";
23982398
getChainOp()->printAsOperand(O, SlotTracker);
23992399
O << " +";
2400-
if (isa<FPMathOperator>(getUnderlyingInstr()))
2401-
printFlags(O);
2400+
printFlags(O);
24022401
O << " reduce." << Instruction::getOpcodeName(RdxDesc.getOpcode()) << " (";
24032402
getVecOp()->printAsOperand(O, SlotTracker);
24042403
if (isConditional()) {
@@ -2419,8 +2418,7 @@ void VPReductionEVLRecipe::print(raw_ostream &O, const Twine &Indent,
24192418
O << " = ";
24202419
getChainOp()->printAsOperand(O, SlotTracker);
24212420
O << " +";
2422-
if (isa<FPMathOperator>(getUnderlyingInstr()))
2423-
printFlags(O);
2421+
printFlags(O);
24242422
O << " vp.reduce." << Instruction::getOpcodeName(RdxDesc.getOpcode()) << " (";
24252423
getVecOp()->printAsOperand(O, SlotTracker);
24262424
O << ", ";

llvm/test/Transforms/LoopVectorize/vplan-printing.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ define float @print_reduction(i64 %n, ptr noalias %y) {
167167
; CHECK-NEXT: CLONE ir<%arrayidx> = getelementptr inbounds ir<%y>, vp<[[STEPS]]>
168168
; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = vector-pointer ir<%arrayidx>
169169
; CHECK-NEXT: WIDEN ir<%lv> = load vp<[[VEC_PTR]]>
170-
; CHECK-NEXT: REDUCE ir<%red.next> = ir<%red> + reassoc nnan ninf nsz arcp contract afn reduce.fadd (ir<%lv>)
170+
; CHECK-NEXT: REDUCE ir<%red.next> = ir<%red> + fast reduce.fadd (ir<%lv>)
171171
; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT]]> = add nuw vp<[[CAN_IV]]>, vp<[[VFxUF]]>
172172
; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VTC]]>
173173
; CHECK-NEXT: No successors
@@ -234,7 +234,7 @@ define void @print_reduction_with_invariant_store(i64 %n, ptr noalias %y, ptr no
234234
; CHECK-NEXT: CLONE ir<%arrayidx> = getelementptr inbounds ir<%y>, vp<[[IV]]>
235235
; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = vector-pointer ir<%arrayidx>
236236
; CHECK-NEXT: WIDEN ir<%lv> = load vp<[[VEC_PTR]]>
237-
; CHECK-NEXT: REDUCE ir<%red.next> = ir<%red> + reassoc nnan ninf nsz arcp contract afn reduce.fadd (ir<%lv>) (with final reduction value stored in invariant address sank outside of loop)
237+
; CHECK-NEXT: REDUCE ir<%red.next> = ir<%red> + fast reduce.fadd (ir<%lv>) (with final reduction value stored in invariant address sank outside of loop)
238238
; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT]]> = add nuw vp<[[CAN_IV]]>, vp<[[VFxUF]]>
239239
; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VTC]]>
240240
; CHECK-NEXT: No successors

0 commit comments

Comments
 (0)