Skip to content

[IVDescriptors] Don't require nsz/nnan for (min|max)num. #137003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions llvm/lib/Analysis/IVDescriptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -892,10 +892,13 @@ RecurrenceDescriptor::InstDesc RecurrenceDescriptor::isRecurrenceInstr(
return true;
if (isa<FPMathOperator>(I) && I->hasNoNaNs() && I->hasNoSignedZeros())
return true;
// minimum and maximum intrinsics do not require nsz and nnan flags since
// NaN and signed zeroes are propagated in the intrinsic implementation.
// minimum/minnum and maximum/maxnum intrinsics do not require nsz and nnan
// flags since NaN and signed zeroes are propagated in the intrinsic
// implementation.
return match(I, m_Intrinsic<Intrinsic::minimum>(m_Value(), m_Value())) ||
match(I, m_Intrinsic<Intrinsic::maximum>(m_Value(), m_Value()));
match(I, m_Intrinsic<Intrinsic::maximum>(m_Value(), m_Value())) ||
match(I, m_Intrinsic<Intrinsic::minnum>(m_Value(), m_Value())) ||
match(I, m_Intrinsic<Intrinsic::maxnum>(m_Value(), m_Value()));
};
if (isIntMinMaxRecurrenceKind(Kind) ||
(HasRequiredFMF() && isFPMinMaxRecurrenceKind(Kind)))
Expand Down
6 changes: 4 additions & 2 deletions llvm/test/Transforms/LoopVectorize/minmax_reduction.ll
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,8 @@ for.body: ; preds = %entry, %for.body
}

; CHECK-LABEL: @fmin_intrinsic_nofast(
; CHECK-NOT: <2 x float> @llvm.minnum.v2f32
; CHECK: call <2 x float> @llvm.minnum.v2f32
; CHECK: call float @llvm.vector.reduce.fmin.v2f32
define float @fmin_intrinsic_nofast(ptr nocapture readonly %x) {
entry:
br label %for.body
Expand All @@ -1022,7 +1023,8 @@ for.body: ; preds = %entry, %for.body
}

; CHECK-LABEL: @fmax_intrinsic_nofast(
; CHECK-NOT: <2 x float> @llvm.maxnum.v2f32
; CHECK: call <2 x float> @llvm.maxnum.v2f32
; CHECK: call float @llvm.vector.reduce.fmax.v2f32
define float @fmax_intrinsic_nofast(ptr nocapture readonly %x) {
entry:
br label %for.body
Expand Down
Loading