@@ -1310,6 +1310,37 @@ TEST_F(ValueTrackingTest, MatchBinaryIntrinsicRecurrenceNegativeFSHR) {
1310
1310
EXPECT_FALSE (matchSimpleBinaryIntrinsicRecurrence (II, PN, Init, OtherOp));
1311
1311
}
1312
1312
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
+
1313
1344
TEST_F (ComputeKnownBitsTest, ComputeKnownBits) {
1314
1345
parseAssembly (
1315
1346
" define i32 @test(i32 %a, i32 %b) {\n "
0 commit comments