Skip to content

Commit 8aa5b69

Browse files
committed
Add test
1 parent 7549fd2 commit 8aa5b69

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

llvm/unittests/Analysis/ValueTrackingTest.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,6 +1310,37 @@ TEST_F(ValueTrackingTest, MatchBinaryIntrinsicRecurrenceNegativeFSHR) {
13101310
EXPECT_FALSE(matchSimpleBinaryIntrinsicRecurrence(II, PN, Init, OtherOp));
13111311
}
13121312

1313+
TEST_F(ValueTrackingTest, MatchBinaryIntrinsicRecurrenceNonTwoOperand) {
1314+
auto M = parseModule(R"(
1315+
declare noundef i32 @llvm.nvvm.read.ptx.sreg.nctaid.x()
1316+
declare i32 @llvm.umin.i32(i32, i32)
1317+
1318+
define void @foo(i32 %arg) {
1319+
bb:
1320+
br i1 false, label %bb1, label %bb2
1321+
1322+
bb1: ; preds = %bb
1323+
br label %bb3
1324+
1325+
bb2: ; preds = %bb
1326+
%i = tail call noundef i32 @llvm.nvvm.read.ptx.sreg.nctaid.x()
1327+
br label %bb3
1328+
1329+
bb3: ; preds = %bb2, %bb1
1330+
%i4 = phi i32 [ 0, %bb1 ], [ %i, %bb2 ]
1331+
%i6 = tail call noundef i32 @llvm.umin.i32(i32 %i4, i32 %arg)
1332+
ret void
1333+
}
1334+
)");
1335+
1336+
auto *F = M->getFunction("foo");
1337+
auto *II = &cast<IntrinsicInst>(findInstructionByName(F, "i6"));
1338+
PHINode *PN;
1339+
Value *Init, *OtherOp;
1340+
// Check that it does not crash (see PR #152700)
1341+
EXPECT_FALSE(matchSimpleBinaryIntrinsicRecurrence(II, PN, Init, OtherOp));
1342+
}
1343+
13131344
TEST_F(ComputeKnownBitsTest, ComputeKnownBits) {
13141345
parseAssembly(
13151346
"define i32 @test(i32 %a, i32 %b) {\n"

0 commit comments

Comments
 (0)