[llvm] cbbf1eb - [test][InstCombine] Use opaque pointers in wcslen test cases. NFC
Bjorn Pettersson via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 6 07:44:36 PDT 2022
Author: Bjorn Pettersson
Date: 2022-10-06T16:43:59+02:00
New Revision: cbbf1ebb7027940d5aa78646d2ff644c7e864983
URL: https://github.com/llvm/llvm-project/commit/cbbf1ebb7027940d5aa78646d2ff644c7e864983
DIFF: https://github.com/llvm/llvm-project/commit/cbbf1ebb7027940d5aa78646d2ff644c7e864983.diff
LOG: [test][InstCombine] Use opaque pointers in wcslen test cases. NFC
Added:
Modified:
llvm/test/Transforms/InstCombine/wcslen-1.ll
llvm/test/Transforms/InstCombine/wcslen-3.ll
llvm/test/Transforms/InstCombine/wcslen-4.ll
llvm/test/Transforms/InstCombine/wcslen-5.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/wcslen-1.ll b/llvm/test/Transforms/InstCombine/wcslen-1.ll
index 6e37652841ff0..3af60a1cd5723 100644
--- a/llvm/test/Transforms/InstCombine/wcslen-1.ll
+++ b/llvm/test/Transforms/InstCombine/wcslen-1.ll
@@ -5,7 +5,7 @@
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
-declare i64 @wcslen(i32*)
+declare i64 @wcslen(ptr)
!0 = !{i32 1, !"wchar_size", i32 4}
!llvm.module.flags = !{!0}
@@ -22,8 +22,7 @@ define i64 @test_simplify1() {
; CHECK-LABEL: @test_simplify1(
; CHECK-NEXT: ret i64 5
;
- %hello_p = getelementptr [6 x i32], [6 x i32]* @hello, i64 0, i64 0
- %hello_l = call i64 @wcslen(i32* %hello_p)
+ %hello_l = call i64 @wcslen(ptr @hello)
ret i64 %hello_l
}
@@ -31,8 +30,7 @@ define i64 @test_simplify2() {
; CHECK-LABEL: @test_simplify2(
; CHECK-NEXT: ret i64 0
;
- %null_p = getelementptr [1 x i32], [1 x i32]* @null, i64 0, i64 0
- %null_l = call i64 @wcslen(i32* %null_p)
+ %null_l = call i64 @wcslen(ptr @null)
ret i64 %null_l
}
@@ -40,8 +38,7 @@ define i64 @test_simplify3() {
; CHECK-LABEL: @test_simplify3(
; CHECK-NEXT: ret i64 0
;
- %null_hello_p = getelementptr [7 x i32], [7 x i32]* @null_hello, i64 0, i64 0
- %null_hello_l = call i64 @wcslen(i32* %null_hello_p)
+ %null_hello_l = call i64 @wcslen(ptr @null_hello)
ret i64 %null_hello_l
}
@@ -49,7 +46,7 @@ define i64 @test_simplify4() {
; CHECK-LABEL: @test_simplify4(
; CHECK-NEXT: ret i64 0
;
- %len = tail call i64 @wcslen(i32* @nullstring) nounwind
+ %len = tail call i64 @wcslen(ptr @nullstring) nounwind
ret i64 %len
}
@@ -59,19 +56,18 @@ define i1 @test_simplify5() {
; CHECK-LABEL: @test_simplify5(
; CHECK-NEXT: ret i1 false
;
- %hello_p = getelementptr [6 x i32], [6 x i32]* @hello, i64 0, i64 0
- %hello_l = call i64 @wcslen(i32* %hello_p)
+ %hello_l = call i64 @wcslen(ptr @hello)
%eq_hello = icmp eq i64 %hello_l, 0
ret i1 %eq_hello
}
-define i1 @test_simplify6(i32* %str_p) {
+define i1 @test_simplify6(ptr %str_p) {
; CHECK-LABEL: @test_simplify6(
-; CHECK-NEXT: [[CHAR0:%.*]] = load i32, i32* [[STR_P:%.*]], align 4
+; CHECK-NEXT: [[CHAR0:%.*]] = load i32, ptr [[STR_P:%.*]], align 4
; CHECK-NEXT: [[EQ_NULL:%.*]] = icmp eq i32 [[CHAR0]], 0
; CHECK-NEXT: ret i1 [[EQ_NULL]]
;
- %str_l = call i64 @wcslen(i32* %str_p)
+ %str_l = call i64 @wcslen(ptr %str_p)
%eq_null = icmp eq i64 %str_l, 0
ret i1 %eq_null
}
@@ -82,19 +78,18 @@ define i1 @test_simplify7() {
; CHECK-LABEL: @test_simplify7(
; CHECK-NEXT: ret i1 true
;
- %hello_p = getelementptr [6 x i32], [6 x i32]* @hello, i64 0, i64 0
- %hello_l = call i64 @wcslen(i32* %hello_p)
+ %hello_l = call i64 @wcslen(ptr @hello)
%ne_hello = icmp ne i64 %hello_l, 0
ret i1 %ne_hello
}
-define i1 @test_simplify8(i32* %str_p) {
+define i1 @test_simplify8(ptr %str_p) {
; CHECK-LABEL: @test_simplify8(
-; CHECK-NEXT: [[CHAR0:%.*]] = load i32, i32* [[STR_P:%.*]], align 4
+; CHECK-NEXT: [[CHAR0:%.*]] = load i32, ptr [[STR_P:%.*]], align 4
; CHECK-NEXT: [[NE_NULL:%.*]] = icmp ne i32 [[CHAR0]], 0
; CHECK-NEXT: ret i1 [[NE_NULL]]
;
- %str_l = call i64 @wcslen(i32* %str_p)
+ %str_l = call i64 @wcslen(ptr %str_p)
%ne_null = icmp ne i64 %str_l, 0
ret i1 %ne_null
}
@@ -104,10 +99,8 @@ define i64 @test_simplify9(i1 %x) {
; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[X:%.*]], i64 5, i64 6
; CHECK-NEXT: ret i64 [[TMP1]]
;
- %hello = getelementptr [6 x i32], [6 x i32]* @hello, i64 0, i64 0
- %longer = getelementptr [7 x i32], [7 x i32]* @longer, i64 0, i64 0
- %s = select i1 %x, i32* %hello, i32* %longer
- %l = call i64 @wcslen(i32* %s)
+ %s = select i1 %x, ptr @hello, ptr @longer
+ %l = call i64 @wcslen(ptr %s)
ret i64 %l
}
@@ -120,8 +113,8 @@ define i64 @test_simplify10(i32 %x) {
; CHECK-NEXT: [[TMP2:%.*]] = sub nsw i64 5, [[TMP1]]
; CHECK-NEXT: ret i64 [[TMP2]]
;
- %hello_p = getelementptr inbounds [6 x i32], [6 x i32]* @hello, i32 0, i32 %x
- %hello_l = call i64 @wcslen(i32* %hello_p)
+ %hello_p = getelementptr inbounds [6 x i32], ptr @hello, i32 0, i32 %x
+ %hello_l = call i64 @wcslen(ptr %hello_p)
ret i64 %hello_l
}
@@ -135,8 +128,8 @@ define i64 @test_simplify11(i32 %x) {
; CHECK-NEXT: ret i64 [[TMP1]]
;
%and = and i32 %x, 7
- %hello_p = getelementptr inbounds [13 x i32], [13 x i32]* @null_hello_mid, i32 0, i32 %and
- %hello_l = call i64 @wcslen(i32* %hello_p)
+ %hello_p = getelementptr inbounds [13 x i32], ptr @null_hello_mid, i32 0, i32 %and
+ %hello_l = call i64 @wcslen(ptr %hello_p)
ret i64 %hello_l
}
@@ -144,11 +137,10 @@ define i64 @test_simplify11(i32 %x) {
define i64 @test_no_simplify1() {
; CHECK-LABEL: @test_no_simplify1(
-; CHECK-NEXT: [[A_L:%.*]] = call i64 @wcslen(i32* nonnull getelementptr inbounds ([32 x i32], [32 x i32]* @a, i64 0, i64 0))
+; CHECK-NEXT: [[A_L:%.*]] = call i64 @wcslen(ptr nonnull @a)
; CHECK-NEXT: ret i64 [[A_L]]
;
- %a_p = getelementptr [32 x i32], [32 x i32]* @a, i64 0, i64 0
- %a_l = call i64 @wcslen(i32* %a_p)
+ %a_l = call i64 @wcslen(ptr @a)
ret i64 %a_l
}
@@ -157,24 +149,24 @@ define i64 @test_no_simplify1() {
define i64 @test_no_simplify2(i32 %x) {
; CHECK-LABEL: @test_no_simplify2(
; CHECK-NEXT: [[TMP1:%.*]] = sext i32 [[X:%.*]] to i64
-; CHECK-NEXT: [[HELLO_P:%.*]] = getelementptr inbounds [7 x i32], [7 x i32]* @null_hello, i64 0, i64 [[TMP1]]
-; CHECK-NEXT: [[HELLO_L:%.*]] = call i64 @wcslen(i32* nonnull [[HELLO_P]])
+; CHECK-NEXT: [[HELLO_P:%.*]] = getelementptr inbounds [7 x i32], ptr @null_hello, i64 0, i64 [[TMP1]]
+; CHECK-NEXT: [[HELLO_L:%.*]] = call i64 @wcslen(ptr nonnull [[HELLO_P]])
; CHECK-NEXT: ret i64 [[HELLO_L]]
;
- %hello_p = getelementptr inbounds [7 x i32], [7 x i32]* @null_hello, i32 0, i32 %x
- %hello_l = call i64 @wcslen(i32* %hello_p)
+ %hello_p = getelementptr inbounds [7 x i32], ptr @null_hello, i32 0, i32 %x
+ %hello_l = call i64 @wcslen(ptr %hello_p)
ret i64 %hello_l
}
define i64 @test_no_simplify2_no_null_opt(i32 %x) #0 {
; CHECK-LABEL: @test_no_simplify2_no_null_opt(
; CHECK-NEXT: [[TMP1:%.*]] = sext i32 [[X:%.*]] to i64
-; CHECK-NEXT: [[HELLO_P:%.*]] = getelementptr inbounds [7 x i32], [7 x i32]* @null_hello, i64 0, i64 [[TMP1]]
-; CHECK-NEXT: [[HELLO_L:%.*]] = call i64 @wcslen(i32* [[HELLO_P]])
+; CHECK-NEXT: [[HELLO_P:%.*]] = getelementptr inbounds [7 x i32], ptr @null_hello, i64 0, i64 [[TMP1]]
+; CHECK-NEXT: [[HELLO_L:%.*]] = call i64 @wcslen(ptr [[HELLO_P]])
; CHECK-NEXT: ret i64 [[HELLO_L]]
;
- %hello_p = getelementptr inbounds [7 x i32], [7 x i32]* @null_hello, i32 0, i32 %x
- %hello_l = call i64 @wcslen(i32* %hello_p)
+ %hello_p = getelementptr inbounds [7 x i32], ptr @null_hello, i32 0, i32 %x
+ %hello_l = call i64 @wcslen(ptr %hello_p)
ret i64 %hello_l
}
@@ -184,13 +176,13 @@ define i64 @test_no_simplify3(i32 %x) {
; CHECK-LABEL: @test_no_simplify3(
; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 15
; CHECK-NEXT: [[TMP1:%.*]] = zext i32 [[AND]] to i64
-; CHECK-NEXT: [[HELLO_P:%.*]] = getelementptr inbounds [13 x i32], [13 x i32]* @null_hello_mid, i64 0, i64 [[TMP1]]
-; CHECK-NEXT: [[HELLO_L:%.*]] = call i64 @wcslen(i32* nonnull [[HELLO_P]])
+; CHECK-NEXT: [[HELLO_P:%.*]] = getelementptr inbounds [13 x i32], ptr @null_hello_mid, i64 0, i64 [[TMP1]]
+; CHECK-NEXT: [[HELLO_L:%.*]] = call i64 @wcslen(ptr nonnull [[HELLO_P]])
; CHECK-NEXT: ret i64 [[HELLO_L]]
;
%and = and i32 %x, 15
- %hello_p = getelementptr inbounds [13 x i32], [13 x i32]* @null_hello_mid, i32 0, i32 %and
- %hello_l = call i64 @wcslen(i32* %hello_p)
+ %hello_p = getelementptr inbounds [13 x i32], ptr @null_hello_mid, i32 0, i32 %and
+ %hello_l = call i64 @wcslen(ptr %hello_p)
ret i64 %hello_l
}
@@ -198,13 +190,13 @@ define i64 @test_no_simplify3_no_null_opt(i32 %x) #0 {
; CHECK-LABEL: @test_no_simplify3_no_null_opt(
; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 15
; CHECK-NEXT: [[TMP1:%.*]] = zext i32 [[AND]] to i64
-; CHECK-NEXT: [[HELLO_P:%.*]] = getelementptr inbounds [13 x i32], [13 x i32]* @null_hello_mid, i64 0, i64 [[TMP1]]
-; CHECK-NEXT: [[HELLO_L:%.*]] = call i64 @wcslen(i32* [[HELLO_P]])
+; CHECK-NEXT: [[HELLO_P:%.*]] = getelementptr inbounds [13 x i32], ptr @null_hello_mid, i64 0, i64 [[TMP1]]
+; CHECK-NEXT: [[HELLO_L:%.*]] = call i64 @wcslen(ptr [[HELLO_P]])
; CHECK-NEXT: ret i64 [[HELLO_L]]
;
%and = and i32 %x, 15
- %hello_p = getelementptr inbounds [13 x i32], [13 x i32]* @null_hello_mid, i32 0, i32 %and
- %hello_l = call i64 @wcslen(i32* %hello_p)
+ %hello_p = getelementptr inbounds [13 x i32], ptr @null_hello_mid, i32 0, i32 %and
+ %hello_l = call i64 @wcslen(ptr %hello_p)
ret i64 %hello_l
}
@@ -218,7 +210,7 @@ define i64 @test_simplify12() {
; CHECK-LABEL: @test_simplify12(
; CHECK-NEXT: ret i64 0
;
- %l = call i64 @wcslen(i32* bitcast ([1 x i16]* @str16 to i32*))
+ %l = call i64 @wcslen(ptr @str16)
ret i64 %l
}
diff --git a/llvm/test/Transforms/InstCombine/wcslen-3.ll b/llvm/test/Transforms/InstCombine/wcslen-3.ll
index 15883d4cae821..26252cd3bd885 100644
--- a/llvm/test/Transforms/InstCombine/wcslen-3.ll
+++ b/llvm/test/Transforms/InstCombine/wcslen-3.ll
@@ -9,7 +9,7 @@ target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
!llvm.module.flags = !{!0}
!0 = !{i32 1, !"wchar_size", i32 2}
-declare i64 @wcslen(i16*)
+declare i64 @wcslen(ptr)
@hello = constant [6 x i16] [i16 104, i16 101, i16 108, i16 108, i16 111, i16 0]
@longer = constant [7 x i16] [i16 108, i16 111, i16 110, i16 103, i16 101, i16 114, i16 0]
@@ -23,8 +23,7 @@ define i64 @test_simplify1() {
; CHECK-LABEL: @test_simplify1(
; CHECK-NEXT: ret i64 5
;
- %hello_p = getelementptr [6 x i16], [6 x i16]* @hello, i64 0, i64 0
- %hello_l = call i64 @wcslen(i16* %hello_p)
+ %hello_l = call i64 @wcslen(ptr @hello)
ret i64 %hello_l
}
@@ -32,8 +31,7 @@ define i64 @test_simplify2() {
; CHECK-LABEL: @test_simplify2(
; CHECK-NEXT: ret i64 0
;
- %null_p = getelementptr [1 x i16], [1 x i16]* @null, i64 0, i64 0
- %null_l = call i64 @wcslen(i16* %null_p)
+ %null_l = call i64 @wcslen(ptr @null)
ret i64 %null_l
}
@@ -41,8 +39,7 @@ define i64 @test_simplify3() {
; CHECK-LABEL: @test_simplify3(
; CHECK-NEXT: ret i64 0
;
- %null_hello_p = getelementptr [7 x i16], [7 x i16]* @null_hello, i64 0, i64 0
- %null_hello_l = call i64 @wcslen(i16* %null_hello_p)
+ %null_hello_l = call i64 @wcslen(ptr @null_hello)
ret i64 %null_hello_l
}
@@ -50,7 +47,7 @@ define i64 @test_simplify4() {
; CHECK-LABEL: @test_simplify4(
; CHECK-NEXT: ret i64 0
;
- %len = tail call i64 @wcslen(i16* @nullstring) nounwind
+ %len = tail call i64 @wcslen(ptr @nullstring) nounwind
ret i64 %len
}
@@ -60,19 +57,18 @@ define i1 @test_simplify5() {
; CHECK-LABEL: @test_simplify5(
; CHECK-NEXT: ret i1 false
;
- %hello_p = getelementptr [6 x i16], [6 x i16]* @hello, i64 0, i64 0
- %hello_l = call i64 @wcslen(i16* %hello_p)
+ %hello_l = call i64 @wcslen(ptr @hello)
%eq_hello = icmp eq i64 %hello_l, 0
ret i1 %eq_hello
}
-define i1 @test_simplify6(i16* %str_p) {
+define i1 @test_simplify6(ptr %str_p) {
; CHECK-LABEL: @test_simplify6(
-; CHECK-NEXT: [[CHAR0:%.*]] = load i16, i16* [[STR_P:%.*]], align 2
+; CHECK-NEXT: [[CHAR0:%.*]] = load i16, ptr [[STR_P:%.*]], align 2
; CHECK-NEXT: [[EQ_NULL:%.*]] = icmp eq i16 [[CHAR0]], 0
; CHECK-NEXT: ret i1 [[EQ_NULL]]
;
- %str_l = call i64 @wcslen(i16* %str_p)
+ %str_l = call i64 @wcslen(ptr %str_p)
%eq_null = icmp eq i64 %str_l, 0
ret i1 %eq_null
}
@@ -83,19 +79,18 @@ define i1 @test_simplify7() {
; CHECK-LABEL: @test_simplify7(
; CHECK-NEXT: ret i1 true
;
- %hello_p = getelementptr [6 x i16], [6 x i16]* @hello, i64 0, i64 0
- %hello_l = call i64 @wcslen(i16* %hello_p)
+ %hello_l = call i64 @wcslen(ptr @hello)
%ne_hello = icmp ne i64 %hello_l, 0
ret i1 %ne_hello
}
-define i1 @test_simplify8(i16* %str_p) {
+define i1 @test_simplify8(ptr %str_p) {
; CHECK-LABEL: @test_simplify8(
-; CHECK-NEXT: [[CHAR0:%.*]] = load i16, i16* [[STR_P:%.*]], align 2
+; CHECK-NEXT: [[CHAR0:%.*]] = load i16, ptr [[STR_P:%.*]], align 2
; CHECK-NEXT: [[NE_NULL:%.*]] = icmp ne i16 [[CHAR0]], 0
; CHECK-NEXT: ret i1 [[NE_NULL]]
;
- %str_l = call i64 @wcslen(i16* %str_p)
+ %str_l = call i64 @wcslen(ptr %str_p)
%ne_null = icmp ne i64 %str_l, 0
ret i1 %ne_null
}
@@ -105,10 +100,8 @@ define i64 @test_simplify9(i1 %x) {
; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[X:%.*]], i64 5, i64 6
; CHECK-NEXT: ret i64 [[TMP1]]
;
- %hello = getelementptr [6 x i16], [6 x i16]* @hello, i64 0, i64 0
- %longer = getelementptr [7 x i16], [7 x i16]* @longer, i64 0, i64 0
- %s = select i1 %x, i16* %hello, i16* %longer
- %l = call i64 @wcslen(i16* %s)
+ %s = select i1 %x, ptr @hello, ptr @longer
+ %l = call i64 @wcslen(ptr %s)
ret i64 %l
}
@@ -121,8 +114,8 @@ define i64 @test_simplify10(i16 %x) {
; CHECK-NEXT: [[TMP2:%.*]] = sub nsw i64 5, [[TMP1]]
; CHECK-NEXT: ret i64 [[TMP2]]
;
- %hello_p = getelementptr inbounds [6 x i16], [6 x i16]* @hello, i16 0, i16 %x
- %hello_l = call i64 @wcslen(i16* %hello_p)
+ %hello_p = getelementptr inbounds [6 x i16], ptr @hello, i16 0, i16 %x
+ %hello_l = call i64 @wcslen(ptr %hello_p)
ret i64 %hello_l
}
@@ -136,8 +129,8 @@ define i64 @test_simplify11(i16 %x) {
; CHECK-NEXT: ret i64 [[TMP1]]
;
%and = and i16 %x, 7
- %hello_p = getelementptr inbounds [13 x i16], [13 x i16]* @null_hello_mid, i16 0, i16 %and
- %hello_l = call i64 @wcslen(i16* %hello_p)
+ %hello_p = getelementptr inbounds [13 x i16], ptr @null_hello_mid, i16 0, i16 %and
+ %hello_l = call i64 @wcslen(ptr %hello_p)
ret i64 %hello_l
}
@@ -145,11 +138,10 @@ define i64 @test_simplify11(i16 %x) {
define i64 @test_no_simplify1() {
; CHECK-LABEL: @test_no_simplify1(
-; CHECK-NEXT: [[A_L:%.*]] = call i64 @wcslen(i16* nonnull getelementptr inbounds ([32 x i16], [32 x i16]* @a, i64 0, i64 0))
+; CHECK-NEXT: [[A_L:%.*]] = call i64 @wcslen(ptr nonnull @a)
; CHECK-NEXT: ret i64 [[A_L]]
;
- %a_p = getelementptr [32 x i16], [32 x i16]* @a, i64 0, i64 0
- %a_l = call i64 @wcslen(i16* %a_p)
+ %a_l = call i64 @wcslen(ptr @a)
ret i64 %a_l
}
@@ -158,12 +150,12 @@ define i64 @test_no_simplify1() {
define i64 @test_no_simplify2(i16 %x) {
; CHECK-LABEL: @test_no_simplify2(
; CHECK-NEXT: [[TMP1:%.*]] = sext i16 [[X:%.*]] to i64
-; CHECK-NEXT: [[HELLO_P:%.*]] = getelementptr inbounds [7 x i16], [7 x i16]* @null_hello, i64 0, i64 [[TMP1]]
-; CHECK-NEXT: [[HELLO_L:%.*]] = call i64 @wcslen(i16* nonnull [[HELLO_P]])
+; CHECK-NEXT: [[HELLO_P:%.*]] = getelementptr inbounds [7 x i16], ptr @null_hello, i64 0, i64 [[TMP1]]
+; CHECK-NEXT: [[HELLO_L:%.*]] = call i64 @wcslen(ptr nonnull [[HELLO_P]])
; CHECK-NEXT: ret i64 [[HELLO_L]]
;
- %hello_p = getelementptr inbounds [7 x i16], [7 x i16]* @null_hello, i16 0, i16 %x
- %hello_l = call i64 @wcslen(i16* %hello_p)
+ %hello_p = getelementptr inbounds [7 x i16], ptr @null_hello, i16 0, i16 %x
+ %hello_l = call i64 @wcslen(ptr %hello_p)
ret i64 %hello_l
}
@@ -173,13 +165,13 @@ define i64 @test_no_simplify3(i16 %x) {
; CHECK-LABEL: @test_no_simplify3(
; CHECK-NEXT: [[AND:%.*]] = and i16 [[X:%.*]], 15
; CHECK-NEXT: [[TMP1:%.*]] = zext i16 [[AND]] to i64
-; CHECK-NEXT: [[HELLO_P:%.*]] = getelementptr inbounds [13 x i16], [13 x i16]* @null_hello_mid, i64 0, i64 [[TMP1]]
-; CHECK-NEXT: [[HELLO_L:%.*]] = call i64 @wcslen(i16* nonnull [[HELLO_P]])
+; CHECK-NEXT: [[HELLO_P:%.*]] = getelementptr inbounds [13 x i16], ptr @null_hello_mid, i64 0, i64 [[TMP1]]
+; CHECK-NEXT: [[HELLO_L:%.*]] = call i64 @wcslen(ptr nonnull [[HELLO_P]])
; CHECK-NEXT: ret i64 [[HELLO_L]]
;
%and = and i16 %x, 15
- %hello_p = getelementptr inbounds [13 x i16], [13 x i16]* @null_hello_mid, i16 0, i16 %and
- %hello_l = call i64 @wcslen(i16* %hello_p)
+ %hello_p = getelementptr inbounds [13 x i16], ptr @null_hello_mid, i16 0, i16 %and
+ %hello_l = call i64 @wcslen(ptr %hello_p)
ret i64 %hello_l
}
@@ -191,6 +183,6 @@ define i64 @test_no_simplify4() {
; CHECK-LABEL: @test_no_simplify4(
; CHECK-NEXT: ret i64 0
;
- %l = call i64 @wcslen(i16* bitcast ([1 x i32]* @str32 to i16*))
+ %l = call i64 @wcslen(ptr @str32)
ret i64 %l
}
diff --git a/llvm/test/Transforms/InstCombine/wcslen-4.ll b/llvm/test/Transforms/InstCombine/wcslen-4.ll
index b7abe1b24de05..eff1aa77c2730 100644
--- a/llvm/test/Transforms/InstCombine/wcslen-4.ll
+++ b/llvm/test/Transforms/InstCombine/wcslen-4.ll
@@ -9,14 +9,13 @@ target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
@hello = constant [6 x i32] [i32 104, i32 101, i32 108, i32 108, i32 111, i32 0]
-declare i64 @wcslen(i32*)
+declare i64 @wcslen(ptr)
define i64 @test_no_simplify1() {
; CHECK-LABEL: @test_no_simplify1(
-; CHECK-NEXT: [[HELLO_L:%.*]] = call i64 @wcslen(i32* nonnull getelementptr inbounds ([6 x i32], [6 x i32]* @hello, i64 0, i64 0))
+; CHECK-NEXT: [[HELLO_L:%.*]] = call i64 @wcslen(ptr nonnull @hello)
; CHECK-NEXT: ret i64 [[HELLO_L]]
;
- %hello_p = getelementptr [6 x i32], [6 x i32]* @hello, i64 0, i64 0
- %hello_l = call i64 @wcslen(i32* %hello_p)
+ %hello_l = call i64 @wcslen(ptr @hello)
ret i64 %hello_l
}
diff --git a/llvm/test/Transforms/InstCombine/wcslen-5.ll b/llvm/test/Transforms/InstCombine/wcslen-5.ll
index e4d971f2b7ef6..29874e7de5928 100644
--- a/llvm/test/Transforms/InstCombine/wcslen-5.ll
+++ b/llvm/test/Transforms/InstCombine/wcslen-5.ll
@@ -5,7 +5,7 @@
;
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
-declare i64 @wcslen(i32*)
+declare i64 @wcslen(ptr)
!0 = !{i32 1, !"wchar_size", i32 4}
!llvm.module.flags = !{!0}
@@ -19,16 +19,15 @@ declare i64 @wcslen(i32*)
define dso_local i64 @fold_wcslen_s3_pi_s5(i1 zeroext %0, i64 %1) {
; CHECK-LABEL: @fold_wcslen_s3_pi_s5(
-; CHECK-NEXT: [[PS3_PI:%.*]] = getelementptr inbounds [4 x i32], [4 x i32]* @ws3, i64 0, i64 [[TMP1:%.*]]
-; CHECK-NEXT: [[SEL:%.*]] = select i1 [[TMP0:%.*]], i32* [[PS3_PI]], i32* getelementptr inbounds ([6 x i32], [6 x i32]* @ws5, i64 0, i64 0)
-; CHECK-NEXT: [[LEN:%.*]] = tail call i64 @wcslen(i32* nonnull [[SEL]])
+; CHECK-NEXT: [[PS3_PI:%.*]] = getelementptr inbounds [4 x i32], ptr @ws3, i64 0, i64 [[TMP1:%.*]]
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[TMP0:%.*]], ptr [[PS3_PI]], ptr @ws5
+; CHECK-NEXT: [[LEN:%.*]] = tail call i64 @wcslen(ptr nonnull [[SEL]])
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ps3_pi = getelementptr inbounds [4 x i32], [4 x i32]* @ws3, i64 0, i64 %1
- %ps5 = getelementptr inbounds [6 x i32], [6 x i32]* @ws5, i64 0, i64 0
- %sel = select i1 %0, i32* %ps3_pi, i32* %ps5
- %len = tail call i64 @wcslen(i32* %sel)
+ %ps3_pi = getelementptr inbounds [4 x i32], ptr @ws3, i64 0, i64 %1
+ %sel = select i1 %0, ptr %ps3_pi, ptr @ws5
+ %len = tail call i64 @wcslen(ptr %sel)
ret i64 %len
}
@@ -42,18 +41,17 @@ define dso_local i64 @fold_wcslen_s3_pi_p1_s5(i1 zeroext %0, i64 %1) {
; XFAIL-CHECK-NEXT: [[SEL:%.*]] = select i1 %0, i64 [[DIF_I]], i64 5
; XFAIL-CHECK-NEXT: ret i64 [[SEL]]
; CHECK-LABEL: @fold_wcslen_s3_pi_p1_s5(
-; CHECK-NEXT: [[PS3_PI:%.*]] = getelementptr inbounds [4 x i32], [4 x i32]* @ws3, i64 0, i64 [[TMP1:%.*]]
-; CHECK-NEXT: [[PS3_PI_P1:%.*]] = getelementptr inbounds i32, i32* [[PS3_PI]], i64 1
-; CHECK-NEXT: [[SEL:%.*]] = select i1 [[TMP0:%.*]], i32* [[PS3_PI_P1]], i32* getelementptr inbounds ([6 x i32], [6 x i32]* @ws5, i64 0, i64 0)
-; CHECK-NEXT: [[LEN:%.*]] = tail call i64 @wcslen(i32* nonnull [[SEL]])
+; CHECK-NEXT: [[PS3_PI:%.*]] = getelementptr inbounds [4 x i32], ptr @ws3, i64 0, i64 [[TMP1:%.*]]
+; CHECK-NEXT: [[PS3_PI_P1:%.*]] = getelementptr inbounds i32, ptr [[PS3_PI]], i64 1
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[TMP0:%.*]], ptr [[PS3_PI_P1]], ptr @ws5
+; CHECK-NEXT: [[LEN:%.*]] = tail call i64 @wcslen(ptr nonnull [[SEL]])
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ps3_pi = getelementptr inbounds [4 x i32], [4 x i32]* @ws3, i64 0, i64 %1
- %ps3_pi_p1 = getelementptr inbounds i32, i32* %ps3_pi, i64 1
- %ps5 = getelementptr inbounds [6 x i32], [6 x i32]* @ws5, i64 0, i64 0
- %sel = select i1 %0, i32* %ps3_pi_p1, i32* %ps5
- %len = tail call i64 @wcslen(i32* %sel)
+ %ps3_pi = getelementptr inbounds [4 x i32], ptr @ws3, i64 0, i64 %1
+ %ps3_pi_p1 = getelementptr inbounds i32, ptr %ps3_pi, i64 1
+ %sel = select i1 %0, ptr %ps3_pi_p1, ptr @ws5
+ %len = tail call i64 @wcslen(ptr %sel)
ret i64 %len
}
@@ -64,16 +62,15 @@ define dso_local i64 @fold_wcslen_s3_pi_p1_s5(i1 zeroext %0, i64 %1) {
define dso_local i64 @call_wcslen_s5_3_pi_s5(i1 zeroext %0, i64 %1) {
; CHECK-LABEL: @call_wcslen_s5_3_pi_s5(
-; CHECK-NEXT: [[PS5_3_PI:%.*]] = getelementptr inbounds [10 x i32], [10 x i32]* @ws5_3, i64 0, i64 [[TMP1:%.*]]
-; CHECK-NEXT: [[SEL:%.*]] = select i1 [[TMP0:%.*]], i32* [[PS5_3_PI]], i32* getelementptr inbounds ([6 x i32], [6 x i32]* @ws5, i64 0, i64 0)
-; CHECK-NEXT: [[LEN:%.*]] = tail call i64 @wcslen(i32* nonnull [[SEL]])
+; CHECK-NEXT: [[PS5_3_PI:%.*]] = getelementptr inbounds [10 x i32], ptr @ws5_3, i64 0, i64 [[TMP1:%.*]]
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[TMP0:%.*]], ptr [[PS5_3_PI]], ptr @ws5
+; CHECK-NEXT: [[LEN:%.*]] = tail call i64 @wcslen(ptr nonnull [[SEL]])
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ps5_3_pi = getelementptr inbounds [10 x i32], [10 x i32]* @ws5_3, i64 0, i64 %1
- %ps5 = getelementptr inbounds [6 x i32], [6 x i32]* @ws5, i64 0, i64 0
- %sel = select i1 %0, i32* %ps5_3_pi, i32* %ps5
- %len = tail call i64 @wcslen(i32* %sel)
+ %ps5_3_pi = getelementptr inbounds [10 x i32], ptr @ws5_3, i64 0, i64 %1
+ %sel = select i1 %0, ptr %ps5_3_pi, ptr @ws5
+ %len = tail call i64 @wcslen(ptr %sel)
ret i64 %len
}
@@ -82,16 +79,15 @@ define dso_local i64 @call_wcslen_s5_3_pi_s5(i1 zeroext %0, i64 %1) {
define dso_local i64 @call_wcslen_s5_3_s5_pj(i1 zeroext %0, i64 %1) {
; CHECK-LABEL: @call_wcslen_s5_3_s5_pj(
-; CHECK-NEXT: [[PS5:%.*]] = getelementptr inbounds [6 x i32], [6 x i32]* @ws5, i64 0, i64 [[TMP1:%.*]]
-; CHECK-NEXT: [[SEL:%.*]] = select i1 [[TMP0:%.*]], i32* getelementptr inbounds ([10 x i32], [10 x i32]* @ws5_3, i64 0, i64 0), i32* [[PS5]]
-; CHECK-NEXT: [[LEN:%.*]] = tail call i64 @wcslen(i32* nonnull [[SEL]])
+; CHECK-NEXT: [[PS5:%.*]] = getelementptr inbounds [6 x i32], ptr @ws5, i64 0, i64 [[TMP1:%.*]]
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[TMP0:%.*]], ptr @ws5_3, ptr [[PS5]]
+; CHECK-NEXT: [[LEN:%.*]] = tail call i64 @wcslen(ptr nonnull [[SEL]])
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ps5_3_pi = getelementptr inbounds [10 x i32], [10 x i32]* @ws5_3, i64 0, i64 0
- %ps5 = getelementptr inbounds [6 x i32], [6 x i32]* @ws5, i64 0, i64 %1
- %sel = select i1 %0, i32* %ps5_3_pi, i32* %ps5
- %len = tail call i64 @wcslen(i32* %sel)
+ %ps5 = getelementptr inbounds [6 x i32], ptr @ws5, i64 0, i64 %1
+ %sel = select i1 %0, ptr @ws5_3, ptr %ps5
+ %len = tail call i64 @wcslen(ptr %sel)
ret i64 %len
}
@@ -100,16 +96,15 @@ define dso_local i64 @call_wcslen_s5_3_s5_pj(i1 zeroext %0, i64 %1) {
define dso_local i64 @fold_wcslen_s3_s5_pj(i1 zeroext %0, i64 %1) {
; CHECK-LABEL: @fold_wcslen_s3_s5_pj(
-; CHECK-NEXT: [[PS5_PJ:%.*]] = getelementptr inbounds [6 x i32], [6 x i32]* @ws5, i64 0, i64 [[TMP1:%.*]]
-; CHECK-NEXT: [[SEL:%.*]] = select i1 [[TMP0:%.*]], i32* getelementptr inbounds ([4 x i32], [4 x i32]* @ws3, i64 0, i64 0), i32* [[PS5_PJ]]
-; CHECK-NEXT: [[LEN:%.*]] = tail call i64 @wcslen(i32* nonnull [[SEL]])
+; CHECK-NEXT: [[PS5_PJ:%.*]] = getelementptr inbounds [6 x i32], ptr @ws5, i64 0, i64 [[TMP1:%.*]]
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[TMP0:%.*]], ptr @ws3, ptr [[PS5_PJ]]
+; CHECK-NEXT: [[LEN:%.*]] = tail call i64 @wcslen(ptr nonnull [[SEL]])
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ps3 = getelementptr inbounds [4 x i32], [4 x i32]* @ws3, i64 0, i64 0
- %ps5_pj = getelementptr inbounds [6 x i32], [6 x i32]* @ws5, i64 0, i64 %1
- %sel = select i1 %0, i32* %ps3, i32* %ps5_pj
- %len = tail call i64 @wcslen(i32* %sel)
+ %ps5_pj = getelementptr inbounds [6 x i32], ptr @ws5, i64 0, i64 %1
+ %sel = select i1 %0, ptr @ws3, ptr %ps5_pj
+ %len = tail call i64 @wcslen(ptr %sel)
ret i64 %len
}
@@ -120,16 +115,15 @@ define dso_local i64 @fold_wcslen_s3_s5_pj(i1 zeroext %0, i64 %1) {
define dso_local i64 @call_wcslen_s3_s5_3_pj(i1 zeroext %0, i64 %1) {
; CHECK-LABEL: @call_wcslen_s3_s5_3_pj(
-; CHECK-NEXT: [[PS5_3_PJ:%.*]] = getelementptr inbounds [10 x i32], [10 x i32]* @ws5_3, i64 0, i64 [[TMP1:%.*]]
-; CHECK-NEXT: [[SEL:%.*]] = select i1 [[TMP0:%.*]], i32* getelementptr inbounds ([4 x i32], [4 x i32]* @ws3, i64 0, i64 0), i32* [[PS5_3_PJ]]
-; CHECK-NEXT: [[LEN:%.*]] = tail call i64 @wcslen(i32* nonnull [[SEL]])
+; CHECK-NEXT: [[PS5_3_PJ:%.*]] = getelementptr inbounds [10 x i32], ptr @ws5_3, i64 0, i64 [[TMP1:%.*]]
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[TMP0:%.*]], ptr @ws3, ptr [[PS5_3_PJ]]
+; CHECK-NEXT: [[LEN:%.*]] = tail call i64 @wcslen(ptr nonnull [[SEL]])
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ps3 = getelementptr inbounds [4 x i32], [4 x i32]* @ws3, i64 0, i64 0
- %ps5_3_pj = getelementptr inbounds [10 x i32], [10 x i32]* @ws5_3, i64 0, i64 %1
- %sel = select i1 %0, i32* %ps3, i32* %ps5_3_pj
- %len = tail call i64 @wcslen(i32* %sel)
+ %ps5_3_pj = getelementptr inbounds [10 x i32], ptr @ws5_3, i64 0, i64 %1
+ %sel = select i1 %0, ptr @ws3, ptr %ps5_3_pj
+ %len = tail call i64 @wcslen(ptr %sel)
ret i64 %len
}
@@ -138,16 +132,16 @@ define dso_local i64 @call_wcslen_s3_s5_3_pj(i1 zeroext %0, i64 %1) {
define dso_local i64 @fold_wcslen_s3_pi_s5_pj(i1 zeroext %0, i64 %1, i64 %2) {
; CHECK-LABEL: @fold_wcslen_s3_pi_s5_pj(
-; CHECK-NEXT: [[PS3_PI:%.*]] = getelementptr inbounds [4 x i32], [4 x i32]* @ws3, i64 0, i64 [[TMP1:%.*]]
-; CHECK-NEXT: [[PS5_PJ:%.*]] = getelementptr inbounds [6 x i32], [6 x i32]* @ws5, i64 0, i64 [[TMP2:%.*]]
-; CHECK-NEXT: [[SEL:%.*]] = select i1 [[TMP0:%.*]], i32* [[PS3_PI]], i32* [[PS5_PJ]]
-; CHECK-NEXT: [[LEN:%.*]] = tail call i64 @wcslen(i32* nonnull [[SEL]])
+; CHECK-NEXT: [[PS3_PI:%.*]] = getelementptr inbounds [4 x i32], ptr @ws3, i64 0, i64 [[TMP1:%.*]]
+; CHECK-NEXT: [[PS5_PJ:%.*]] = getelementptr inbounds [6 x i32], ptr @ws5, i64 0, i64 [[TMP2:%.*]]
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[TMP0:%.*]], ptr [[PS3_PI]], ptr [[PS5_PJ]]
+; CHECK-NEXT: [[LEN:%.*]] = tail call i64 @wcslen(ptr nonnull [[SEL]])
; CHECK-NEXT: ret i64 [[LEN]]
;
- %ps3_pi = getelementptr inbounds [4 x i32], [4 x i32]* @ws3, i64 0, i64 %1
- %ps5_pj = getelementptr inbounds [6 x i32], [6 x i32]* @ws5, i64 0, i64 %2
- %sel = select i1 %0, i32* %ps3_pi, i32* %ps5_pj
- %len = tail call i64 @wcslen(i32* %sel)
+ %ps3_pi = getelementptr inbounds [4 x i32], ptr @ws3, i64 0, i64 %1
+ %ps5_pj = getelementptr inbounds [6 x i32], ptr @ws5, i64 0, i64 %2
+ %sel = select i1 %0, ptr %ps3_pi, ptr %ps5_pj
+ %len = tail call i64 @wcslen(ptr %sel)
ret i64 %len
}
More information about the llvm-commits
mailing list