aboutsummaryrefslogtreecommitdiff
path: root/llvm/test
diff options
context:
space:
mode:
authorIvan R. Ivanov <ivanov.i.aa@m.titech.ac.jp>2025-08-08 17:39:24 +0200
committerGitHub <noreply@github.com>2025-08-08 17:39:24 +0200
commit7c141e2118f9387e941478e6d4da133868876cf9 (patch)
tree19dc064de91238224e70b525bfe6136a8f57716b /llvm/test
parent66734f4c3ceb82abb22c22445027bf8860a41d0b (diff)
downloadllvm-7c141e2118f9387e941478e6d4da133868876cf9.zip
llvm-7c141e2118f9387e941478e6d4da133868876cf9.tar.gz
llvm-7c141e2118f9387e941478e6d4da133868876cf9.tar.bz2
[ValueTracking] Add missing check for two-value PN recurrence matching (#152700)
When InstTy is a type like IntrinsicInst which can have a variable number of arguments, we can encounter a case where Operation will have fewer than two arguments and error at the getOperand() calls. Fixes: https://github.com/llvm/llvm-project/issues/152725.
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Analysis/ValueTracking/pr152700.ll28
1 files changed, 28 insertions, 0 deletions
diff --git a/llvm/test/Analysis/ValueTracking/pr152700.ll b/llvm/test/Analysis/ValueTracking/pr152700.ll
new file mode 100644
index 0000000..91644c5
--- /dev/null
+++ b/llvm/test/Analysis/ValueTracking/pr152700.ll
@@ -0,0 +1,28 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt < %s -passes=instcombine -S | FileCheck %s
+
+declare noundef i32 @llvm.nvvm.read.ptx.sreg.nctaid.x()
+declare i32 @llvm.umin.i32(i32, i32)
+define i32 @foo(i1 %c, i32 %arg) {
+; CHECK-LABEL: define i32 @foo(
+; CHECK-SAME: i1 [[C:%.*]], i32 [[ARG:%.*]]) {
+; CHECK-NEXT: [[ENTRY:.*]]:
+; CHECK-NEXT: [[I:%.*]] = call i32 @llvm.nvvm.read.ptx.sreg.nctaid.x()
+; CHECK-NEXT: br i1 [[C]], label %[[BB_1:.*]], label %[[BB_2:.*]]
+; CHECK: [[BB_1]]:
+; CHECK-NEXT: br label %[[BB_2]]
+; CHECK: [[BB_2]]:
+; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ [[I]], %[[ENTRY]] ], [ 0, %[[BB_1]] ]
+; CHECK-NEXT: [[RES:%.*]] = call i32 @llvm.umin.i32(i32 [[PHI]], i32 [[ARG]])
+; CHECK-NEXT: ret i32 [[RES]]
+;
+entry:
+ %i = call i32 @llvm.nvvm.read.ptx.sreg.nctaid.x()
+ br i1 %c, label %bb.1, label %bb.2
+bb.1:
+ br label %bb.2
+bb.2:
+ %phi = phi i32 [ %i, %entry ], [ 0, %bb.1 ]
+ %res = call i32 @llvm.umin.i32(i32 %phi, i32 %arg)
+ ret i32 %res
+}