[llvm] 03b807d - Replace numbered function arguments with descriptive names.
Martin Sebor via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 13 14:00:37 PDT 2022
Author: Martin Sebor
Date: 2022-04-13T15:00:11-06:00
New Revision: 03b807d3f2999888bbe395945987af06f201c142
URL: https://github.com/llvm/llvm-project/commit/03b807d3f2999888bbe395945987af06f201c142
DIFF: https://github.com/llvm/llvm-project/commit/03b807d3f2999888bbe395945987af06f201c142.diff
LOG: Replace numbered function arguments with descriptive names.
Added:
Modified:
llvm/test/Transforms/InstCombine/strnlen-2.ll
llvm/test/Transforms/InstCombine/strnlen-3.ll
llvm/test/Transforms/InstCombine/strnlen-4.ll
llvm/test/Transforms/InstCombine/strnlen-5.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/strnlen-2.ll b/llvm/test/Transforms/InstCombine/strnlen-2.ll
index 4af460ba0abc2..f46886598e318 100644
--- a/llvm/test/Transforms/InstCombine/strnlen-2.ll
+++ b/llvm/test/Transforms/InstCombine/strnlen-2.ll
@@ -13,91 +13,91 @@ declare i64 @strnlen(i8*, i64)
@s7 = constant [8 x i8] c"1234567\00"
-; Fold strnlen (%0 ? s3 : s5, 0) to 0.
+; Fold strnlen (C ? s3 : s5, 0) to 0.
-define i64 @fold_strnlen_s3_s5_0(i1 %0) {
+define i64 @fold_strnlen_s3_s5_0(i1 %C) {
; CHECK-LABEL: @fold_strnlen_s3_s5_0(
-; CHECK-NEXT: [[PTR:%.*]] = select i1 [[TMP0:%.*]], i8* getelementptr inbounds ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @s6, i64 0, i64 0)
+; CHECK-NEXT: [[PTR:%.*]] = select i1 [[C:%.*]], i8* getelementptr inbounds ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @s6, i64 0, i64 0)
; CHECK-NEXT: [[LEN:%.*]] = call i64 @strnlen(i8* [[PTR]], i64 0)
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ptr = select i1 %0, i8* getelementptr ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* getelementptr ([7 x i8], [7 x i8]* @s6, i64 0, i64 0)
+ %ptr = select i1 %C, i8* getelementptr ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* getelementptr ([7 x i8], [7 x i8]* @s6, i64 0, i64 0)
%len = call i64 @strnlen(i8* %ptr, i64 0)
ret i64 %len
}
-; Fold strnlen (%0 ? s3 : s5, 1) to 1.
+; Fold strnlen (C ? s3 : s5, 1) to 1.
-define i64 @fold_strnlen_s3_s5_1(i1 %0) {
+define i64 @fold_strnlen_s3_s5_1(i1 %C) {
; CHECK-LABEL: @fold_strnlen_s3_s5_1(
-; CHECK-NEXT: [[PTR:%.*]] = select i1 [[TMP0:%.*]], i8* getelementptr inbounds ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @s6, i64 0, i64 0)
+; CHECK-NEXT: [[PTR:%.*]] = select i1 [[C:%.*]], i8* getelementptr inbounds ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @s6, i64 0, i64 0)
; CHECK-NEXT: [[LEN:%.*]] = call i64 @strnlen(i8* [[PTR]], i64 1)
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ptr = select i1 %0, i8* getelementptr ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* getelementptr ([7 x i8], [7 x i8]* @s6, i64 0, i64 0)
+ %ptr = select i1 %C, i8* getelementptr ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* getelementptr ([7 x i8], [7 x i8]* @s6, i64 0, i64 0)
%len = call i64 @strnlen(i8* %ptr, i64 1)
ret i64 %len
}
-; Fold strnlen (%0 ? s3 : s5, 3) to 3.
+; Fold strnlen (C ? s3 : s5, 3) to 3.
-define i64 @fold_strnlen_s3_s5_3(i1 %0) {
+define i64 @fold_strnlen_s3_s5_3(i1 %C) {
; CHECK-LABEL: @fold_strnlen_s3_s5_3(
-; CHECK-NEXT: [[PTR:%.*]] = select i1 [[TMP0:%.*]], i8* getelementptr inbounds ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @s6, i64 0, i64 0)
+; CHECK-NEXT: [[PTR:%.*]] = select i1 [[C:%.*]], i8* getelementptr inbounds ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @s6, i64 0, i64 0)
; CHECK-NEXT: [[LEN:%.*]] = call i64 @strnlen(i8* [[PTR]], i64 3)
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ptr = select i1 %0, i8* getelementptr ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* getelementptr ([7 x i8], [7 x i8]* @s6, i64 0, i64 0)
+ %ptr = select i1 %C, i8* getelementptr ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* getelementptr ([7 x i8], [7 x i8]* @s6, i64 0, i64 0)
%len = call i64 @strnlen(i8* %ptr, i64 3)
ret i64 %len
}
-; Fold strnlen (%0 ? s3 : s5, 4) to %0 ? 3 : 4.
+; Fold strnlen (C ? s3 : s5, 4) to C ? 3 : 4.
-define i64 @fold_strnlen_s3_s5_4(i1 %0) {
+define i64 @fold_strnlen_s3_s5_4(i1 %C) {
; CHECK-LABEL: @fold_strnlen_s3_s5_4(
-; CHECK-NEXT: [[PTR:%.*]] = select i1 [[TMP0:%.*]], i8* getelementptr inbounds ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @s6, i64 0, i64 0)
+; CHECK-NEXT: [[PTR:%.*]] = select i1 [[C:%.*]], i8* getelementptr inbounds ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @s6, i64 0, i64 0)
; CHECK-NEXT: [[LEN:%.*]] = call i64 @strnlen(i8* [[PTR]], i64 4)
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ptr = select i1 %0, i8* getelementptr ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* getelementptr ([7 x i8], [7 x i8]* @s6, i64 0, i64 0)
+ %ptr = select i1 %C, i8* getelementptr ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* getelementptr ([7 x i8], [7 x i8]* @s6, i64 0, i64 0)
%len = call i64 @strnlen(i8* %ptr, i64 4)
ret i64 %len
}
-; Fold strnlen (%0 ? s3 : s5, 5) to %0 ? 3 : 5.
+; Fold strnlen (C ? s3 : s5, 5) to C ? 3 : 5.
-define i64 @fold_strnlen_s3_s5_5(i1 %0) {
+define i64 @fold_strnlen_s3_s5_5(i1 %C) {
; CHECK-LABEL: @fold_strnlen_s3_s5_5(
-; CHECK-NEXT: [[PTR:%.*]] = select i1 [[TMP0:%.*]], i8* getelementptr inbounds ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @s6, i64 0, i64 0)
+; CHECK-NEXT: [[PTR:%.*]] = select i1 [[C:%.*]], i8* getelementptr inbounds ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @s6, i64 0, i64 0)
; CHECK-NEXT: [[LEN:%.*]] = call i64 @strnlen(i8* [[PTR]], i64 5)
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ptr = select i1 %0, i8* getelementptr ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* getelementptr ([7 x i8], [7 x i8]* @s6, i64 0, i64 0)
+ %ptr = select i1 %C, i8* getelementptr ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* getelementptr ([7 x i8], [7 x i8]* @s6, i64 0, i64 0)
%len = call i64 @strnlen(i8* %ptr, i64 5)
ret i64 %len
}
-; Fold strnlen (%0 ? s3 : s5, 6) to %0 ? 3 : 5.
+; Fold strnlen (C ? s3 : s5, 6) to C ? 3 : 5.
-define i64 @fold_strnlen_s5_6(i1 %0) {
+define i64 @fold_strnlen_s5_6(i1 %C) {
; CHECK-LABEL: @fold_strnlen_s5_6(
-; CHECK-NEXT: [[PTR:%.*]] = select i1 [[TMP0:%.*]], i8* getelementptr inbounds ([6 x i8], [6 x i8]* @s5, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @s6, i64 0, i64 0)
+; CHECK-NEXT: [[PTR:%.*]] = select i1 [[C:%.*]], i8* getelementptr inbounds ([6 x i8], [6 x i8]* @s5, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @s6, i64 0, i64 0)
; CHECK-NEXT: [[LEN:%.*]] = call i64 @strnlen(i8* [[PTR]], i64 6)
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ptr = select i1 %0, i8* getelementptr ([6 x i8], [6 x i8]* @s5, i64 0, i64 0), i8* getelementptr ([7 x i8], [7 x i8]* @s6, i64 0, i64 0)
+ %ptr = select i1 %C, i8* getelementptr ([6 x i8], [6 x i8]* @s5, i64 0, i64 0), i8* getelementptr ([7 x i8], [7 x i8]* @s6, i64 0, i64 0)
%len = call i64 @strnlen(i8* %ptr, i64 6)
ret i64 %len
@@ -107,22 +107,22 @@ define i64 @fold_strnlen_s5_6(i1 %0) {
; Fold strnlen(E, N) with E being two conditional expressions:
; strlen (x == 3 ? s3 : x == 5 ? s5 : s7, 4) to x == 3 ? 3 : 4.
-define i64 @fold_strnlen_s3_s5_s7_4(i32 %0) {
+define i64 @fold_strnlen_s3_s5_s7_4(i32 %X) {
; CHECK-LABEL: @fold_strnlen_s3_s5_s7_4(
-; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP0:%.*]], 3
-; CHECK-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP0]], 5
-; CHECK-NEXT: [[TMP4:%.*]] = select i1 [[TMP3]], i8* getelementptr inbounds ([6 x i8], [6 x i8]* @s5, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @s7, i64 0, i64 0)
-; CHECK-NEXT: [[TMP5:%.*]] = select i1 [[TMP2]], i8* getelementptr inbounds ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* [[TMP4]]
-; CHECK-NEXT: [[TMP6:%.*]] = tail call i64 @strnlen(i8* [[TMP5]], i64 4)
-; CHECK-NEXT: ret i64 [[TMP6]]
+; CHECK-NEXT: [[X_EQ_3:%.*]] = icmp eq i32 [[X:%.*]], 3
+; CHECK-NEXT: [[X_EQ_5:%.*]] = icmp eq i32 [[X]], 5
+; CHECK-NEXT: [[SEL_X_EQ_5:%.*]] = select i1 [[X_EQ_5]], i8* getelementptr inbounds ([6 x i8], [6 x i8]* @s5, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @s7, i64 0, i64 0)
+; CHECK-NEXT: [[SEL_X_EQ_3:%.*]] = select i1 [[X_EQ_3]], i8* getelementptr inbounds ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* [[SEL_X_EQ_5]]
+; CHECK-NEXT: [[LEN:%.*]] = tail call i64 @strnlen(i8* [[SEL_X_EQ_3]], i64 4)
+; CHECK-NEXT: ret i64 [[LEN]]
;
- %2 = icmp eq i32 %0, 3
- %3 = icmp eq i32 %0, 5
- %4 = select i1 %3, i8* getelementptr ([6 x i8], [6 x i8]* @s5, i64 0, i64 0), i8* getelementptr ([8 x i8], [8 x i8]* @s7, i64 0, i64 0)
- %5 = select i1 %2, i8* getelementptr ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* %4
- %6 = tail call i64 @strnlen(i8* %5, i64 4)
- ret i64 %6
+ %x_eq_3 = icmp eq i32 %X, 3
+ %x_eq_5 = icmp eq i32 %X, 5
+ %sel_x_eq_5 = select i1 %x_eq_5, i8* getelementptr ([6 x i8], [6 x i8]* @s5, i64 0, i64 0), i8* getelementptr ([8 x i8], [8 x i8]* @s7, i64 0, i64 0)
+ %sel_x_eq_3 = select i1 %x_eq_3, i8* getelementptr ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* %sel_x_eq_5
+ %len = tail call i64 @strnlen(i8* %sel_x_eq_3, i64 4)
+ ret i64 %len
}
@@ -130,22 +130,22 @@ define i64 @fold_strnlen_s3_s5_s7_4(i32 %0) {
; but with N == 6:
; strlen (x == 3 ? s3 : x == 5 ? s5 : s7, 6) to x == 3 ? 3 : x == 5 ? 5 : 6.
-define i64 @fold_strnlen_s3_s5_s7_6(i32 %0) {
+define i64 @fold_strnlen_s3_s5_s7_6(i32 %X) {
; CHECK-LABEL: @fold_strnlen_s3_s5_s7_6(
-; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP0:%.*]], 3
-; CHECK-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP0]], 5
-; CHECK-NEXT: [[TMP4:%.*]] = select i1 [[TMP3]], i8* getelementptr inbounds ([6 x i8], [6 x i8]* @s5, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @s7, i64 0, i64 0)
-; CHECK-NEXT: [[TMP5:%.*]] = select i1 [[TMP2]], i8* getelementptr inbounds ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* [[TMP4]]
-; CHECK-NEXT: [[TMP6:%.*]] = tail call i64 @strnlen(i8* [[TMP5]], i64 6)
-; CHECK-NEXT: ret i64 [[TMP6]]
+; CHECK-NEXT: [[X_EQ_3:%.*]] = icmp eq i32 [[X:%.*]], 3
+; CHECK-NEXT: [[X_EQ_5:%.*]] = icmp eq i32 [[X]], 5
+; CHECK-NEXT: [[SEL_X_EQ_5:%.*]] = select i1 [[X_EQ_5]], i8* getelementptr inbounds ([6 x i8], [6 x i8]* @s5, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @s7, i64 0, i64 0)
+; CHECK-NEXT: [[SEL_X_EQ_3:%.*]] = select i1 [[X_EQ_3]], i8* getelementptr inbounds ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* [[SEL_X_EQ_5]]
+; CHECK-NEXT: [[LEN:%.*]] = tail call i64 @strnlen(i8* [[SEL_X_EQ_3]], i64 6)
+; CHECK-NEXT: ret i64 [[LEN]]
;
- %2 = icmp eq i32 %0, 3
- %3 = icmp eq i32 %0, 5
- %4 = select i1 %3, i8* getelementptr ([6 x i8], [6 x i8]* @s5, i64 0, i64 0), i8* getelementptr ([8 x i8], [8 x i8]* @s7, i64 0, i64 0)
- %5 = select i1 %2, i8* getelementptr ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* %4
- %6 = tail call i64 @strnlen(i8* %5, i64 6)
- ret i64 %6
+ %x_eq_3 = icmp eq i32 %X, 3
+ %x_eq_5 = icmp eq i32 %X, 5
+ %sel_x_eq_5 = select i1 %x_eq_5, i8* getelementptr ([6 x i8], [6 x i8]* @s5, i64 0, i64 0), i8* getelementptr ([8 x i8], [8 x i8]* @s7, i64 0, i64 0)
+ %sel_x_eq_3 = select i1 %x_eq_3, i8* getelementptr ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* %sel_x_eq_5
+ %len = tail call i64 @strnlen(i8* %sel_x_eq_3, i64 6)
+ ret i64 %len
}
@@ -153,20 +153,20 @@ define i64 @fold_strnlen_s3_s5_s7_6(i32 %0) {
; but with N == 8:
; strlen (x == 3 ? s3 : x == 5 ? s5 : s7, 8) to x == 3 ? 3 : x == 5 ? 5 : 7.
-define i64 @fold_strnlen_s3_s5_s7_8(i32 %0) {
+define i64 @fold_strnlen_s3_s5_s7_8(i32 %X) {
; CHECK-LABEL: @fold_strnlen_s3_s5_s7_8(
-; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP0:%.*]], 3
-; CHECK-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP0]], 5
-; CHECK-NEXT: [[TMP4:%.*]] = select i1 [[TMP3]], i8* getelementptr inbounds ([6 x i8], [6 x i8]* @s5, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @s7, i64 0, i64 0)
-; CHECK-NEXT: [[TMP5:%.*]] = select i1 [[TMP2]], i8* getelementptr inbounds ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* [[TMP4]]
-; CHECK-NEXT: [[TMP6:%.*]] = tail call i64 @strnlen(i8* [[TMP5]], i64 8)
-; CHECK-NEXT: ret i64 [[TMP6]]
+; CHECK-NEXT: [[X_EQ_3:%.*]] = icmp eq i32 [[X:%.*]], 3
+; CHECK-NEXT: [[X_EQ_5:%.*]] = icmp eq i32 [[X]], 5
+; CHECK-NEXT: [[SEL_X_EQ_5:%.*]] = select i1 [[X_EQ_5]], i8* getelementptr inbounds ([6 x i8], [6 x i8]* @s5, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @s7, i64 0, i64 0)
+; CHECK-NEXT: [[SEL_X_EQ_3:%.*]] = select i1 [[X_EQ_3]], i8* getelementptr inbounds ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* [[SEL_X_EQ_5]]
+; CHECK-NEXT: [[LEN:%.*]] = tail call i64 @strnlen(i8* [[SEL_X_EQ_3]], i64 8)
+; CHECK-NEXT: ret i64 [[LEN]]
;
- %2 = icmp eq i32 %0, 3
- %3 = icmp eq i32 %0, 5
- %4 = select i1 %3, i8* getelementptr ([6 x i8], [6 x i8]* @s5, i64 0, i64 0), i8* getelementptr ([8 x i8], [8 x i8]* @s7, i64 0, i64 0)
- %5 = select i1 %2, i8* getelementptr ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* %4
- %6 = tail call i64 @strnlen(i8* %5, i64 8)
- ret i64 %6
+ %x_eq_3 = icmp eq i32 %X, 3
+ %x_eq_5 = icmp eq i32 %X, 5
+ %sel_x_eq_5 = select i1 %x_eq_5, i8* getelementptr ([6 x i8], [6 x i8]* @s5, i64 0, i64 0), i8* getelementptr ([8 x i8], [8 x i8]* @s7, i64 0, i64 0)
+ %sel_x_eq_3 = select i1 %x_eq_3, i8* getelementptr ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i8* %sel_x_eq_5
+ %len = tail call i64 @strnlen(i8* %sel_x_eq_3, i64 8)
+ ret i64 %len
}
diff --git a/llvm/test/Transforms/InstCombine/strnlen-3.ll b/llvm/test/Transforms/InstCombine/strnlen-3.ll
index 33792f426d3c3..5dc730ed044be 100644
--- a/llvm/test/Transforms/InstCombine/strnlen-3.ll
+++ b/llvm/test/Transforms/InstCombine/strnlen-3.ll
@@ -14,83 +14,83 @@ declare i64 @strnlen(i8*, i64)
@s5_3 = constant [10 x i8] c"12345\00abc\00"
-; Fold strnlen(sx + %0, 0) to 0.
+; Fold strnlen(sx + i, 0) to 0.
-define i64 @fold_strnlen_sx_pi_0(i64 %0) {
+define i64 @fold_strnlen_sx_pi_0(i64 %i) {
; CHECK-LABEL: @fold_strnlen_sx_pi_0(
; CHECK-NEXT: [[PTR:%.*]] = getelementptr [0 x i8], [0 x i8]* @sx, i64 0, i64 [[TMP0:%.*]]
; CHECK-NEXT: [[LEN:%.*]] = call i64 @strnlen(i8* [[PTR]], i64 0)
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ptr = getelementptr [0 x i8], [0 x i8]* @sx, i64 0, i64 %0
+ %ptr = getelementptr [0 x i8], [0 x i8]* @sx, i64 0, i64 %i
%len = call i64 @strnlen(i8* %ptr, i64 0)
ret i64 %len
}
-; Do not fold strnlen(sx + %0, %1).
+; Do not fold strnlen(sx + i, n).
-define i64 @call_strnlen_sx_pi_n(i64 %0, i64 %1) {
+define i64 @call_strnlen_sx_pi_n(i64 %i, i64 %n) {
; CHECK-LABEL: @call_strnlen_sx_pi_n(
; CHECK-NEXT: [[PTR:%.*]] = getelementptr inbounds [0 x i8], [0 x i8]* @sx, i64 0, i64 [[TMP0:%.*]]
; CHECK-NEXT: [[LEN:%.*]] = call i64 @strnlen(i8* nonnull [[PTR]], i64 [[TMP1:%.*]])
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ptr = getelementptr inbounds [0 x i8], [0 x i8]* @sx, i64 0, i64 %0
- %len = call i64 @strnlen(i8* %ptr, i64 %1)
+ %ptr = getelementptr inbounds [0 x i8], [0 x i8]* @sx, i64 0, i64 %i
+ %len = call i64 @strnlen(i8* %ptr, i64 %n)
ret i64 %len
}
-; Fold strnlen(a3 + %0, 2) to min(3 - %0, 2).
+; Fold strnlen(a3 + i, 2) to min(3 - i, 2).
-define i64 @call_strnlen_a3_pi_2(i64 %0) {
+define i64 @call_strnlen_a3_pi_2(i64 %i) {
; CHECK-LABEL: @call_strnlen_a3_pi_2(
; CHECK-NEXT: [[PTR:%.*]] = getelementptr inbounds [3 x i8], [3 x i8]* @a3, i64 0, i64 [[TMP0:%.*]]
; CHECK-NEXT: [[LEN:%.*]] = call i64 @strnlen(i8* nonnull [[PTR]], i64 2)
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ptr = getelementptr inbounds [3 x i8], [3 x i8]* @a3, i64 0, i64 %0
+ %ptr = getelementptr inbounds [3 x i8], [3 x i8]* @a3, i64 0, i64 %i
%len = call i64 @strnlen(i8* %ptr, i64 2)
ret i64 %len
}
-; Fold strnlen(a3 + %0, 3) to min(3 - %0, 3).
+; Fold strnlen(a3 + i, 3) to min(3 - i, 3).
-define i64 @call_strnlen_a3_pi_3(i64 %0) {
+define i64 @call_strnlen_a3_pi_3(i64 %i) {
; CHECK-LABEL: @call_strnlen_a3_pi_3(
; CHECK-NEXT: [[PTR:%.*]] = getelementptr inbounds [3 x i8], [3 x i8]* @a3, i64 0, i64 [[TMP0:%.*]]
; CHECK-NEXT: [[LEN:%.*]] = call i64 @strnlen(i8* nonnull [[PTR]], i64 3)
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ptr = getelementptr inbounds [3 x i8], [3 x i8]* @a3, i64 0, i64 %0
+ %ptr = getelementptr inbounds [3 x i8], [3 x i8]* @a3, i64 0, i64 %i
%len = call i64 @strnlen(i8* %ptr, i64 3)
ret i64 %len
}
-; Fold strnlen(s3 + %0, 0) to 0.
+; Fold strnlen(s3 + i, 0) to 0.
-define i64 @fold_strnlen_s3_pi_0(i64 %0) {
+define i64 @fold_strnlen_s3_pi_0(i64 %i) {
; CHECK-LABEL: @fold_strnlen_s3_pi_0(
; CHECK-NEXT: [[PTR:%.*]] = getelementptr inbounds [4 x i8], [4 x i8]* @s3, i64 0, i64 [[TMP0:%.*]]
; CHECK-NEXT: [[LEN:%.*]] = call i64 @strnlen(i8* nonnull [[PTR]], i64 0)
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ptr = getelementptr inbounds [4 x i8], [4 x i8]* @s3, i64 0, i64 %0
+ %ptr = getelementptr inbounds [4 x i8], [4 x i8]* @s3, i64 0, i64 %i
%len = call i64 @strnlen(i8* %ptr, i64 0)
ret i64 %len
}
-; Fold strnlen(s5 + %0, 0) to 0.
+; Fold strnlen(s5 + i, 0) to 0.
-define i64 @call_strnlen_s5_pi_0(i64 zeroext %0) {
+define i64 @call_strnlen_s5_pi_0(i64 zeroext %i) {
; CHECK-LABEL: @call_strnlen_s5_pi_0(
; CHECK-NEXT: [[LEN:%.*]] = call i64 @strnlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @s5, i64 0, i64 0), i64 0)
; CHECK-NEXT: ret i64 [[LEN]]
@@ -101,133 +101,133 @@ define i64 @call_strnlen_s5_pi_0(i64 zeroext %0) {
}
-; Fold strnlen(s5_3 + %0, 0) to 0.
+; Fold strnlen(s5_3 + i, 0) to 0.
-define i64 @fold_strnlen_s5_3_pi_0(i64 zeroext %0) {
+define i64 @fold_strnlen_s5_3_pi_0(i64 zeroext %i) {
; CHECK-LABEL: @fold_strnlen_s5_3_pi_0(
; CHECK-NEXT: [[PTR:%.*]] = getelementptr [10 x i8], [10 x i8]* @s5_3, i64 0, i64 [[TMP0:%.*]]
; CHECK-NEXT: [[LEN:%.*]] = call i64 @strnlen(i8* [[PTR]], i64 0)
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ptr = getelementptr [10 x i8], [10 x i8]* @s5_3, i32 0, i64 %0
+ %ptr = getelementptr [10 x i8], [10 x i8]* @s5_3, i32 0, i64 %i
%len = call i64 @strnlen(i8* %ptr, i64 0)
ret i64 %len
}
-; Do not fold strnlen(s5_3 + %0, %1).
+; Do not fold strnlen(s5_3 + i, n).
-define i64 @fold_strnlen_s5_3_pi_n(i64 zeroext %0, i64 %1) {
-; CHECK-LABEL: @fold_strnlen_s5_3_pi_n(
+define i64 @call_strnlen_s5_3_pi_n(i64 zeroext %i, i64 %n) {
+; CHECK-LABEL: @call_strnlen_s5_3_pi_n(
; CHECK-NEXT: [[PTR:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* @s5_3, i64 0, i64 [[TMP0:%.*]]
; CHECK-NEXT: [[LEN:%.*]] = call i64 @strnlen(i8* nonnull [[PTR]], i64 [[TMP1:%.*]])
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ptr = getelementptr inbounds [10 x i8], [10 x i8]* @s5_3, i32 0, i64 %0
- %len = call i64 @strnlen(i8* %ptr, i64 %1)
+ %ptr = getelementptr inbounds [10 x i8], [10 x i8]* @s5_3, i32 0, i64 %i
+ %len = call i64 @strnlen(i8* %ptr, i64 %n)
ret i64 %len
}
-; Fold strnlen(a3, %0) to min(sizeof(a3), %0)
+; Fold strnlen(a3, n) to min(sizeof(a3), n)
-define i64 @fold_strnlen_a3_n(i64 %0) {
+define i64 @fold_strnlen_a3_n(i64 %n) {
; CHECK-LABEL: @fold_strnlen_a3_n(
; CHECK-NEXT: [[LEN:%.*]] = call i64 @strnlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @a3, i64 0, i64 0), i64 [[TMP0:%.*]])
; CHECK-NEXT: ret i64 [[LEN]]
;
%ptr = getelementptr [3 x i8], [3 x i8]* @a3, i64 0, i64 0
- %len = call i64 @strnlen(i8* %ptr, i64 %0)
+ %len = call i64 @strnlen(i8* %ptr, i64 %n)
ret i64 %len
}
-; Fold strnlen(s3, %0) to min(strlen(s3), %0)
+; Fold strnlen(s3, n) to min(strlen(s3), n)
-define i64 @fold_strnlen_s3_n(i64 %0) {
+define i64 @fold_strnlen_s3_n(i64 %n) {
; CHECK-LABEL: @fold_strnlen_s3_n(
; CHECK-NEXT: [[LEN:%.*]] = call i64 @strnlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @s3, i64 0, i64 0), i64 [[TMP0:%.*]])
; CHECK-NEXT: ret i64 [[LEN]]
;
%ptr = getelementptr [4 x i8], [4 x i8]* @s3, i64 0, i64 0
- %len = call i64 @strnlen(i8* %ptr, i64 %0)
+ %len = call i64 @strnlen(i8* %ptr, i64 %n)
ret i64 %len
}
-; Fold strnlen(a3 + %0, 2) to min(sizeof(a3) - %0, 2)
+; Fold strnlen(a3 + i, 2) to min(sizeof(a3) - i, 2)
-define i64 @fold_strnlen_a3_pi_2(i64 %0) {
+define i64 @fold_strnlen_a3_pi_2(i64 %i) {
; CHECK-LABEL: @fold_strnlen_a3_pi_2(
; CHECK-NEXT: [[PTR:%.*]] = getelementptr inbounds [3 x i8], [3 x i8]* @a3, i64 0, i64 [[TMP0:%.*]]
; CHECK-NEXT: [[LEN:%.*]] = call i64 @strnlen(i8* nonnull [[PTR]], i64 2)
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ptr = getelementptr inbounds [3 x i8], [3 x i8]* @a3, i64 0, i64 %0
+ %ptr = getelementptr inbounds [3 x i8], [3 x i8]* @a3, i64 0, i64 %i
%len = call i64 @strnlen(i8* %ptr, i64 2)
ret i64 %len
}
-; Fold strnlen(s3 + %0, 2) to min(strlen(s3) - %0, 2)
+; Fold strnlen(s3 + i, 2) to min(strlen(s3) - i, 2)
-define i64 @fold_strnlen_s3_pi_2(i64 %0) {
+define i64 @fold_strnlen_s3_pi_2(i64 %i) {
; CHECK-LABEL: @fold_strnlen_s3_pi_2(
; CHECK-NEXT: [[PTR:%.*]] = getelementptr inbounds [4 x i8], [4 x i8]* @s3, i64 0, i64 [[TMP0:%.*]]
; CHECK-NEXT: [[LEN:%.*]] = call i64 @strnlen(i8* nonnull [[PTR]], i64 2)
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ptr = getelementptr inbounds [4 x i8], [4 x i8]* @s3, i64 0, i64 %0
+ %ptr = getelementptr inbounds [4 x i8], [4 x i8]* @s3, i64 0, i64 %i
%len = call i64 @strnlen(i8* %ptr, i64 2)
ret i64 %len
}
-; Fold strnlen(s3 + %0, 3) to min(strlen(s3) - %0, 3)
+; Fold strnlen(s3 + i, 3) to min(strlen(s3) - i, 3)
-define i64 @fold_strnlen_s3_pi_3(i64 %0) {
+define i64 @fold_strnlen_s3_pi_3(i64 %i) {
; CHECK-LABEL: @fold_strnlen_s3_pi_3(
; CHECK-NEXT: [[PTR:%.*]] = getelementptr inbounds [4 x i8], [4 x i8]* @s3, i64 0, i64 [[TMP0:%.*]]
; CHECK-NEXT: [[LEN:%.*]] = call i64 @strnlen(i8* nonnull [[PTR]], i64 3)
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ptr = getelementptr inbounds [4 x i8], [4 x i8]* @s3, i64 0, i64 %0
+ %ptr = getelementptr inbounds [4 x i8], [4 x i8]* @s3, i64 0, i64 %i
%len = call i64 @strnlen(i8* %ptr, i64 3)
ret i64 %len
}
-; Fold strnlen(s3 + %0, %1) to min(strlen(s3) - %0, %1)
+; Fold strnlen(s3 + i, n) to min(strlen(s3) - i, n)
-define i64 @fold_strnlen_s3_pi_n(i64 %0, i64 %1) {
+define i64 @fold_strnlen_s3_pi_n(i64 %i, i64 %n) {
; CHECK-LABEL: @fold_strnlen_s3_pi_n(
; CHECK-NEXT: [[PTR:%.*]] = getelementptr inbounds [4 x i8], [4 x i8]* @s3, i64 0, i64 [[TMP0:%.*]]
; CHECK-NEXT: [[LEN:%.*]] = call i64 @strnlen(i8* nonnull [[PTR]], i64 [[TMP1:%.*]])
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ptr = getelementptr inbounds [4 x i8], [4 x i8]* @s3, i64 0, i64 %0
- %len = call i64 @strnlen(i8* %ptr, i64 %1)
+ %ptr = getelementptr inbounds [4 x i8], [4 x i8]* @s3, i64 0, i64 %i
+ %len = call i64 @strnlen(i8* %ptr, i64 %n)
ret i64 %len
}
-; Do not fold strnlen(s5_3 + %0, 2). The result is in [0, 2] but there's
+; Do not fold strnlen(s5_3 + i, 2). The result is in [0, 2] but there's
; no simple way to derive its lower bound from the offset.
-define i64 @call_strnlen_s5_3_pi_2(i64 %0) {
+define i64 @call_strnlen_s5_3_pi_2(i64 %i) {
; CHECK-LABEL: @call_strnlen_s5_3_pi_2(
; CHECK-NEXT: [[PTR:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* @s5_3, i64 0, i64 [[TMP0:%.*]]
; CHECK-NEXT: [[LEN:%.*]] = call i64 @strnlen(i8* nonnull [[PTR]], i64 2)
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ptr = getelementptr inbounds [10 x i8], [10 x i8]* @s5_3, i64 0, i64 %0
+ %ptr = getelementptr inbounds [10 x i8], [10 x i8]* @s5_3, i64 0, i64 %i
%len = call i64 @strnlen(i8* %ptr, i64 2)
ret i64 %len
}
diff --git a/llvm/test/Transforms/InstCombine/strnlen-4.ll b/llvm/test/Transforms/InstCombine/strnlen-4.ll
index 96cb6cc5de37a..997fa2a77bb08 100644
--- a/llvm/test/Transforms/InstCombine/strnlen-4.ll
+++ b/llvm/test/Transforms/InstCombine/strnlen-4.ll
@@ -12,10 +12,10 @@ declare i64 @strnlen(i8*, i64)
@s5_3 = constant [10 x i8] c"12345\00abc\00"
-; Fold strnlen (%0 ? s3 + %1 : s5, %2) to min(%0 ? 3 : 5, %1) when
-; s3 + %1 is guaranteed to be within the bounds of s3.
+; Fold strnlen (C ? s3 + i : s5, %n) to min(C ? 3 : 5, i) when
+; s3 + i is guaranteed to be within the bounds of s3.
-define i64 @fold_strnlen_s3_pi_s5_n(i1 %0, i64 %1, i64 %2) {
+define i64 @fold_strnlen_s3_pi_s5_n(i1 %C, i64 %i, i64 %n) {
; CHECK-LABEL: @fold_strnlen_s3_pi_s5_n(
; CHECK-NEXT: [[PTR:%.*]] = getelementptr inbounds [4 x i8], [4 x i8]* @s3, i64 0, i64 [[TMP1:%.*]]
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[TMP0:%.*]], i8* [[PTR]], i8* getelementptr inbounds ([6 x i8], [6 x i8]* @s5, i64 0, i64 0)
@@ -23,19 +23,19 @@ define i64 @fold_strnlen_s3_pi_s5_n(i1 %0, i64 %1, i64 %2) {
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ptr = getelementptr inbounds [4 x i8], [4 x i8]* @s3, i64 0, i64 %1
- %sel = select i1 %0, i8* %ptr, i8* getelementptr ([6 x i8], [6 x i8]* @s5, i64 0, i64 0)
- %len = call i64 @strnlen(i8* %sel, i64 %2)
+ %ptr = getelementptr inbounds [4 x i8], [4 x i8]* @s3, i64 0, i64 %i
+ %sel = select i1 %C, i8* %ptr, i8* getelementptr ([6 x i8], [6 x i8]* @s5, i64 0, i64 0)
+ %len = call i64 @strnlen(i8* %sel, i64 %n)
ret i64 %len
}
-; Do not fold the same expression as above when s3 + %i is not guaranteed
+; Do not fold the same expression as above when s3 + i is not guaranteed
; to be within the bounds of s3. Also verify that the call is not marked
; noundef, nonnull, or dereferenceable because a zero bound implies no
; access.
-define i64 @call_strnlen_s3_pi_xbounds_s5_n(i1 %0, i64 %1, i64 %2) {
+define i64 @call_strnlen_s3_pi_xbounds_s5_n(i1 %C, i64 %i, i64 %n) {
; CHECK-LABEL: @call_strnlen_s3_pi_xbounds_s5_n(
; CHECK-NEXT: [[PTR:%.*]] = getelementptr [4 x i8], [4 x i8]* @s3, i64 0, i64 [[TMP1:%.*]]
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[TMP0:%.*]], i8* [[PTR]], i8* getelementptr inbounds ([6 x i8], [6 x i8]* @s5, i64 0, i64 0)
@@ -43,19 +43,19 @@ define i64 @call_strnlen_s3_pi_xbounds_s5_n(i1 %0, i64 %1, i64 %2) {
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ptr = getelementptr [4 x i8], [4 x i8]* @s3, i64 0, i64 %1
- %sel = select i1 %0, i8* %ptr, i8* getelementptr ([6 x i8], [6 x i8]* @s5, i64 0, i64 0)
- %len = call i64 @strnlen(i8* %sel, i64 %2)
+ %ptr = getelementptr [4 x i8], [4 x i8]* @s3, i64 0, i64 %i
+ %sel = select i1 %C, i8* %ptr, i8* getelementptr ([6 x i8], [6 x i8]* @s5, i64 0, i64 0)
+ %len = call i64 @strnlen(i8* %sel, i64 %n)
ret i64 %len
}
-; Do not fold strnlen(%0 ? s3 + %1 : sx, %1) when sx's length and size
+; Do not fold strnlen(C ? s3 + i : sx, n) when sx's length and size
; are unknown. This also verifies that the folder cleans up the IR after
; successfully folding the first subexpression IR when folding the second
; subexpression fails.
-define i64 @call_strnlen_s3_pi_sx_n(i1 %0, i64 %1, i64 %2) {
+define i64 @call_strnlen_s3_pi_sx_n(i1 %C, i64 %i, i64 %n) {
; CHECK-LABEL: @call_strnlen_s3_pi_sx_n(
; CHECK-NEXT: [[PTR:%.*]] = getelementptr inbounds [4 x i8], [4 x i8]* @s3, i64 0, i64 [[TMP1:%.*]]
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[TMP0:%.*]], i8* [[PTR]], i8* getelementptr inbounds ([0 x i8], [0 x i8]* @sx, i64 0, i64 0)
@@ -63,23 +63,23 @@ define i64 @call_strnlen_s3_pi_sx_n(i1 %0, i64 %1, i64 %2) {
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ptr = getelementptr inbounds [4 x i8], [4 x i8]* @s3, i64 0, i64 %1
- %sel = select i1 %0, i8* %ptr, i8* getelementptr ([0 x i8], [0 x i8]* @sx, i64 0, i64 0)
- %len = call i64 @strnlen(i8* %sel, i64 %2)
+ %ptr = getelementptr inbounds [4 x i8], [4 x i8]* @s3, i64 0, i64 %i
+ %sel = select i1 %C, i8* %ptr, i8* getelementptr ([0 x i8], [0 x i8]* @sx, i64 0, i64 0)
+ %len = call i64 @strnlen(i8* %sel, i64 %n)
ret i64 %len
}
-; Fold strnlen (%0 ? s3 : s5 + %1, %2) to min(%0 ? 3 : 5, %1).
+; Fold strnlen (C ? s3 : s5 + i, n) to min(C ? 3 : 5, i).
-define i64 @fold_strnlen_s3_s5_pi_n(i1 %0, i64 %1, i64 %2) {
+define i64 @fold_strnlen_s3_s5_pi_n(i1 %C, i64 %i, i64 %n) {
; CHECK-LABEL: @fold_strnlen_s3_s5_pi_n(
; CHECK-NEXT: [[PTR:%.*]] = select i1 [[TMP0:%.*]], i8* getelementptr inbounds ([6 x i8], [6 x i8]* @s5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @s3, i64 0, i64 0)
; CHECK-NEXT: [[LEN:%.*]] = call i64 @strnlen(i8* [[PTR]], i64 [[TMP1:%.*]])
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ptr = select i1 %0, i8* getelementptr ([6 x i8], [6 x i8]* @s5, i64 0, i64 0), i8* getelementptr ([4 x i8], [4 x i8]* @s3, i64 0, i64 0)
- %len = call i64 @strnlen(i8* %ptr, i64 %1)
+ %ptr = select i1 %C, i8* getelementptr ([6 x i8], [6 x i8]* @s5, i64 0, i64 0), i8* getelementptr ([4 x i8], [4 x i8]* @s3, i64 0, i64 0)
+ %len = call i64 @strnlen(i8* %ptr, i64 %i)
ret i64 %len
}
diff --git a/llvm/test/Transforms/InstCombine/strnlen-5.ll b/llvm/test/Transforms/InstCombine/strnlen-5.ll
index 9887d2916023c..96281faf15831 100644
--- a/llvm/test/Transforms/InstCombine/strnlen-5.ll
+++ b/llvm/test/Transforms/InstCombine/strnlen-5.ll
@@ -91,9 +91,9 @@ define i1 @fold_strnlen_ax_9_eqz() {
}
-; Do not fold strnlen(ax, %0) == 0 for %0 that might be zero.
+; Do not fold strnlen(ax, n) == 0 for n that might be zero.
-define i1 @call_strnlen_ax_n_eqz(i64 %0) {
+define i1 @call_strnlen_ax_n_eqz(i64 %n) {
; CHECK-LABEL: @call_strnlen_ax_n_eqz(
; CHECK-NEXT: [[LEN:%.*]] = tail call i64 @strnlen(i8* getelementptr inbounds ([0 x i8], [0 x i8]* @ax, i64 0, i64 0), i64 [[TMP0:%.*]])
; CHECK-NEXT: [[EQZ:%.*]] = icmp eq i64 [[LEN]], 0
@@ -101,15 +101,15 @@ define i1 @call_strnlen_ax_n_eqz(i64 %0) {
;
%ptr = getelementptr [0 x i8], [0 x i8]* @ax, i64 0, i64 0
- %len = tail call i64 @strnlen(i8* %ptr, i64 %0)
+ %len = tail call i64 @strnlen(i8* %ptr, i64 %n)
%eqz = icmp eq i64 %len, 0
ret i1 %eqz
}
-; Fold strnlen(ax, %0) == 0 to *ax == 0 for %0 that's not zero.
+; Fold strnlen(ax, n) == 0 to *ax == 0 for %0 that's not zero.
-define i1 @fold_strnlen_ax_nz_eqz(i64 %0) {
+define i1 @fold_strnlen_ax_nz_eqz(i64 %n) {
; CHECK-LABEL: @fold_strnlen_ax_nz_eqz(
; CHECK-NEXT: [[MAX:%.*]] = or i64 [[TMP0:%.*]], 1
; CHECK-NEXT: [[LEN:%.*]] = tail call i64 @strnlen(i8* getelementptr inbounds ([0 x i8], [0 x i8]* @ax, i64 0, i64 0), i64 [[MAX]])
@@ -117,7 +117,7 @@ define i1 @fold_strnlen_ax_nz_eqz(i64 %0) {
; CHECK-NEXT: ret i1 [[EQZ]]
;
- %max = or i64 %0, 1
+ %max = or i64 %n, 1
%ptr = getelementptr [0 x i8], [0 x i8]* @ax, i64 0, i64 0
%len = tail call i64 @strnlen(i8* %ptr, i64 %max)
%eqz = icmp eq i64 %len, 0
@@ -125,9 +125,9 @@ define i1 @fold_strnlen_ax_nz_eqz(i64 %0) {
}
-; Fold strnlen(ax, %0) > 0 to *ax != 0 for %0 that's not zero.
+; Fold strnlen(ax, n) > 0 to *ax != 0 for n that's not zero.
-define i1 @fold_strnlen_ax_nz_gtz(i64 %0) {
+define i1 @fold_strnlen_ax_nz_gtz(i64 %n) {
; CHECK-LABEL: @fold_strnlen_ax_nz_gtz(
; CHECK-NEXT: [[MAX:%.*]] = or i64 [[TMP0:%.*]], 1
; CHECK-NEXT: [[LEN:%.*]] = tail call i64 @strnlen(i8* getelementptr inbounds ([0 x i8], [0 x i8]* @ax, i64 0, i64 0), i64 [[MAX]])
@@ -135,7 +135,7 @@ define i1 @fold_strnlen_ax_nz_gtz(i64 %0) {
; CHECK-NEXT: ret i1 [[GTZ]]
;
- %max = or i64 %0, 1
+ %max = or i64 %n, 1
%ptr = getelementptr [0 x i8], [0 x i8]* @ax, i64 0, i64 0
%len = tail call i64 @strnlen(i8* %ptr, i64 %max)
%gtz = icmp ugt i64 %len, 0
@@ -143,10 +143,10 @@ define i1 @fold_strnlen_ax_nz_gtz(i64 %0) {
}
-; Fold strnlen(a5 + %0, %1) == 0 to a5[%0] == 0 for a nonconstant a5
-; and a nonzero %1.
+; Fold strnlen(a5 + i, n) == 0 to a5[i] == 0 for a nonconstant a5
+; and a nonzero n.
-define i1 @fold_strnlen_a5_pi_nz_eqz(i64 %0, i64 %1) {
+define i1 @fold_strnlen_a5_pi_nz_eqz(i64 %i, i64 %n) {
; CHECK-LABEL: @fold_strnlen_a5_pi_nz_eqz(
; CHECK-NEXT: [[NZ:%.*]] = or i64 [[TMP1:%.*]], 1
; CHECK-NEXT: [[PTR:%.*]] = getelementptr inbounds [5 x i8], [5 x i8]* @a5, i64 0, i64 [[TMP0:%.*]]
@@ -155,19 +155,19 @@ define i1 @fold_strnlen_a5_pi_nz_eqz(i64 %0, i64 %1) {
; CHECK-NEXT: ret i1 [[EQZ]]
;
- %nz = or i64 %1, 1
- %ptr = getelementptr inbounds [5 x i8], [5 x i8]* @a5, i64 0, i64 %0
- %len = call i64 @strnlen(i8* nonnull %ptr, i64 %nz)
+ %nz = or i64 %n, 1
+ %ptr = getelementptr inbounds [5 x i8], [5 x i8]* @a5, i64 0, i64 %i
+ %len = call i64 @strnlen(i8* %ptr, i64 %nz)
%eqz = icmp eq i64 %len, 0
ret i1 %eqz
}
-; Fold strnlen(s5 + %0, %1) == 0 for a constant s5 and nonzero %1.
-; This is first folded to s5[%0] == 0 like the above and then finally
+; Fold strnlen(s5 + i, n) == 0 for a constant s5 and nonzero n.
+; This is first folded to s5[i] == 0 like the above and then finally
; to %0 == 5.
-define i1 @fold_strnlen_s5_pi_nz_eqz(i64 %0, i64 %1) {
+define i1 @fold_strnlen_s5_pi_nz_eqz(i64 %i, i64 %n) {
; CHECK-LABEL: @fold_strnlen_s5_pi_nz_eqz(
; CHECK-NEXT: [[TMP3:%.*]] = or i64 [[TMP1:%.*]], 1
; CHECK-NEXT: [[TMP4:%.*]] = getelementptr inbounds [6 x i8], [6 x i8]* @s5, i64 0, i64 [[TMP0:%.*]]
@@ -176,17 +176,17 @@ define i1 @fold_strnlen_s5_pi_nz_eqz(i64 %0, i64 %1) {
; CHECK-NEXT: ret i1 [[TMP6]]
;
- %3 = or i64 %1, 1
- %4 = getelementptr inbounds [6 x i8], [6 x i8]* @s5, i64 0, i64 %0
- %5 = call i64 @strnlen(i8* nonnull %4, i64 %3)
- %6 = icmp eq i64 %5, 0
- ret i1 %6
+ %nz = or i64 %n, 1
+ %ptr = getelementptr inbounds [6 x i8], [6 x i8]* @s5, i64 0, i64 %i
+ %len = call i64 @strnlen(i8* %ptr, i64 %nz)
+ %eqz = icmp eq i64 %len, 0
+ ret i1 %eqz
}
-; Do not fold strnlen(s5 + %0, %1) for a constant s5 when %1 might be zero.
+; Do not fold strnlen(s5 + i, n) for a constant s5 when n might be zero.
-define i1 @call_strnlen_s5_pi_n_eqz(i64 %0, i64 %1) {
+define i1 @call_strnlen_s5_pi_n_eqz(i64 %i, i64 %n) {
; CHECK-LABEL: @call_strnlen_s5_pi_n_eqz(
; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds [6 x i8], [6 x i8]* @s5, i64 0, i64 [[TMP0:%.*]]
; CHECK-NEXT: [[TMP4:%.*]] = call i64 @strnlen(i8* nonnull [[TMP3]], i64 [[TMP1:%.*]])
@@ -194,8 +194,8 @@ define i1 @call_strnlen_s5_pi_n_eqz(i64 %0, i64 %1) {
; CHECK-NEXT: ret i1 [[TMP5]]
;
- %3 = getelementptr inbounds [6 x i8], [6 x i8]* @s5, i64 0, i64 %0
- %4 = call i64 @strnlen(i8* nonnull %3, i64 %1)
- %5 = icmp eq i64 %4, 0
- ret i1 %5
+ %ptr = getelementptr inbounds [6 x i8], [6 x i8]* @s5, i64 0, i64 %i
+ %len = call i64 @strnlen(i8* %ptr, i64 %n)
+ %eqz = icmp eq i64 %len, 0
+ ret i1 %eqz
}
More information about the llvm-commits
mailing list