Skip to content

Commit 75a591b

Browse files
Uyiosa IyekekpolorUyiosa Iyekekpolor
authored andcommitted
[Analysis][LV] Handle FMinNum/FMaxNum in RecurrenceDescriptor::getOpcode
Teach getOpcode to return FCmp for FMinNum/FMaxNum. Without these cases, passes that query the opcode for minNum/maxNum reductions can hit llvm_unreachable. Add a unit test to cover both enums.
1 parent 7f0e407 commit 75a591b

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

llvm/lib/Analysis/IVDescriptors.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,8 @@ unsigned RecurrenceDescriptor::getOpcode(RecurKind Kind) {
12281228
return Instruction::ICmp;
12291229
case RecurKind::FMax:
12301230
case RecurKind::FMin:
1231+
case RecurKind::FMaxNum:
1232+
case RecurKind::FMinNum:
12311233
case RecurKind::FMaximum:
12321234
case RecurKind::FMinimum:
12331235
case RecurKind::FMaximumNum:

llvm/unittests/Analysis/IVDescriptorsTest.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,12 @@ for.end:
259259
EXPECT_EQ(Kind, RecurKind::FMax);
260260
});
261261
}
262+
263+
TEST(IVDescriptorsTest, GetOpcodeForFMinMaxNum) {
264+
using RK = RecurKind;
265+
// Ensure the "num" variants map to the same opcode as the plain ones.
266+
EXPECT_EQ(RecurrenceDescriptor::getOpcode(RK::FMinNum),
267+
RecurrenceDescriptor::getOpcode(RK::FMin));
268+
EXPECT_EQ(RecurrenceDescriptor::getOpcode(RK::FMinNum),
269+
RecurrenceDescriptor::getOpcode(RK::FMin));
270+
}

0 commit comments

Comments
 (0)