[llvm] [FuncSpec] Consider literal constants of recursive functions (PR #111162)
Alexandros Lamprineas via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 7 05:21:09 PDT 2024
================
@@ -108,6 +108,46 @@ define i32 @main(ptr %0, i32 %1) {
; CHECK-NEXT: ret void
;
;
+; CHECK-LABEL: define internal void @func.specialized.3(
+; CHECK-SAME: ptr [[TMP0:%.*]], i32 [[TMP1:%.*]]) {
+; CHECK-NEXT: [[TMP3:%.*]] = alloca i32, align 4
+; CHECK-NEXT: store i32 [[TMP1]], ptr [[TMP3]], align 4
+; CHECK-NEXT: [[TMP4:%.*]] = load i32, ptr [[TMP3]], align 4
+; CHECK-NEXT: [[TMP5:%.*]] = icmp slt i32 [[TMP4]], 1
+; CHECK-NEXT: br i1 [[TMP5]], label %[[BB12:.*]], label %[[BB6:.*]]
+; CHECK: [[BB6]]:
+; CHECK-NEXT: [[TMP7:%.*]] = load i32, ptr [[TMP3]], align 4
+; CHECK-NEXT: [[TMP8:%.*]] = sext i32 [[TMP7]] to i64
+; CHECK-NEXT: [[TMP9:%.*]] = getelementptr inbounds i32, ptr [[TMP0]], i64 [[TMP8]]
+; CHECK-NEXT: call void @decrement(ptr [[TMP9]])
+; CHECK-NEXT: [[TMP10:%.*]] = load i32, ptr [[TMP3]], align 4
+; CHECK-NEXT: [[TMP11:%.*]] = add nsw i32 [[TMP10]], -1
+; CHECK-NEXT: call void @func.specialized.3(ptr [[TMP0]], i32 [[TMP11]])
+; CHECK-NEXT: br label %[[BB12]]
+; CHECK: [[BB12]]:
+; CHECK-NEXT: ret void
+;
+;
+; ONE-ITER-LABEL: define internal void @func(
+; ONE-ITER-SAME: ptr [[TMP0:%.*]], i32 [[TMP1:%.*]], ptr nocapture [[TMP2:%.*]]) {
+; ONE-ITER-NEXT: [[TMP4:%.*]] = alloca i32, align 4
+; ONE-ITER-NEXT: store i32 [[TMP1]], ptr [[TMP4]], align 4
+; ONE-ITER-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP4]], align 4
+; ONE-ITER-NEXT: [[TMP6:%.*]] = icmp slt i32 [[TMP5]], 1
+; ONE-ITER-NEXT: br i1 [[TMP6]], label %[[BB13:.*]], label %[[BB7:.*]]
+; ONE-ITER: [[BB7]]:
+; ONE-ITER-NEXT: [[TMP8:%.*]] = load i32, ptr [[TMP4]], align 4
+; ONE-ITER-NEXT: [[TMP9:%.*]] = sext i32 [[TMP8]] to i64
+; ONE-ITER-NEXT: [[TMP10:%.*]] = getelementptr inbounds i32, ptr [[TMP0]], i64 [[TMP9]]
+; ONE-ITER-NEXT: call void [[TMP2]](ptr [[TMP10]])
+; ONE-ITER-NEXT: [[TMP11:%.*]] = load i32, ptr [[TMP4]], align 4
+; ONE-ITER-NEXT: [[TMP12:%.*]] = add nsw i32 [[TMP11]], -1
+; ONE-ITER-NEXT: call void @func(ptr [[TMP0]], i32 [[TMP12]], ptr [[TMP2]])
+; ONE-ITER-NEXT: br label %[[BB13]]
+; ONE-ITER: [[BB13]]:
+; ONE-ITER-NEXT: ret void
+;
----------------
labrinea wrote:
Any new tests should be moved to a new file named accordingly based on what the test is trying to check. In this case something like `recursive-literal-const-args.ll` or similar.
https://github.com/llvm/llvm-project/pull/111162
More information about the llvm-commits
mailing list