Skip to content

Commit 8bfa38a

Browse files
ElvisWang123lukel97
authored andcommitted
!fixup, Only set FMF for FMOperators and update after merge main.
1 parent dbaec21 commit 8bfa38a

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
@@ -2410,8 +2410,7 @@ void VPReductionRecipe::print(raw_ostream &O, const Twine &Indent,
24102410
O << " = ";
24112411
getChainOp()->printAsOperand(O, SlotTracker);
24122412
O << " +";
2413-
if (isa<FPMathOperator>(getUnderlyingInstr()))
2414-
printFlags(O);
2413+
printFlags(O);
24152414
O << " reduce." << Instruction::getOpcodeName(RdxDesc.getOpcode()) << " (";
24162415
getVecOp()->printAsOperand(O, SlotTracker);
24172416
if (isConditional()) {
@@ -2432,8 +2431,7 @@ void VPReductionEVLRecipe::print(raw_ostream &O, const Twine &Indent,
24322431
O << " = ";
24332432
getChainOp()->printAsOperand(O, SlotTracker);
24342433
O << " +";
2435-
if (isa<FPMathOperator>(getUnderlyingInstr()))
2436-
printFlags(O);
2434+
printFlags(O);
24372435
O << " vp.reduce." << Instruction::getOpcodeName(RdxDesc.getOpcode()) << " (";
24382436
getVecOp()->printAsOperand(O, SlotTracker);
24392437
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)