[llvm] 7a752e8 - [LoopIdiom] Convert tests to opaque pointers (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 6 02:36:46 PST 2023
Author: Nikita Popov
Date: 2023-01-06T11:36:37+01:00
New Revision: 7a752e81086318303b9326dfef1344c4881f53c3
URL: https://github.com/llvm/llvm-project/commit/7a752e81086318303b9326dfef1344c4881f53c3
DIFF: https://github.com/llvm/llvm-project/commit/7a752e81086318303b9326dfef1344c4881f53c3.diff
LOG: [LoopIdiom] Convert tests to opaque pointers (NFC)
The differences here are due to SCEVExpander producing GEPs with
explicit offset calculation, a known difference with opaque pointers.
Added:
Modified:
llvm/test/Transforms/LoopIdiom/X86/ctlz.ll
llvm/test/Transforms/LoopIdiom/X86/memset-size-compute.ll
llvm/test/Transforms/LoopIdiom/basic.ll
llvm/test/Transforms/LoopIdiom/memcpy-debugify-remarks.ll
llvm/test/Transforms/LoopIdiom/memcpy-intrinsic.ll
llvm/test/Transforms/LoopIdiom/memset-debugify-remarks.ll
llvm/test/Transforms/LoopIdiom/memset-pr52104.ll
llvm/test/Transforms/LoopIdiom/memset-runtime-32bit.ll
llvm/test/Transforms/LoopIdiom/memset-runtime-64bit.ll
llvm/test/Transforms/LoopIdiom/phi-insertion.ll
llvm/test/Transforms/LoopIdiom/struct-custom-dl.ll
llvm/test/Transforms/LoopIdiom/struct.ll
llvm/test/Transforms/LoopIdiom/struct_pattern.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/LoopIdiom/X86/ctlz.ll b/llvm/test/Transforms/LoopIdiom/X86/ctlz.ll
index 45a5574680107..8ea8ba8f34639 100644
--- a/llvm/test/Transforms/LoopIdiom/X86/ctlz.ll
+++ b/llvm/test/Transforms/LoopIdiom/X86/ctlz.ll
@@ -17,7 +17,7 @@
; return i;
; }
;
-define i32 @ctlz_and_other(i32 %n, i8* nocapture %a) {
+define i32 @ctlz_and_other(i32 %n, ptr nocapture %a) {
; ALL-LABEL: @ctlz_and_other(
; ALL-NEXT: entry:
; ALL-NEXT: [[C:%.*]] = icmp sgt i32 [[N:%.*]], 0
@@ -40,8 +40,8 @@ define i32 @ctlz_and_other(i32 %n, i8* nocapture %a) {
; ALL-NEXT: [[AND:%.*]] = and i32 [[SHL]], [[ABS_N]]
; ALL-NEXT: [[TOBOOL1:%.*]] = icmp ne i32 [[AND]], 0
; ALL-NEXT: [[CONV:%.*]] = zext i1 [[TOBOOL1]] to i8
-; ALL-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i8, i8* [[A:%.*]], i64 [[INDVARS_IV]]
-; ALL-NEXT: store i8 [[CONV]], i8* [[ARRAYIDX]], align 1
+; ALL-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i8, ptr [[A:%.*]], i64 [[INDVARS_IV]]
+; ALL-NEXT: store i8 [[CONV]], ptr [[ARRAYIDX]], align 1
; ALL-NEXT: [[INDVARS_IV_NEXT]] = add nuw i64 [[INDVARS_IV]], 1
; ALL-NEXT: [[SHR]] = ashr i32 [[SHR11]], 1
; ALL-NEXT: [[TCDEC]] = sub nsw i32 [[TCPHI]], 1
@@ -74,8 +74,8 @@ while.body: ; preds = %while.body.preheade
%and = and i32 %shl, %abs_n
%tobool1 = icmp ne i32 %and, 0
%conv = zext i1 %tobool1 to i8
- %arrayidx = getelementptr inbounds i8, i8* %a, i64 %indvars.iv
- store i8 %conv, i8* %arrayidx, align 1
+ %arrayidx = getelementptr inbounds i8, ptr %a, i64 %indvars.iv
+ store i8 %conv, ptr %arrayidx, align 1
%indvars.iv.next = add nuw i64 %indvars.iv, 1
%shr = ashr i32 %shr11, 1
%tobool = icmp eq i32 %shr, 0
@@ -562,7 +562,7 @@ define i32 @foo(i32 %x) {
; ALL-NEXT: [[X_ADDR_05:%.*]] = phi i32 [ [[X]], [[WHILE_BODY_LR_PH]] ], [ [[SHR:%.*]], [[WHILE_BODY]] ]
; ALL-NEXT: [[SHR]] = ashr i32 [[X_ADDR_05]], 1
; ALL-NEXT: [[INC]] = add i32 [[CNT_06]], 1
-; ALL-NEXT: store volatile i8 42, i8* [[V]], align 1
+; ALL-NEXT: store volatile i8 42, ptr [[V]], align 1
; ALL-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[SHR]], 0
; ALL-NEXT: br i1 [[TOBOOL]], label [[WHILE_COND_WHILE_END_CRIT_EDGE:%.*]], label [[WHILE_BODY]]
; ALL: while.cond.while.end_crit_edge:
@@ -585,7 +585,7 @@ while.body: ; preds = %while.body.lr.ph, %
%x.addr.05 = phi i32 [ %x, %while.body.lr.ph ], [ %shr, %while.body ]
%shr = ashr i32 %x.addr.05, 1
%inc = add i32 %cnt.06, 1
- store volatile i8 42, i8* %v, align 1
+ store volatile i8 42, ptr %v, align 1
%tobool = icmp eq i32 %shr, 0
br i1 %tobool, label %while.cond.while.end_crit_edge, label %while.body
diff --git a/llvm/test/Transforms/LoopIdiom/X86/memset-size-compute.ll b/llvm/test/Transforms/LoopIdiom/X86/memset-size-compute.ll
index 30bcb59a6fa9e..fe3f5f2f6fce4 100644
--- a/llvm/test/Transforms/LoopIdiom/X86/memset-size-compute.ll
+++ b/llvm/test/Transforms/LoopIdiom/X86/memset-size-compute.ll
@@ -6,7 +6,7 @@ target triple = "x86_64-apple-macosx11.0.0"
; Make sure the number of bytes is computed correctly in the presence of zero
; extensions and preserved add flags.
-define void @test(i64* %ptr) {
+define void @test(ptr %ptr) {
; CHECK-LABEL: @test(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[FOR_BODY_PREHEADER:%.*]]
@@ -14,18 +14,17 @@ define void @test(i64* %ptr) {
; CHECK-NEXT: br label [[FOR_BODY_PREHEADER]]
; CHECK: for.body.preheader:
; CHECK-NEXT: [[LIM_0:%.*]] = phi i32 [ 65, [[ENTRY:%.*]] ], [ 1, [[DEAD:%.*]] ]
-; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i64, i64* [[PTR:%.*]], i64 1
-; CHECK-NEXT: [[SCEVGEP1:%.*]] = bitcast i64* [[SCEVGEP]] to i8*
+; CHECK-NEXT: [[UGLYGEP:%.*]] = getelementptr i8, ptr [[PTR:%.*]], i64 8
; CHECK-NEXT: [[UMAX:%.*]] = call i32 @llvm.umax.i32(i32 [[LIM_0]], i32 2)
; CHECK-NEXT: [[TMP0:%.*]] = add nsw i32 [[UMAX]], -1
; CHECK-NEXT: [[TMP1:%.*]] = zext i32 [[TMP0]] to i64
; CHECK-NEXT: [[TMP2:%.*]] = shl nuw nsw i64 [[TMP1]], 3
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 8 [[SCEVGEP1]], i8 0, i64 [[TMP2]], i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 8 [[UGLYGEP]], i8 0, i64 [[TMP2]], i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[IV:%.*]] = phi i32 [ [[IV_NEXT:%.*]], [[FOR_BODY]] ], [ 1, [[FOR_BODY_PREHEADER]] ]
; CHECK-NEXT: [[IV_EXT:%.*]] = zext i32 [[IV]] to i64
-; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i64, i64* [[PTR]], i64 [[IV_EXT]]
+; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i64, ptr [[PTR]], i64 [[IV_EXT]]
; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i32 [[IV]], 1
; CHECK-NEXT: [[CMP64:%.*]] = icmp ult i32 [[IV_NEXT]], [[LIM_0]]
; CHECK-NEXT: br i1 [[CMP64]], label [[FOR_BODY]], label [[EXIT:%.*]]
@@ -45,8 +44,8 @@ for.body.preheader:
for.body:
%iv = phi i32 [ %iv.next, %for.body ], [ 1, %for.body.preheader ]
%iv.ext = zext i32 %iv to i64
- %gep = getelementptr inbounds i64, i64* %ptr, i64 %iv.ext
- store i64 0, i64* %gep, align 8
+ %gep = getelementptr inbounds i64, ptr %ptr, i64 %iv.ext
+ store i64 0, ptr %gep, align 8
%iv.next = add nuw nsw i32 %iv, 1
%cmp64 = icmp ult i32 %iv.next, %lim.0
br i1 %cmp64, label %for.body, label %exit
diff --git a/llvm/test/Transforms/LoopIdiom/basic.ll b/llvm/test/Transforms/LoopIdiom/basic.ll
index 02ba2125cd8cd..d114abcffb5f7 100644
--- a/llvm/test/Transforms/LoopIdiom/basic.ll
+++ b/llvm/test/Transforms/LoopIdiom/basic.ll
@@ -6,18 +6,18 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
; CHECK: @.memset_pattern = private unnamed_addr constant [4 x i32] [i32 1, i32 1, i32 1, i32 1]
; For @test13_pattern
-; CHECK: @.memset_pattern.1 = private unnamed_addr constant [2 x i32*] [i32* @G, i32* @G]
+; CHECK: @.memset_pattern.1 = private unnamed_addr constant [2 x ptr] [ptr @G, ptr @G]
target triple = "x86_64-apple-darwin10.0.0"
-define void @test1(i8* %Base, i64 %Size) nounwind ssp {
+define void @test1(ptr %Base, i64 %Size) nounwind ssp {
; CHECK-LABEL: @test1(
; CHECK-NEXT: bb.nph:
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 1 [[BASE:%.*]], i8 0, i64 [[SIZE:%.*]], i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[BASE:%.*]], i8 0, i64 [[SIZE:%.*]], i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ 0, [[BB_NPH:%.*]] ], [ [[INDVAR_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[I_0_014:%.*]] = getelementptr i8, i8* [[BASE]], i64 [[INDVAR]]
+; CHECK-NEXT: [[I_0_014:%.*]] = getelementptr i8, ptr [[BASE]], i64 [[INDVAR]]
; CHECK-NEXT: [[INDVAR_NEXT]] = add i64 [[INDVAR]], 1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVAR_NEXT]], [[SIZE]]
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
@@ -29,8 +29,8 @@ bb.nph: ; preds = %entry
for.body: ; preds = %bb.nph, %for.body
%indvar = phi i64 [ 0, %bb.nph ], [ %indvar.next, %for.body ]
- %I.0.014 = getelementptr i8, i8* %Base, i64 %indvar
- store i8 0, i8* %I.0.014, align 1
+ %I.0.014 = getelementptr i8, ptr %Base, i64 %indvar
+ store i8 0, ptr %I.0.014, align 1
%indvar.next = add i64 %indvar, 1
%exitcond = icmp eq i64 %indvar.next, %Size
br i1 %exitcond, label %for.end, label %for.body
@@ -41,16 +41,15 @@ for.end: ; preds = %for.body, %entry
; Make sure memset is formed for larger than 1 byte stores, and that the
; alignment of the store is preserved
-define void @test1_i16(i16* align 2 %Base, i64 %Size) nounwind ssp {
+define void @test1_i16(ptr align 2 %Base, i64 %Size) nounwind ssp {
; CHECK-LABEL: @test1_i16(
; CHECK-NEXT: bb.nph:
-; CHECK-NEXT: [[BASE1:%.*]] = bitcast i16* [[BASE:%.*]] to i8*
; CHECK-NEXT: [[TMP0:%.*]] = shl nuw i64 [[SIZE:%.*]], 1
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 2 [[BASE1]], i8 0, i64 [[TMP0]], i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 2 [[BASE:%.*]], i8 0, i64 [[TMP0]], i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ 0, [[BB_NPH:%.*]] ], [ [[INDVAR_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[I_0_014:%.*]] = getelementptr i16, i16* [[BASE]], i64 [[INDVAR]]
+; CHECK-NEXT: [[I_0_014:%.*]] = getelementptr i16, ptr [[BASE]], i64 [[INDVAR]]
; CHECK-NEXT: [[INDVAR_NEXT]] = add i64 [[INDVAR]], 1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVAR_NEXT]], [[SIZE]]
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
@@ -62,8 +61,8 @@ bb.nph: ; preds = %entry
for.body: ; preds = %bb.nph, %for.body
%indvar = phi i64 [ 0, %bb.nph ], [ %indvar.next, %for.body ]
- %I.0.014 = getelementptr i16, i16* %Base, i64 %indvar
- store i16 0, i16* %I.0.014, align 2
+ %I.0.014 = getelementptr i16, ptr %Base, i64 %indvar
+ store i16 0, ptr %I.0.014, align 2
%indvar.next = add i64 %indvar, 1
%exitcond = icmp eq i64 %indvar.next, %Size
br i1 %exitcond, label %for.end, label %for.body
@@ -74,14 +73,14 @@ for.end: ; preds = %for.body, %entry
; This is a loop that was rotated but where the blocks weren't merged. This
; shouldn't perturb us.
-define void @test1a(i8* %Base, i64 %Size) nounwind ssp {
+define void @test1a(ptr %Base, i64 %Size) nounwind ssp {
; CHECK-LABEL: @test1a(
; CHECK-NEXT: bb.nph:
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 1 [[BASE:%.*]], i8 0, i64 [[SIZE:%.*]], i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[BASE:%.*]], i8 0, i64 [[SIZE:%.*]], i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ 0, [[BB_NPH:%.*]] ], [ [[INDVAR_NEXT:%.*]], [[FOR_BODY_CONT:%.*]] ]
-; CHECK-NEXT: [[I_0_014:%.*]] = getelementptr i8, i8* [[BASE]], i64 [[INDVAR]]
+; CHECK-NEXT: [[I_0_014:%.*]] = getelementptr i8, ptr [[BASE]], i64 [[INDVAR]]
; CHECK-NEXT: [[INDVAR_NEXT]] = add i64 [[INDVAR]], 1
; CHECK-NEXT: br label [[FOR_BODY_CONT]]
; CHECK: for.body.cont:
@@ -95,8 +94,8 @@ bb.nph: ; preds = %entry
for.body: ; preds = %bb.nph, %for.body
%indvar = phi i64 [ 0, %bb.nph ], [ %indvar.next, %for.body.cont ]
- %I.0.014 = getelementptr i8, i8* %Base, i64 %indvar
- store i8 0, i8* %I.0.014, align 1
+ %I.0.014 = getelementptr i8, ptr %Base, i64 %indvar
+ store i8 0, ptr %I.0.014, align 1
%indvar.next = add i64 %indvar, 1
br label %for.body.cont
for.body.cont:
@@ -108,19 +107,18 @@ for.end: ; preds = %for.body, %entry
}
-define void @test2(i32* %Base, i64 %Size) nounwind ssp {
+define void @test2(ptr %Base, i64 %Size) nounwind ssp {
; CHECK-LABEL: @test2(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[BASE1:%.*]] = bitcast i32* [[BASE:%.*]] to i8*
; CHECK-NEXT: [[CMP10:%.*]] = icmp eq i64 [[SIZE:%.*]], 0
; CHECK-NEXT: br i1 [[CMP10]], label [[FOR_END:%.*]], label [[FOR_BODY_PREHEADER:%.*]]
; CHECK: for.body.preheader:
; CHECK-NEXT: [[TMP0:%.*]] = shl nuw i64 [[SIZE]], 2
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 4 [[BASE1]], i8 1, i64 [[TMP0]], i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 4 [[BASE:%.*]], i8 1, i64 [[TMP0]], i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[I_011:%.*]] = phi i64 [ [[INC:%.*]], [[FOR_BODY]] ], [ 0, [[FOR_BODY_PREHEADER]] ]
-; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr i32, i32* [[BASE]], i64 [[I_011]]
+; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr i32, ptr [[BASE]], i64 [[I_011]]
; CHECK-NEXT: [[INC]] = add nsw i64 [[I_011]], 1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INC]], [[SIZE]]
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END_LOOPEXIT:%.*]], label [[FOR_BODY]]
@@ -135,8 +133,8 @@ entry:
for.body: ; preds = %entry, %for.body
%i.011 = phi i64 [ %inc, %for.body ], [ 0, %entry ]
- %add.ptr.i = getelementptr i32, i32* %Base, i64 %i.011
- store i32 16843009, i32* %add.ptr.i, align 4
+ %add.ptr.i = getelementptr i32, ptr %Base, i64 %i.011
+ store i32 16843009, ptr %add.ptr.i, align 4
%inc = add nsw i64 %i.011, 1
%exitcond = icmp eq i64 %inc, %Size
br i1 %exitcond, label %for.end, label %for.body
@@ -147,15 +145,15 @@ for.end: ; preds = %for.body, %entry
; This is a case where there is an extra may-aliased store in the loop, we can't
; promote the memset.
-define void @test3(i32* %Base, i64 %Size, i8 *%MayAlias) nounwind ssp {
+define void @test3(ptr %Base, i64 %Size, ptr %MayAlias) nounwind ssp {
; CHECK-LABEL: @test3(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[I_011:%.*]] = phi i64 [ [[INC:%.*]], [[FOR_BODY]] ], [ 0, [[ENTRY:%.*]] ]
-; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr i32, i32* [[BASE:%.*]], i64 [[I_011]]
-; CHECK-NEXT: store i32 16843009, i32* [[ADD_PTR_I]], align 4
-; CHECK-NEXT: store i8 42, i8* [[MAYALIAS:%.*]], align 1
+; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr i32, ptr [[BASE:%.*]], i64 [[I_011]]
+; CHECK-NEXT: store i32 16843009, ptr [[ADD_PTR_I]], align 4
+; CHECK-NEXT: store i8 42, ptr [[MAYALIAS:%.*]], align 1
; CHECK-NEXT: [[INC]] = add nsw i64 [[I_011]], 1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INC]], [[SIZE:%.*]]
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
@@ -167,10 +165,10 @@ entry:
for.body: ; preds = %entry, %for.body
%i.011 = phi i64 [ %inc, %for.body ], [ 0, %entry ]
- %add.ptr.i = getelementptr i32, i32* %Base, i64 %i.011
- store i32 16843009, i32* %add.ptr.i, align 4
+ %add.ptr.i = getelementptr i32, ptr %Base, i64 %i.011
+ store i32 16843009, ptr %add.ptr.i, align 4
- store i8 42, i8* %MayAlias
+ store i8 42, ptr %MayAlias
%inc = add nsw i64 %i.011, 1
%exitcond = icmp eq i64 %inc, %Size
br i1 %exitcond, label %for.end, label %for.body
@@ -180,16 +178,16 @@ for.end: ; preds = %entry
}
; Make sure the first store in the loop is turned into a memset.
-define void @test4(i8* %Base) nounwind ssp {
+define void @test4(ptr %Base) nounwind ssp {
; CHECK-LABEL: @test4(
; CHECK-NEXT: bb.nph:
-; CHECK-NEXT: [[BASE100:%.*]] = getelementptr i8, i8* [[BASE:%.*]], i64 1000
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 1 [[BASE]], i8 0, i64 100, i1 false)
+; CHECK-NEXT: [[BASE100:%.*]] = getelementptr i8, ptr [[BASE:%.*]], i64 1000
+; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[BASE]], i8 0, i64 100, i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ 0, [[BB_NPH:%.*]] ], [ [[INDVAR_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[I_0_014:%.*]] = getelementptr i8, i8* [[BASE]], i64 [[INDVAR]]
-; CHECK-NEXT: store i8 42, i8* [[BASE100]], align 1
+; CHECK-NEXT: [[I_0_014:%.*]] = getelementptr i8, ptr [[BASE]], i64 [[INDVAR]]
+; CHECK-NEXT: store i8 42, ptr [[BASE100]], align 1
; CHECK-NEXT: [[INDVAR_NEXT]] = add i64 [[INDVAR]], 1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVAR_NEXT]], 100
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
@@ -197,16 +195,16 @@ define void @test4(i8* %Base) nounwind ssp {
; CHECK-NEXT: ret void
;
bb.nph: ; preds = %entry
- %Base100 = getelementptr i8, i8* %Base, i64 1000
+ %Base100 = getelementptr i8, ptr %Base, i64 1000
br label %for.body
for.body: ; preds = %bb.nph, %for.body
%indvar = phi i64 [ 0, %bb.nph ], [ %indvar.next, %for.body ]
- %I.0.014 = getelementptr i8, i8* %Base, i64 %indvar
- store i8 0, i8* %I.0.014, align 1
+ %I.0.014 = getelementptr i8, ptr %Base, i64 %indvar
+ store i8 0, ptr %I.0.014, align 1
;; Store beyond the range memset, should be safe to promote.
- store i8 42, i8* %Base100
+ store i8 42, ptr %Base100
%indvar.next = add i64 %indvar, 1
%exitcond = icmp eq i64 %indvar.next, 100
@@ -217,15 +215,15 @@ for.end: ; preds = %for.body, %entry
}
; This can't be promoted: the memset is a store of a loop variant value.
-define void @test5(i8* %Base, i64 %Size) nounwind ssp {
+define void @test5(ptr %Base, i64 %Size) nounwind ssp {
; CHECK-LABEL: @test5(
; CHECK-NEXT: bb.nph:
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ 0, [[BB_NPH:%.*]] ], [ [[INDVAR_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[I_0_014:%.*]] = getelementptr i8, i8* [[BASE:%.*]], i64 [[INDVAR]]
+; CHECK-NEXT: [[I_0_014:%.*]] = getelementptr i8, ptr [[BASE:%.*]], i64 [[INDVAR]]
; CHECK-NEXT: [[V:%.*]] = trunc i64 [[INDVAR]] to i8
-; CHECK-NEXT: store i8 [[V]], i8* [[I_0_014]], align 1
+; CHECK-NEXT: store i8 [[V]], ptr [[I_0_014]], align 1
; CHECK-NEXT: [[INDVAR_NEXT]] = add i64 [[INDVAR]], 1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVAR_NEXT]], [[SIZE:%.*]]
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
@@ -237,10 +235,10 @@ bb.nph: ; preds = %entry
for.body: ; preds = %bb.nph, %for.body
%indvar = phi i64 [ 0, %bb.nph ], [ %indvar.next, %for.body ]
- %I.0.014 = getelementptr i8, i8* %Base, i64 %indvar
+ %I.0.014 = getelementptr i8, ptr %Base, i64 %indvar
%V = trunc i64 %indvar to i8
- store i8 %V, i8* %I.0.014, align 1
+ store i8 %V, ptr %I.0.014, align 1
%indvar.next = add i64 %indvar, 1
%exitcond = icmp eq i64 %indvar.next, %Size
br i1 %exitcond, label %for.end, label %for.body
@@ -256,13 +254,13 @@ define void @test6(i64 %Size) nounwind ssp {
; CHECK-NEXT: bb.nph:
; CHECK-NEXT: [[BASE:%.*]] = alloca i8, i32 10000, align 1
; CHECK-NEXT: [[DEST:%.*]] = alloca i8, i32 10000, align 1
-; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 [[DEST]], i8* align 1 [[BASE]], i64 [[SIZE:%.*]], i1 false)
+; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 [[DEST]], ptr align 1 [[BASE]], i64 [[SIZE:%.*]], i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ 0, [[BB_NPH:%.*]] ], [ [[INDVAR_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[I_0_014:%.*]] = getelementptr i8, i8* [[BASE]], i64 [[INDVAR]]
-; CHECK-NEXT: [[DESTI:%.*]] = getelementptr i8, i8* [[DEST]], i64 [[INDVAR]]
-; CHECK-NEXT: [[V:%.*]] = load i8, i8* [[I_0_014]], align 1
+; CHECK-NEXT: [[I_0_014:%.*]] = getelementptr i8, ptr [[BASE]], i64 [[INDVAR]]
+; CHECK-NEXT: [[DESTI:%.*]] = getelementptr i8, ptr [[DEST]], i64 [[INDVAR]]
+; CHECK-NEXT: [[V:%.*]] = load i8, ptr [[I_0_014]], align 1
; CHECK-NEXT: [[INDVAR_NEXT]] = add i64 [[INDVAR]], 1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVAR_NEXT]], [[SIZE]]
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
@@ -276,10 +274,10 @@ bb.nph:
for.body: ; preds = %bb.nph, %for.body
%indvar = phi i64 [ 0, %bb.nph ], [ %indvar.next, %for.body ]
- %I.0.014 = getelementptr i8, i8* %Base, i64 %indvar
- %DestI = getelementptr i8, i8* %Dest, i64 %indvar
- %V = load i8, i8* %I.0.014, align 1
- store i8 %V, i8* %DestI, align 1
+ %I.0.014 = getelementptr i8, ptr %Base, i64 %indvar
+ %DestI = getelementptr i8, ptr %Dest, i64 %indvar
+ %V = load i8, ptr %I.0.014, align 1
+ store i8 %V, ptr %DestI, align 1
%indvar.next = add i64 %indvar, 1
%exitcond = icmp eq i64 %indvar.next, %Size
br i1 %exitcond, label %for.end, label %for.body
@@ -289,19 +287,17 @@ for.end: ; preds = %for.body, %entry
}
;; memcpy formation, check alignment
-define void @test6_dest_align(i32* noalias align 1 %Base, i32* noalias align 4 %Dest, i64 %Size) nounwind ssp {
+define void @test6_dest_align(ptr noalias align 1 %Base, ptr noalias align 4 %Dest, i64 %Size) nounwind ssp {
; CHECK-LABEL: @test6_dest_align(
; CHECK-NEXT: bb.nph:
-; CHECK-NEXT: [[DEST1:%.*]] = bitcast i32* [[DEST:%.*]] to i8*
-; CHECK-NEXT: [[BASE2:%.*]] = bitcast i32* [[BASE:%.*]] to i8*
; CHECK-NEXT: [[TMP0:%.*]] = shl nuw i64 [[SIZE:%.*]], 2
-; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 [[DEST1]], i8* align 1 [[BASE2]], i64 [[TMP0]], i1 false)
+; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 [[DEST:%.*]], ptr align 1 [[BASE:%.*]], i64 [[TMP0]], i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ 0, [[BB_NPH:%.*]] ], [ [[INDVAR_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[I_0_014:%.*]] = getelementptr i32, i32* [[BASE]], i64 [[INDVAR]]
-; CHECK-NEXT: [[DESTI:%.*]] = getelementptr i32, i32* [[DEST]], i64 [[INDVAR]]
-; CHECK-NEXT: [[V:%.*]] = load i32, i32* [[I_0_014]], align 1
+; CHECK-NEXT: [[I_0_014:%.*]] = getelementptr i32, ptr [[BASE]], i64 [[INDVAR]]
+; CHECK-NEXT: [[DESTI:%.*]] = getelementptr i32, ptr [[DEST]], i64 [[INDVAR]]
+; CHECK-NEXT: [[V:%.*]] = load i32, ptr [[I_0_014]], align 1
; CHECK-NEXT: [[INDVAR_NEXT]] = add i64 [[INDVAR]], 1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVAR_NEXT]], [[SIZE]]
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
@@ -313,10 +309,10 @@ bb.nph:
for.body: ; preds = %bb.nph, %for.body
%indvar = phi i64 [ 0, %bb.nph ], [ %indvar.next, %for.body ]
- %I.0.014 = getelementptr i32, i32* %Base, i64 %indvar
- %DestI = getelementptr i32, i32* %Dest, i64 %indvar
- %V = load i32, i32* %I.0.014, align 1
- store i32 %V, i32* %DestI, align 4
+ %I.0.014 = getelementptr i32, ptr %Base, i64 %indvar
+ %DestI = getelementptr i32, ptr %Dest, i64 %indvar
+ %V = load i32, ptr %I.0.014, align 1
+ store i32 %V, ptr %DestI, align 4
%indvar.next = add i64 %indvar, 1
%exitcond = icmp eq i64 %indvar.next, %Size
br i1 %exitcond, label %for.end, label %for.body
@@ -326,19 +322,17 @@ for.end: ; preds = %for.body, %entry
}
;; memcpy formation, check alignment
-define void @test6_src_align(i32* noalias align 4 %Base, i32* noalias align 1 %Dest, i64 %Size) nounwind ssp {
+define void @test6_src_align(ptr noalias align 4 %Base, ptr noalias align 1 %Dest, i64 %Size) nounwind ssp {
; CHECK-LABEL: @test6_src_align(
; CHECK-NEXT: bb.nph:
-; CHECK-NEXT: [[DEST1:%.*]] = bitcast i32* [[DEST:%.*]] to i8*
-; CHECK-NEXT: [[BASE2:%.*]] = bitcast i32* [[BASE:%.*]] to i8*
; CHECK-NEXT: [[TMP0:%.*]] = shl nuw i64 [[SIZE:%.*]], 2
-; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 [[DEST1]], i8* align 4 [[BASE2]], i64 [[TMP0]], i1 false)
+; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 [[DEST:%.*]], ptr align 4 [[BASE:%.*]], i64 [[TMP0]], i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ 0, [[BB_NPH:%.*]] ], [ [[INDVAR_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[I_0_014:%.*]] = getelementptr i32, i32* [[BASE]], i64 [[INDVAR]]
-; CHECK-NEXT: [[DESTI:%.*]] = getelementptr i32, i32* [[DEST]], i64 [[INDVAR]]
-; CHECK-NEXT: [[V:%.*]] = load i32, i32* [[I_0_014]], align 4
+; CHECK-NEXT: [[I_0_014:%.*]] = getelementptr i32, ptr [[BASE]], i64 [[INDVAR]]
+; CHECK-NEXT: [[DESTI:%.*]] = getelementptr i32, ptr [[DEST]], i64 [[INDVAR]]
+; CHECK-NEXT: [[V:%.*]] = load i32, ptr [[I_0_014]], align 4
; CHECK-NEXT: [[INDVAR_NEXT]] = add i64 [[INDVAR]], 1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVAR_NEXT]], [[SIZE]]
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
@@ -350,10 +344,10 @@ bb.nph:
for.body: ; preds = %bb.nph, %for.body
%indvar = phi i64 [ 0, %bb.nph ], [ %indvar.next, %for.body ]
- %I.0.014 = getelementptr i32, i32* %Base, i64 %indvar
- %DestI = getelementptr i32, i32* %Dest, i64 %indvar
- %V = load i32, i32* %I.0.014, align 4
- store i32 %V, i32* %DestI, align 1
+ %I.0.014 = getelementptr i32, ptr %Base, i64 %indvar
+ %DestI = getelementptr i32, ptr %Dest, i64 %indvar
+ %V = load i32, ptr %I.0.014, align 4
+ store i32 %V, ptr %DestI, align 1
%indvar.next = add i64 %indvar, 1
%exitcond = icmp eq i64 %indvar.next, %Size
br i1 %exitcond, label %for.end, label %for.body
@@ -365,16 +359,16 @@ for.end: ; preds = %for.body, %entry
; This is a loop that was rotated but where the blocks weren't merged. This
; shouldn't perturb us.
-define void @test7(i8* %Base, i64 %Size) nounwind ssp {
+define void @test7(ptr %Base, i64 %Size) nounwind ssp {
; CHECK-LABEL: @test7(
; CHECK-NEXT: bb.nph:
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 1 [[BASE:%.*]], i8 0, i64 [[SIZE:%.*]], i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[BASE:%.*]], i8 0, i64 [[SIZE:%.*]], i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ 0, [[BB_NPH:%.*]] ], [ [[INDVAR_NEXT:%.*]], [[FOR_BODY_CONT:%.*]] ]
; CHECK-NEXT: br label [[FOR_BODY_CONT]]
; CHECK: for.body.cont:
-; CHECK-NEXT: [[I_0_014:%.*]] = getelementptr i8, i8* [[BASE]], i64 [[INDVAR]]
+; CHECK-NEXT: [[I_0_014:%.*]] = getelementptr i8, ptr [[BASE]], i64 [[INDVAR]]
; CHECK-NEXT: [[INDVAR_NEXT]] = add i64 [[INDVAR]], 1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVAR_NEXT]], [[SIZE]]
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
@@ -388,8 +382,8 @@ for.body: ; preds = %bb.nph, %for.body
%indvar = phi i64 [ 0, %bb.nph ], [ %indvar.next, %for.body.cont ]
br label %for.body.cont
for.body.cont:
- %I.0.014 = getelementptr i8, i8* %Base, i64 %indvar
- store i8 0, i8* %I.0.014, align 1
+ %I.0.014 = getelementptr i8, ptr %Base, i64 %indvar
+ store i8 0, ptr %I.0.014, align 1
%indvar.next = add i64 %indvar, 1
%exitcond = icmp eq i64 %indvar.next, %Size
br i1 %exitcond, label %for.end, label %for.body
@@ -399,14 +393,14 @@ for.end: ; preds = %for.body, %entry
}
; This is a loop should not be transformed, it only executes one iteration.
-define void @test8(i64* %Ptr, i64 %Size) nounwind ssp {
+define void @test8(ptr %Ptr, i64 %Size) nounwind ssp {
; CHECK-LABEL: @test8(
; CHECK-NEXT: bb.nph:
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ 0, [[BB_NPH:%.*]] ], [ [[INDVAR_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[PI:%.*]] = getelementptr i64, i64* [[PTR:%.*]], i64 [[INDVAR]]
-; CHECK-NEXT: store i64 0, i64* [[PI]], align 8
+; CHECK-NEXT: [[PI:%.*]] = getelementptr i64, ptr [[PTR:%.*]], i64 [[INDVAR]]
+; CHECK-NEXT: store i64 0, ptr [[PI]], align 8
; CHECK-NEXT: [[INDVAR_NEXT]] = add i64 [[INDVAR]], 1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVAR_NEXT]], 1
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
@@ -418,8 +412,8 @@ bb.nph: ; preds = %entry
for.body: ; preds = %bb.nph, %for.body
%indvar = phi i64 [ 0, %bb.nph ], [ %indvar.next, %for.body ]
- %PI = getelementptr i64, i64* %Ptr, i64 %indvar
- store i64 0, i64 *%PI
+ %PI = getelementptr i64, ptr %Ptr, i64 %indvar
+ store i64 0, ptr %PI
%indvar.next = add i64 %indvar, 1
%exitcond = icmp eq i64 %indvar.next, 1
br i1 %exitcond, label %for.end, label %for.body
@@ -428,7 +422,7 @@ for.end: ; preds = %for.body, %entry
ret void
}
-declare i8* @external(i8*)
+declare ptr @external(ptr)
;; This cannot be transformed into a memcpy, because the read-from location is
;; mutated by the loop.
@@ -437,15 +431,15 @@ define void @test9(i64 %Size) nounwind ssp {
; CHECK-NEXT: bb.nph:
; CHECK-NEXT: [[BASE:%.*]] = alloca i8, i32 10000, align 1
; CHECK-NEXT: [[DEST:%.*]] = alloca i8, i32 10000, align 1
-; CHECK-NEXT: [[BASEALIAS:%.*]] = call i8* @external(i8* [[BASE]])
+; CHECK-NEXT: [[BASEALIAS:%.*]] = call ptr @external(ptr [[BASE]])
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ 0, [[BB_NPH:%.*]] ], [ [[INDVAR_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[I_0_014:%.*]] = getelementptr i8, i8* [[BASE]], i64 [[INDVAR]]
-; CHECK-NEXT: [[DESTI:%.*]] = getelementptr i8, i8* [[DEST]], i64 [[INDVAR]]
-; CHECK-NEXT: [[V:%.*]] = load i8, i8* [[I_0_014]], align 1
-; CHECK-NEXT: store i8 [[V]], i8* [[DESTI]], align 1
-; CHECK-NEXT: store i8 4, i8* [[BASEALIAS]], align 1
+; CHECK-NEXT: [[I_0_014:%.*]] = getelementptr i8, ptr [[BASE]], i64 [[INDVAR]]
+; CHECK-NEXT: [[DESTI:%.*]] = getelementptr i8, ptr [[DEST]], i64 [[INDVAR]]
+; CHECK-NEXT: [[V:%.*]] = load i8, ptr [[I_0_014]], align 1
+; CHECK-NEXT: store i8 [[V]], ptr [[DESTI]], align 1
+; CHECK-NEXT: store i8 4, ptr [[BASEALIAS]], align 1
; CHECK-NEXT: [[INDVAR_NEXT]] = add i64 [[INDVAR]], 1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVAR_NEXT]], [[SIZE:%.*]]
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
@@ -456,18 +450,18 @@ bb.nph:
%Base = alloca i8, i32 10000
%Dest = alloca i8, i32 10000
- %BaseAlias = call i8* @external(i8* %Base)
+ %BaseAlias = call ptr @external(ptr %Base)
br label %for.body
for.body: ; preds = %bb.nph, %for.body
%indvar = phi i64 [ 0, %bb.nph ], [ %indvar.next, %for.body ]
- %I.0.014 = getelementptr i8, i8* %Base, i64 %indvar
- %DestI = getelementptr i8, i8* %Dest, i64 %indvar
- %V = load i8, i8* %I.0.014, align 1
- store i8 %V, i8* %DestI, align 1
+ %I.0.014 = getelementptr i8, ptr %Base, i64 %indvar
+ %DestI = getelementptr i8, ptr %Dest, i64 %indvar
+ %V = load i8, ptr %I.0.014, align 1
+ store i8 %V, ptr %DestI, align 1
;; This store can clobber the input.
- store i8 4, i8* %BaseAlias
+ store i8 4, ptr %BaseAlias
%indvar.next = add i64 %indvar, 1
%exitcond = icmp eq i64 %indvar.next, %Size
@@ -478,23 +472,23 @@ for.end: ; preds = %for.body, %entry
}
; Two dimensional nested loop should be promoted to one big memset.
-define void @test10(i8* %X) nounwind ssp {
+define void @test10(ptr %X) nounwind ssp {
; CHECK-LABEL: @test10(
; CHECK-NEXT: entry:
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 1 [[X:%.*]], i8 0, i64 10000, i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[X:%.*]], i8 0, i64 10000, i1 false)
; CHECK-NEXT: br label [[BB_NPH:%.*]]
; CHECK: bb.nph:
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ [[INDVAR_NEXT:%.*]], [[FOR_INC10:%.*]] ], [ 0, [[ENTRY:%.*]] ]
; CHECK-NEXT: [[I_04:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[INC12:%.*]], [[FOR_INC10]] ]
; CHECK-NEXT: [[TMP0:%.*]] = mul nuw nsw i64 [[INDVAR]], 100
-; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, i8* [[X]], i64 [[TMP0]]
+; CHECK-NEXT: [[UGLYGEP:%.*]] = getelementptr i8, ptr [[X]], i64 [[TMP0]]
; CHECK-NEXT: br label [[FOR_BODY5:%.*]]
; CHECK: for.body5:
; CHECK-NEXT: [[J_02:%.*]] = phi i32 [ 0, [[BB_NPH]] ], [ [[INC:%.*]], [[FOR_BODY5]] ]
; CHECK-NEXT: [[MUL:%.*]] = mul nsw i32 [[I_04]], 100
; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[J_02]], [[MUL]]
; CHECK-NEXT: [[IDXPROM:%.*]] = sext i32 [[ADD]] to i64
-; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i8, i8* [[X]], i64 [[IDXPROM]]
+; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i8, ptr [[X]], i64 [[IDXPROM]]
; CHECK-NEXT: [[INC]] = add nsw i32 [[J_02]], 1
; CHECK-NEXT: [[CMP4:%.*]] = icmp eq i32 [[INC]], 100
; CHECK-NEXT: br i1 [[CMP4]], label [[FOR_INC10]], label [[FOR_BODY5]]
@@ -518,8 +512,8 @@ for.body5: ; preds = %for.body5, %bb.nph
%mul = mul nsw i32 %i.04, 100
%add = add nsw i32 %j.02, %mul
%idxprom = sext i32 %add to i64
- %arrayidx = getelementptr inbounds i8, i8* %X, i64 %idxprom
- store i8 0, i8* %arrayidx, align 1
+ %arrayidx = getelementptr inbounds i8, ptr %X, i64 %idxprom
+ store i8 0, ptr %arrayidx, align 1
%inc = add nsw i32 %j.02, 1
%cmp4 = icmp eq i32 %inc, 100
br i1 %cmp4, label %for.inc10, label %for.body5
@@ -536,15 +530,14 @@ for.end13: ; preds = %for.inc10
; On darwin10 (which is the triple in this .ll file) this loop can be turned
; into a memset_pattern call.
; rdar://9009151
-define void @test11_pattern(i32* nocapture %P) nounwind ssp {
+define void @test11_pattern(ptr nocapture %P) nounwind ssp {
; CHECK-LABEL: @test11_pattern(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[P1:%.*]] = bitcast i32* [[P:%.*]] to i8*
-; CHECK-NEXT: call void @memset_pattern16(i8* [[P1]], i8* bitcast ([4 x i32]* @.memset_pattern to i8*), i64 40000)
+; CHECK-NEXT: call void @memset_pattern16(ptr [[P:%.*]], ptr @.memset_pattern, i64 40000)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVAR_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr i32, i32* [[P]], i64 [[INDVAR]]
+; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr i32, ptr [[P]], i64 [[INDVAR]]
; CHECK-NEXT: [[INDVAR_NEXT]] = add i64 [[INDVAR]], 1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVAR_NEXT]], 10000
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
@@ -556,8 +549,8 @@ entry:
for.body: ; preds = %entry, %for.body
%indvar = phi i64 [ 0, %entry ], [ %indvar.next, %for.body ]
- %arrayidx = getelementptr i32, i32* %P, i64 %indvar
- store i32 1, i32* %arrayidx, align 4
+ %arrayidx = getelementptr i32, ptr %P, i64 %indvar
+ store i32 1, ptr %arrayidx, align 4
%indvar.next = add i64 %indvar, 1
%exitcond = icmp eq i64 %indvar.next, 10000
br i1 %exitcond, label %for.end, label %for.body
@@ -567,15 +560,14 @@ for.end: ; preds = %for.body
}
; Store of null should turn into memset of zero.
-define void @test12(i32** nocapture %P) nounwind ssp {
+define void @test12(ptr nocapture %P) nounwind ssp {
; CHECK-LABEL: @test12(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[P1:%.*]] = bitcast i32** [[P:%.*]] to i8*
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 4 [[P1]], i8 0, i64 80000, i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 4 [[P:%.*]], i8 0, i64 80000, i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVAR_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr i32*, i32** [[P]], i64 [[INDVAR]]
+; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr ptr, ptr [[P]], i64 [[INDVAR]]
; CHECK-NEXT: [[INDVAR_NEXT]] = add i64 [[INDVAR]], 1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVAR_NEXT]], 10000
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
@@ -587,8 +579,8 @@ entry:
for.body: ; preds = %entry, %for.body
%indvar = phi i64 [ 0, %entry ], [ %indvar.next, %for.body ]
- %arrayidx = getelementptr i32*, i32** %P, i64 %indvar
- store i32* null, i32** %arrayidx, align 4
+ %arrayidx = getelementptr ptr, ptr %P, i64 %indvar
+ store ptr null, ptr %arrayidx, align 4
%indvar.next = add i64 %indvar, 1
%exitcond = icmp eq i64 %indvar.next, 10000
br i1 %exitcond, label %for.end, label %for.body
@@ -601,15 +593,14 @@ for.end: ; preds = %for.body
; This store-of-address loop can be turned into a memset_pattern call.
; rdar://9009151
-define void @test13_pattern(i32** nocapture %P) nounwind ssp {
+define void @test13_pattern(ptr nocapture %P) nounwind ssp {
; CHECK-LABEL: @test13_pattern(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[P1:%.*]] = bitcast i32** [[P:%.*]] to i8*
-; CHECK-NEXT: call void @memset_pattern16(i8* [[P1]], i8* bitcast ([2 x i32*]* @.memset_pattern.1 to i8*), i64 80000)
+; CHECK-NEXT: call void @memset_pattern16(ptr [[P:%.*]], ptr @.memset_pattern.1, i64 80000)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVAR_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr i32*, i32** [[P]], i64 [[INDVAR]]
+; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr ptr, ptr [[P]], i64 [[INDVAR]]
; CHECK-NEXT: [[INDVAR_NEXT]] = add i64 [[INDVAR]], 1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVAR_NEXT]], 10000
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
@@ -621,8 +612,8 @@ entry:
for.body: ; preds = %entry, %for.body
%indvar = phi i64 [ 0, %entry ], [ %indvar.next, %for.body ]
- %arrayidx = getelementptr i32*, i32** %P, i64 %indvar
- store i32* @G, i32** %arrayidx, align 4
+ %arrayidx = getelementptr ptr, ptr %P, i64 %indvar
+ store ptr @G, ptr %arrayidx, align 4
%indvar.next = add i64 %indvar, 1
%exitcond = icmp eq i64 %indvar.next, 10000
br i1 %exitcond, label %for.end, label %for.body
@@ -645,17 +636,17 @@ define i32 @test14() nounwind {
; CHECK-NEXT: [[T5:%.*]] = phi i32 [ [[INC:%.*]], [[FOR_BODY]] ], [ 0, [[ENTRY:%.*]] ]
; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[T5]], 4
; CHECK-NEXT: [[IDXPROM:%.*]] = sext i32 [[ADD]] to i64
-; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [7 x i32], [7 x i32]* @g_50, i32 0, i64 [[IDXPROM]]
-; CHECK-NEXT: [[T2:%.*]] = load i32, i32* [[ARRAYIDX]], align 4
+; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [7 x i32], ptr @g_50, i32 0, i64 [[IDXPROM]]
+; CHECK-NEXT: [[T2:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
; CHECK-NEXT: [[ADD4:%.*]] = add nsw i32 [[T5]], 5
; CHECK-NEXT: [[IDXPROM5:%.*]] = sext i32 [[ADD4]] to i64
-; CHECK-NEXT: [[ARRAYIDX6:%.*]] = getelementptr inbounds [7 x i32], [7 x i32]* @g_50, i32 0, i64 [[IDXPROM5]]
-; CHECK-NEXT: store i32 [[T2]], i32* [[ARRAYIDX6]], align 4
+; CHECK-NEXT: [[ARRAYIDX6:%.*]] = getelementptr inbounds [7 x i32], ptr @g_50, i32 0, i64 [[IDXPROM5]]
+; CHECK-NEXT: store i32 [[T2]], ptr [[ARRAYIDX6]], align 4
; CHECK-NEXT: [[INC]] = add nsw i32 [[T5]], 1
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[INC]], 2
; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END:%.*]]
; CHECK: for.end:
-; CHECK-NEXT: [[T8:%.*]] = load i32, i32* getelementptr inbounds ([7 x i32], [7 x i32]* @g_50, i32 0, i64 6), align 4
+; CHECK-NEXT: [[T8:%.*]] = load i32, ptr getelementptr inbounds ([7 x i32], ptr @g_50, i32 0, i64 6), align 4
; CHECK-NEXT: ret i32 [[T8]]
;
entry:
@@ -665,23 +656,23 @@ for.body: ; preds = %for.inc, %for.body.
%t5 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
%add = add nsw i32 %t5, 4
%idxprom = sext i32 %add to i64
- %arrayidx = getelementptr inbounds [7 x i32], [7 x i32]* @g_50, i32 0, i64 %idxprom
- %t2 = load i32, i32* %arrayidx, align 4
+ %arrayidx = getelementptr inbounds [7 x i32], ptr @g_50, i32 0, i64 %idxprom
+ %t2 = load i32, ptr %arrayidx, align 4
%add4 = add nsw i32 %t5, 5
%idxprom5 = sext i32 %add4 to i64
- %arrayidx6 = getelementptr inbounds [7 x i32], [7 x i32]* @g_50, i32 0, i64 %idxprom5
- store i32 %t2, i32* %arrayidx6, align 4
+ %arrayidx6 = getelementptr inbounds [7 x i32], ptr @g_50, i32 0, i64 %idxprom5
+ store i32 %t2, ptr %arrayidx6, align 4
%inc = add nsw i32 %t5, 1
%cmp = icmp slt i32 %inc, 2
br i1 %cmp, label %for.body, label %for.end
for.end: ; preds = %for.inc
- %t8 = load i32, i32* getelementptr inbounds ([7 x i32], [7 x i32]* @g_50, i32 0, i64 6), align 4
+ %t8 = load i32, ptr getelementptr inbounds ([7 x i32], ptr @g_50, i32 0, i64 6), align 4
ret i32 %t8
}
-define void @PR14241(i32* %s, i64 %size) {
+define void @PR14241(ptr %s, i64 %size) {
; Ensure that we don't form a memcpy for strided loops. Briefly, when we taught
; LoopIdiom about memmove and strided loops, this got miscompiled into a memcpy
; instead of a memmove. If we get the memmove transform back, this will catch
@@ -689,25 +680,22 @@ define void @PR14241(i32* %s, i64 %size) {
;
; CHECK-LABEL: @PR14241(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[S1:%.*]] = bitcast i32* [[S:%.*]] to i8*
; CHECK-NEXT: [[END_IDX:%.*]] = add i64 [[SIZE:%.*]], -1
-; CHECK-NEXT: [[END_PTR:%.*]] = getelementptr inbounds i32, i32* [[S]], i64 [[END_IDX]]
-; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i32, i32* [[S]], i64 1
-; CHECK-NEXT: [[SCEVGEP2:%.*]] = bitcast i32* [[SCEVGEP]] to i8*
+; CHECK-NEXT: [[END_PTR:%.*]] = getelementptr inbounds i32, ptr [[S:%.*]], i64 [[END_IDX]]
+; CHECK-NEXT: [[UGLYGEP:%.*]] = getelementptr i8, ptr [[S]], i64 4
; CHECK-NEXT: [[TMP0:%.*]] = shl i64 [[SIZE]], 2
; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[TMP0]], -8
; CHECK-NEXT: [[TMP2:%.*]] = lshr i64 [[TMP1]], 2
; CHECK-NEXT: [[TMP3:%.*]] = shl nuw i64 [[TMP2]], 2
; CHECK-NEXT: [[TMP4:%.*]] = add i64 [[TMP3]], 4
-; CHECK-NEXT: call void @llvm.memmove.p0i8.p0i8.i64(i8* align 4 [[S1]], i8* align 4 [[SCEVGEP2]], i64 [[TMP4]], i1 false)
+; CHECK-NEXT: call void @llvm.memmove.p0.p0.i64(ptr align 4 [[S]], ptr align 4 [[UGLYGEP]], i64 [[TMP4]], i1 false)
; CHECK-NEXT: br label [[WHILE_BODY:%.*]]
; CHECK: while.body:
-; CHECK-NEXT: [[PHI_PTR:%.*]] = phi i32* [ [[S]], [[ENTRY:%.*]] ], [ [[NEXT_PTR:%.*]], [[WHILE_BODY]] ]
-; CHECK-NEXT: [[SRC_PTR:%.*]] = getelementptr inbounds i32, i32* [[PHI_PTR]], i64 1
-; CHECK-NEXT: [[VAL:%.*]] = load i32, i32* [[SRC_PTR]], align 4
-; CHECK-NEXT: [[DST_PTR:%.*]] = getelementptr inbounds i32, i32* [[PHI_PTR]], i64 0
-; CHECK-NEXT: [[NEXT_PTR]] = getelementptr inbounds i32, i32* [[PHI_PTR]], i64 1
-; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32* [[NEXT_PTR]], [[END_PTR]]
+; CHECK-NEXT: [[PHI_PTR:%.*]] = phi ptr [ [[S]], [[ENTRY:%.*]] ], [ [[NEXT_PTR:%.*]], [[WHILE_BODY]] ]
+; CHECK-NEXT: [[SRC_PTR:%.*]] = getelementptr inbounds i32, ptr [[PHI_PTR]], i64 1
+; CHECK-NEXT: [[VAL:%.*]] = load i32, ptr [[SRC_PTR]], align 4
+; CHECK-NEXT: [[NEXT_PTR]] = getelementptr inbounds i32, ptr [[PHI_PTR]], i64 1
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq ptr [[NEXT_PTR]], [[END_PTR]]
; CHECK-NEXT: br i1 [[CMP]], label [[EXIT:%.*]], label [[WHILE_BODY]]
; CHECK: exit:
; CHECK-NEXT: ret void
@@ -715,17 +703,16 @@ define void @PR14241(i32* %s, i64 %size) {
entry:
%end.idx = add i64 %size, -1
- %end.ptr = getelementptr inbounds i32, i32* %s, i64 %end.idx
+ %end.ptr = getelementptr inbounds i32, ptr %s, i64 %end.idx
br label %while.body
while.body:
- %phi.ptr = phi i32* [ %s, %entry ], [ %next.ptr, %while.body ]
- %src.ptr = getelementptr inbounds i32, i32* %phi.ptr, i64 1
- %val = load i32, i32* %src.ptr, align 4
- %dst.ptr = getelementptr inbounds i32, i32* %phi.ptr, i64 0
- store i32 %val, i32* %dst.ptr, align 4
- %next.ptr = getelementptr inbounds i32, i32* %phi.ptr, i64 1
- %cmp = icmp eq i32* %next.ptr, %end.ptr
+ %phi.ptr = phi ptr [ %s, %entry ], [ %next.ptr, %while.body ]
+ %src.ptr = getelementptr inbounds i32, ptr %phi.ptr, i64 1
+ %val = load i32, ptr %src.ptr, align 4
+ store i32 %val, ptr %phi.ptr, align 4
+ %next.ptr = getelementptr inbounds i32, ptr %phi.ptr, i64 1
+ %cmp = icmp eq ptr %next.ptr, %end.ptr
br i1 %cmp, label %exit, label %while.body
exit:
@@ -733,15 +720,14 @@ exit:
}
; Recognize loops with a negative stride.
-define void @test15(i32* nocapture %f) {
+define void @test15(ptr nocapture %f) {
; CHECK-LABEL: @test15(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[F1:%.*]] = bitcast i32* [[F:%.*]] to i8*
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 4 [[F1]], i8 0, i64 262148, i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 4 [[F:%.*]], i8 0, i64 262148, i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 65536, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[F]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[F]], i64 [[INDVARS_IV]]
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], -1
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i64 [[INDVARS_IV]], 0
; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_COND_CLEANUP:%.*]]
@@ -753,8 +739,8 @@ entry:
for.body:
%indvars.iv = phi i64 [ 65536, %entry ], [ %indvars.iv.next, %for.body ]
- %arrayidx = getelementptr inbounds i32, i32* %f, i64 %indvars.iv
- store i32 0, i32* %arrayidx, align 4
+ %arrayidx = getelementptr inbounds i32, ptr %f, i64 %indvars.iv
+ store i32 0, ptr %arrayidx, align 4
%indvars.iv.next = add nsw i64 %indvars.iv, -1
%cmp = icmp sgt i64 %indvars.iv, 0
br i1 %cmp, label %for.body, label %for.cond.cleanup
@@ -765,16 +751,16 @@ for.cond.cleanup:
; Loop with a negative stride. Verify an aliasing write to f[65536] prevents
; the creation of a memset.
-define void @test16(i32* nocapture %f) {
+define void @test16(ptr nocapture %f) {
; CHECK-LABEL: @test16(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds i32, i32* [[F:%.*]], i64 65536
+; CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds i32, ptr [[F:%.*]], i64 65536
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 65536, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[F]], i64 [[INDVARS_IV]]
-; CHECK-NEXT: store i32 0, i32* [[ARRAYIDX]], align 4
-; CHECK-NEXT: store i32 1, i32* [[ARRAYIDX1]], align 4
+; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[F]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: store i32 0, ptr [[ARRAYIDX]], align 4
+; CHECK-NEXT: store i32 1, ptr [[ARRAYIDX1]], align 4
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], -1
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i64 [[INDVARS_IV]], 0
; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_COND_CLEANUP:%.*]]
@@ -782,14 +768,14 @@ define void @test16(i32* nocapture %f) {
; CHECK-NEXT: ret void
;
entry:
- %arrayidx1 = getelementptr inbounds i32, i32* %f, i64 65536
+ %arrayidx1 = getelementptr inbounds i32, ptr %f, i64 65536
br label %for.body
for.body: ; preds = %entry, %for.body
%indvars.iv = phi i64 [ 65536, %entry ], [ %indvars.iv.next, %for.body ]
- %arrayidx = getelementptr inbounds i32, i32* %f, i64 %indvars.iv
- store i32 0, i32* %arrayidx, align 4
- store i32 1, i32* %arrayidx1, align 4
+ %arrayidx = getelementptr inbounds i32, ptr %f, i64 %indvars.iv
+ store i32 0, ptr %arrayidx, align 4
+ store i32 1, ptr %arrayidx1, align 4
%indvars.iv.next = add nsw i64 %indvars.iv, -1
%cmp = icmp sgt i64 %indvars.iv, 0
br i1 %cmp, label %for.body, label %for.cond.cleanup
@@ -799,49 +785,45 @@ for.cond.cleanup: ; preds = %for.body
}
; Handle memcpy-able loops with negative stride.
-define noalias i32* @test17(i32* nocapture readonly %a, i32 %c) {
+define noalias ptr @test17(ptr nocapture readonly %a, i32 %c) {
; CHECK-LABEL: @test17(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CONV:%.*]] = sext i32 [[C:%.*]] to i64
; CHECK-NEXT: [[MUL:%.*]] = shl nsw i64 [[CONV]], 2
-; CHECK-NEXT: [[CALL:%.*]] = tail call noalias i8* @malloc(i64 [[MUL]])
-; CHECK-NEXT: [[TMP0:%.*]] = bitcast i8* [[CALL]] to i32*
+; CHECK-NEXT: [[CALL:%.*]] = tail call noalias ptr @malloc(i64 [[MUL]])
; CHECK-NEXT: [[TOBOOL_9:%.*]] = icmp eq i32 [[C]], 0
; CHECK-NEXT: br i1 [[TOBOOL_9]], label [[WHILE_END:%.*]], label [[WHILE_BODY_PREHEADER:%.*]]
; CHECK: while.body.preheader:
-; CHECK-NEXT: [[TMP1:%.*]] = add i32 [[C]], -1
-; CHECK-NEXT: [[TMP2:%.*]] = sext i32 [[TMP1]] to i64
-; CHECK-NEXT: [[TMP3:%.*]] = shl nsw i64 [[TMP2]], 2
-; CHECK-NEXT: [[TMP4:%.*]] = zext i32 [[TMP1]] to i64
-; CHECK-NEXT: [[TMP5:%.*]] = shl nuw nsw i64 [[TMP4]], 2
-; CHECK-NEXT: [[TMP6:%.*]] = sub i64 [[TMP3]], [[TMP5]]
-; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, i8* [[CALL]], i64 [[TMP6]]
-; CHECK-NEXT: [[TMP7:%.*]] = sub i64 [[TMP2]], [[TMP4]]
-; CHECK-NEXT: [[SCEVGEP1:%.*]] = getelementptr i32, i32* [[A:%.*]], i64 [[TMP7]]
-; CHECK-NEXT: [[SCEVGEP12:%.*]] = bitcast i32* [[SCEVGEP1]] to i8*
-; CHECK-NEXT: [[TMP8:%.*]] = zext i32 [[C]] to i64
-; CHECK-NEXT: [[TMP9:%.*]] = shl nuw nsw i64 [[TMP8]], 2
-; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 [[SCEVGEP]], i8* align 4 [[SCEVGEP12]], i64 [[TMP9]], i1 false)
+; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[C]], -1
+; CHECK-NEXT: [[TMP1:%.*]] = sext i32 [[TMP0]] to i64
+; CHECK-NEXT: [[TMP2:%.*]] = shl nsw i64 [[TMP1]], 2
+; CHECK-NEXT: [[TMP3:%.*]] = zext i32 [[TMP0]] to i64
+; CHECK-NEXT: [[TMP4:%.*]] = shl nuw nsw i64 [[TMP3]], 2
+; CHECK-NEXT: [[TMP5:%.*]] = sub i64 [[TMP2]], [[TMP4]]
+; CHECK-NEXT: [[UGLYGEP:%.*]] = getelementptr i8, ptr [[CALL]], i64 [[TMP5]]
+; CHECK-NEXT: [[UGLYGEP1:%.*]] = getelementptr i8, ptr [[A:%.*]], i64 [[TMP5]]
+; CHECK-NEXT: [[TMP6:%.*]] = zext i32 [[C]] to i64
+; CHECK-NEXT: [[TMP7:%.*]] = shl nuw nsw i64 [[TMP6]], 2
+; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 [[UGLYGEP]], ptr align 4 [[UGLYGEP1]], i64 [[TMP7]], i1 false)
; CHECK-NEXT: br label [[WHILE_BODY:%.*]]
; CHECK: while.body:
; CHECK-NEXT: [[DEC10_IN:%.*]] = phi i32 [ [[DEC10:%.*]], [[WHILE_BODY]] ], [ [[C]], [[WHILE_BODY_PREHEADER]] ]
; CHECK-NEXT: [[DEC10]] = add nsw i32 [[DEC10_IN]], -1
; CHECK-NEXT: [[IDXPROM:%.*]] = sext i32 [[DEC10]] to i64
-; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 [[IDXPROM]]
-; CHECK-NEXT: [[TMP10:%.*]] = load i32, i32* [[ARRAYIDX]], align 4
-; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds i32, i32* [[TMP0]], i64 [[IDXPROM]]
+; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[IDXPROM]]
+; CHECK-NEXT: [[TMP8:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
+; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds i32, ptr [[CALL]], i64 [[IDXPROM]]
; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[DEC10]], 0
; CHECK-NEXT: br i1 [[TOBOOL]], label [[WHILE_END_LOOPEXIT:%.*]], label [[WHILE_BODY]]
; CHECK: while.end.loopexit:
; CHECK-NEXT: br label [[WHILE_END]]
; CHECK: while.end:
-; CHECK-NEXT: ret i32* [[TMP0]]
+; CHECK-NEXT: ret ptr [[CALL]]
;
entry:
%conv = sext i32 %c to i64
%mul = shl nsw i64 %conv, 2
- %call = tail call noalias i8* @malloc(i64 %mul)
- %0 = bitcast i8* %call to i32*
+ %call = tail call noalias ptr @malloc(i64 %mul)
%tobool.9 = icmp eq i32 %c, 0
br i1 %tobool.9, label %while.end, label %while.body.preheader
@@ -852,10 +834,10 @@ while.body: ; preds = %while.body.preheade
%dec10.in = phi i32 [ %dec10, %while.body ], [ %c, %while.body.preheader ]
%dec10 = add nsw i32 %dec10.in, -1
%idxprom = sext i32 %dec10 to i64
- %arrayidx = getelementptr inbounds i32, i32* %a, i64 %idxprom
- %1 = load i32, i32* %arrayidx, align 4
- %arrayidx2 = getelementptr inbounds i32, i32* %0, i64 %idxprom
- store i32 %1, i32* %arrayidx2, align 4
+ %arrayidx = getelementptr inbounds i32, ptr %a, i64 %idxprom
+ %0 = load i32, ptr %arrayidx, align 4
+ %arrayidx2 = getelementptr inbounds i32, ptr %call, i64 %idxprom
+ store i32 %0, ptr %arrayidx2, align 4
%tobool = icmp eq i32 %dec10, 0
br i1 %tobool, label %while.end.loopexit, label %while.body
@@ -863,10 +845,10 @@ while.end.loopexit: ; preds = %while.body
br label %while.end
while.end: ; preds = %while.end.loopexit, %entry
- ret i32* %0
+ ret ptr %call
}
-declare noalias i8* @malloc(i64)
+declare noalias ptr @malloc(i64)
; Handle memcpy-able loops with negative stride.
; void test18(unsigned *__restrict__ a, unsigned *__restrict__ b) {
@@ -874,18 +856,16 @@ declare noalias i8* @malloc(i64)
; a[i] = b[i];
; }
; }
-define void @test18(i32* noalias nocapture %a, i32* noalias nocapture readonly %b) #0 {
+define void @test18(ptr noalias nocapture %a, ptr noalias nocapture readonly %b) #0 {
; CHECK-LABEL: @test18(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[A1:%.*]] = bitcast i32* [[A:%.*]] to i8*
-; CHECK-NEXT: [[B2:%.*]] = bitcast i32* [[B:%.*]] to i8*
-; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 [[A1]], i8* align 4 [[B2]], i64 8192, i1 false)
+; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 [[A:%.*]], ptr align 4 [[B:%.*]], i64 8192, i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 2047, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[B]], i64 [[INDVARS_IV]]
-; CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* [[ARRAYIDX]], align 4
-; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[B]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
+; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[INDVARS_IV]]
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], -1
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i64 [[INDVARS_IV]], 0
; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_COND_CLEANUP:%.*]]
@@ -897,10 +877,10 @@ entry:
for.body: ; preds = %entry, %for.body
%indvars.iv = phi i64 [ 2047, %entry ], [ %indvars.iv.next, %for.body ]
- %arrayidx = getelementptr inbounds i32, i32* %b, i64 %indvars.iv
- %0 = load i32, i32* %arrayidx, align 4
- %arrayidx2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
- store i32 %0, i32* %arrayidx2, align 4
+ %arrayidx = getelementptr inbounds i32, ptr %b, i64 %indvars.iv
+ %0 = load i32, ptr %arrayidx, align 4
+ %arrayidx2 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
+ store i32 %0, ptr %arrayidx2, align 4
%indvars.iv.next = add nsw i64 %indvars.iv, -1
%cmp = icmp sgt i64 %indvars.iv, 0
br i1 %cmp, label %for.body, label %for.cond.cleanup
@@ -910,24 +890,24 @@ for.cond.cleanup: ; preds = %for.body
}
; Two dimensional nested loop with negative stride should be promoted to one big memset.
-define void @test19(i8* nocapture %X) {
+define void @test19(ptr nocapture %X) {
; CHECK-LABEL: @test19(
; CHECK-NEXT: entry:
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 1 [[X:%.*]], i8 0, i64 10000, i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[X:%.*]], i8 0, i64 10000, i1 false)
; CHECK-NEXT: br label [[FOR_COND1_PREHEADER:%.*]]
; CHECK: for.cond1.preheader:
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ [[INDVAR_NEXT:%.*]], [[FOR_INC4:%.*]] ], [ 0, [[ENTRY:%.*]] ]
; CHECK-NEXT: [[I_06:%.*]] = phi i32 [ 99, [[ENTRY]] ], [ [[DEC5:%.*]], [[FOR_INC4]] ]
; CHECK-NEXT: [[TMP0:%.*]] = mul nsw i64 [[INDVAR]], -100
; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[TMP0]], 9900
-; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, i8* [[X]], i64 [[TMP1]]
+; CHECK-NEXT: [[UGLYGEP:%.*]] = getelementptr i8, ptr [[X]], i64 [[TMP1]]
; CHECK-NEXT: [[MUL:%.*]] = mul nsw i32 [[I_06]], 100
; CHECK-NEXT: br label [[FOR_BODY3:%.*]]
; CHECK: for.body3:
; CHECK-NEXT: [[J_05:%.*]] = phi i32 [ 99, [[FOR_COND1_PREHEADER]] ], [ [[DEC:%.*]], [[FOR_BODY3]] ]
; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[J_05]], [[MUL]]
; CHECK-NEXT: [[IDXPROM:%.*]] = sext i32 [[ADD]] to i64
-; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i8, i8* [[X]], i64 [[IDXPROM]]
+; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i8, ptr [[X]], i64 [[IDXPROM]]
; CHECK-NEXT: [[DEC]] = add nsw i32 [[J_05]], -1
; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i32 [[J_05]], 0
; CHECK-NEXT: br i1 [[CMP2]], label [[FOR_BODY3]], label [[FOR_INC4]]
@@ -951,8 +931,8 @@ for.body3: ; preds = %for.cond1.preheader
%j.05 = phi i32 [ 99, %for.cond1.preheader ], [ %dec, %for.body3 ]
%add = add nsw i32 %j.05, %mul
%idxprom = sext i32 %add to i64
- %arrayidx = getelementptr inbounds i8, i8* %X, i64 %idxprom
- store i8 0, i8* %arrayidx, align 1
+ %arrayidx = getelementptr inbounds i8, ptr %X, i64 %idxprom
+ store i8 0, ptr %arrayidx, align 1
%dec = add nsw i32 %j.05, -1
%cmp2 = icmp sgt i32 %j.05, 0
br i1 %cmp2, label %for.body3, label %for.inc4
@@ -968,21 +948,20 @@ for.end6: ; preds = %for.inc4
; Handle loops where the trip count is a narrow integer that needs to be
; extended.
-define void @form_memset_narrow_size(i64* %ptr, i32 %size) {
+define void @form_memset_narrow_size(ptr %ptr, i32 %size) {
; CHECK-LABEL: @form_memset_narrow_size(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[PTR1:%.*]] = bitcast i64* [[PTR:%.*]] to i8*
; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt i32 [[SIZE:%.*]], 0
; CHECK-NEXT: br i1 [[CMP1]], label [[LOOP_PH:%.*]], label [[EXIT:%.*]]
; CHECK: loop.ph:
; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[SIZE]] to i64
; CHECK-NEXT: [[TMP1:%.*]] = shl nuw nsw i64 [[TMP0]], 3
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 8 [[PTR1]], i8 0, i64 [[TMP1]], i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 8 [[PTR:%.*]], i8 0, i64 [[TMP1]], i1 false)
; CHECK-NEXT: br label [[LOOP_BODY:%.*]]
; CHECK: loop.body:
; CHECK-NEXT: [[STOREMERGE4:%.*]] = phi i32 [ 0, [[LOOP_PH]] ], [ [[INC:%.*]], [[LOOP_BODY]] ]
; CHECK-NEXT: [[IDXPROM:%.*]] = sext i32 [[STOREMERGE4]] to i64
-; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i64, i64* [[PTR]], i64 [[IDXPROM]]
+; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i64, ptr [[PTR]], i64 [[IDXPROM]]
; CHECK-NEXT: [[INC]] = add nsw i32 [[STOREMERGE4]], 1
; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i32 [[INC]], [[SIZE]]
; CHECK-NEXT: br i1 [[CMP2]], label [[LOOP_BODY]], label [[LOOP_EXIT:%.*]]
@@ -1001,8 +980,8 @@ loop.ph:
loop.body:
%storemerge4 = phi i32 [ 0, %loop.ph ], [ %inc, %loop.body ]
%idxprom = sext i32 %storemerge4 to i64
- %arrayidx = getelementptr inbounds i64, i64* %ptr, i64 %idxprom
- store i64 0, i64* %arrayidx, align 8
+ %arrayidx = getelementptr inbounds i64, ptr %ptr, i64 %idxprom
+ store i64 0, ptr %arrayidx, align 8
%inc = add nsw i32 %storemerge4, 1
%cmp2 = icmp slt i32 %inc, %size
br i1 %cmp2, label %loop.body, label %loop.exit
@@ -1014,25 +993,23 @@ exit:
ret void
}
-define void @form_memcpy_narrow_size(i64* noalias %dst, i64* noalias %src, i32 %size) {
+define void @form_memcpy_narrow_size(ptr noalias %dst, ptr noalias %src, i32 %size) {
; CHECK-LABEL: @form_memcpy_narrow_size(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[DST1:%.*]] = bitcast i64* [[DST:%.*]] to i8*
-; CHECK-NEXT: [[SRC2:%.*]] = bitcast i64* [[SRC:%.*]] to i8*
; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt i32 [[SIZE:%.*]], 0
; CHECK-NEXT: br i1 [[CMP1]], label [[LOOP_PH:%.*]], label [[EXIT:%.*]]
; CHECK: loop.ph:
; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[SIZE]] to i64
; CHECK-NEXT: [[TMP1:%.*]] = shl nuw nsw i64 [[TMP0]], 3
-; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 [[DST1]], i8* align 8 [[SRC2]], i64 [[TMP1]], i1 false)
+; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[DST:%.*]], ptr align 8 [[SRC:%.*]], i64 [[TMP1]], i1 false)
; CHECK-NEXT: br label [[LOOP_BODY:%.*]]
; CHECK: loop.body:
; CHECK-NEXT: [[STOREMERGE4:%.*]] = phi i32 [ 0, [[LOOP_PH]] ], [ [[INC:%.*]], [[LOOP_BODY]] ]
; CHECK-NEXT: [[IDXPROM1:%.*]] = sext i32 [[STOREMERGE4]] to i64
-; CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds i64, i64* [[SRC]], i64 [[IDXPROM1]]
-; CHECK-NEXT: [[V:%.*]] = load i64, i64* [[ARRAYIDX1]], align 8
+; CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds i64, ptr [[SRC]], i64 [[IDXPROM1]]
+; CHECK-NEXT: [[V:%.*]] = load i64, ptr [[ARRAYIDX1]], align 8
; CHECK-NEXT: [[IDXPROM2:%.*]] = sext i32 [[STOREMERGE4]] to i64
-; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds i64, i64* [[DST]], i64 [[IDXPROM2]]
+; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds i64, ptr [[DST]], i64 [[IDXPROM2]]
; CHECK-NEXT: [[INC]] = add nsw i32 [[STOREMERGE4]], 1
; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i32 [[INC]], [[SIZE]]
; CHECK-NEXT: br i1 [[CMP2]], label [[LOOP_BODY]], label [[LOOP_EXIT:%.*]]
@@ -1051,11 +1028,11 @@ loop.ph:
loop.body:
%storemerge4 = phi i32 [ 0, %loop.ph ], [ %inc, %loop.body ]
%idxprom1 = sext i32 %storemerge4 to i64
- %arrayidx1 = getelementptr inbounds i64, i64* %src, i64 %idxprom1
- %v = load i64, i64* %arrayidx1, align 8
+ %arrayidx1 = getelementptr inbounds i64, ptr %src, i64 %idxprom1
+ %v = load i64, ptr %arrayidx1, align 8
%idxprom2 = sext i32 %storemerge4 to i64
- %arrayidx2 = getelementptr inbounds i64, i64* %dst, i64 %idxprom2
- store i64 %v, i64* %arrayidx2, align 8
+ %arrayidx2 = getelementptr inbounds i64, ptr %dst, i64 %idxprom2
+ store i64 %v, ptr %arrayidx2, align 8
%inc = add nsw i32 %storemerge4, 1
%cmp2 = icmp slt i32 %inc, %size
br i1 %cmp2, label %loop.body, label %loop.exit
@@ -1068,18 +1045,18 @@ exit:
}
;; Memmove formation.
-define void @PR46179_positive_stride(i8* %Src, i64 %Size) {
+define void @PR46179_positive_stride(ptr %Src, i64 %Size) {
; CHECK-LABEL: @PR46179_positive_stride(
; CHECK-NEXT: bb.nph:
-; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, i8* [[SRC:%.*]], i64 1
-; CHECK-NEXT: call void @llvm.memmove.p0i8.p0i8.i64(i8* align 1 [[SRC]], i8* align 1 [[SCEVGEP]], i64 [[SIZE:%.*]], i1 false)
+; CHECK-NEXT: [[UGLYGEP:%.*]] = getelementptr i8, ptr [[SRC:%.*]], i64 1
+; CHECK-NEXT: call void @llvm.memmove.p0.p0.i64(ptr align 1 [[SRC]], ptr align 1 [[UGLYGEP]], i64 [[SIZE:%.*]], i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ 0, [[BB_NPH:%.*]] ], [ [[INDVAR_NEXT:%.*]], [[FOR_BODY]] ]
; CHECK-NEXT: [[STEP:%.*]] = add nuw nsw i64 [[INDVAR]], 1
-; CHECK-NEXT: [[SRCI:%.*]] = getelementptr i8, i8* [[SRC]], i64 [[STEP]]
-; CHECK-NEXT: [[DESTI:%.*]] = getelementptr i8, i8* [[SRC]], i64 [[INDVAR]]
-; CHECK-NEXT: [[V:%.*]] = load i8, i8* [[SRCI]], align 1
+; CHECK-NEXT: [[SRCI:%.*]] = getelementptr i8, ptr [[SRC]], i64 [[STEP]]
+; CHECK-NEXT: [[DESTI:%.*]] = getelementptr i8, ptr [[SRC]], i64 [[INDVAR]]
+; CHECK-NEXT: [[V:%.*]] = load i8, ptr [[SRCI]], align 1
; CHECK-NEXT: [[INDVAR_NEXT]] = add i64 [[INDVAR]], 1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVAR_NEXT]], [[SIZE]]
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
@@ -1092,10 +1069,10 @@ bb.nph:
for.body: ; preds = %bb.nph, %for.body
%indvar = phi i64 [ 0, %bb.nph ], [ %indvar.next, %for.body ]
%Step = add nuw nsw i64 %indvar, 1
- %SrcI = getelementptr i8, i8* %Src, i64 %Step
- %DestI = getelementptr i8, i8* %Src, i64 %indvar
- %V = load i8, i8* %SrcI, align 1
- store i8 %V, i8* %DestI, align 1
+ %SrcI = getelementptr i8, ptr %Src, i64 %Step
+ %DestI = getelementptr i8, ptr %Src, i64 %indvar
+ %V = load i8, ptr %SrcI, align 1
+ store i8 %V, ptr %DestI, align 1
%indvar.next = add i64 %indvar, 1
%exitcond = icmp eq i64 %indvar.next, %Size
br i1 %exitcond, label %for.end, label %for.body
@@ -1104,20 +1081,20 @@ for.end: ; preds = %for.body, %entry
ret void
}
-declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg)
+declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg)
;; Memmove formation. We expect exactly same memmove result like in PR46179_positive_stride output.
-define void @loop_with_memcpy_PR46179_positive_stride(i8* %Src, i64 %Size) {
+define void @loop_with_memcpy_PR46179_positive_stride(ptr %Src, i64 %Size) {
; CHECK-LABEL: @loop_with_memcpy_PR46179_positive_stride(
; CHECK-NEXT: bb.nph:
-; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, i8* [[SRC:%.*]], i64 1
-; CHECK-NEXT: call void @llvm.memmove.p0i8.p0i8.i64(i8* align 1 [[SRC]], i8* align 1 [[SCEVGEP]], i64 [[SIZE:%.*]], i1 false)
+; CHECK-NEXT: [[UGLYGEP:%.*]] = getelementptr i8, ptr [[SRC:%.*]], i64 1
+; CHECK-NEXT: call void @llvm.memmove.p0.p0.i64(ptr align 1 [[SRC]], ptr align 1 [[UGLYGEP]], i64 [[SIZE:%.*]], i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ 0, [[BB_NPH:%.*]] ], [ [[INDVAR_NEXT:%.*]], [[FOR_BODY]] ]
; CHECK-NEXT: [[STEP:%.*]] = add nuw nsw i64 [[INDVAR]], 1
-; CHECK-NEXT: [[SRCI:%.*]] = getelementptr i8, i8* [[SRC]], i64 [[STEP]]
-; CHECK-NEXT: [[DESTI:%.*]] = getelementptr i8, i8* [[SRC]], i64 [[INDVAR]]
+; CHECK-NEXT: [[SRCI:%.*]] = getelementptr i8, ptr [[SRC]], i64 [[STEP]]
+; CHECK-NEXT: [[DESTI:%.*]] = getelementptr i8, ptr [[SRC]], i64 [[INDVAR]]
; CHECK-NEXT: [[INDVAR_NEXT]] = add i64 [[INDVAR]], 1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVAR_NEXT]], [[SIZE]]
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
@@ -1130,9 +1107,9 @@ bb.nph:
for.body: ; preds = %bb.nph, %for.body
%indvar = phi i64 [ 0, %bb.nph ], [ %indvar.next, %for.body ]
%Step = add nuw nsw i64 %indvar, 1
- %SrcI = getelementptr i8, i8* %Src, i64 %Step
- %DestI = getelementptr i8, i8* %Src, i64 %indvar
- call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %DestI, i8* align 1 %SrcI, i64 1, i1 false)
+ %SrcI = getelementptr i8, ptr %Src, i64 %Step
+ %DestI = getelementptr i8, ptr %Src, i64 %indvar
+ call void @llvm.memcpy.p0.p0.i64(ptr align 1 %DestI, ptr align 1 %SrcI, i64 1, i1 false)
%indvar.next = add i64 %indvar, 1
%exitcond = icmp eq i64 %indvar.next, %Size
br i1 %exitcond, label %for.end, label %for.body
@@ -1142,21 +1119,21 @@ for.end: ; preds = %for.body, %entry
}
;; Memmove formation.
-define void @PR46179_negative_stride(i8* %Src, i64 %Size) {
+define void @PR46179_negative_stride(ptr %Src, i64 %Size) {
; CHECK-LABEL: @PR46179_negative_stride(
; CHECK-NEXT: bb.nph:
; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt i64 [[SIZE:%.*]], 0
; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_END:%.*]]
; CHECK: for.body.preheader:
-; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, i8* [[SRC:%.*]], i64 1
-; CHECK-NEXT: call void @llvm.memmove.p0i8.p0i8.i64(i8* align 1 [[SCEVGEP]], i8* align 1 [[SRC]], i64 [[SIZE]], i1 false)
+; CHECK-NEXT: [[UGLYGEP:%.*]] = getelementptr i8, ptr [[SRC:%.*]], i64 1
+; CHECK-NEXT: call void @llvm.memmove.p0.p0.i64(ptr align 1 [[UGLYGEP]], ptr align 1 [[SRC]], i64 [[SIZE]], i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ [[STEP:%.*]], [[FOR_BODY]] ], [ [[SIZE]], [[FOR_BODY_PREHEADER]] ]
; CHECK-NEXT: [[STEP]] = add nsw i64 [[INDVAR]], -1
-; CHECK-NEXT: [[SRCI:%.*]] = getelementptr inbounds i8, i8* [[SRC]], i64 [[STEP]]
-; CHECK-NEXT: [[V:%.*]] = load i8, i8* [[SRCI]], align 1
-; CHECK-NEXT: [[DESTI:%.*]] = getelementptr inbounds i8, i8* [[SRC]], i64 [[INDVAR]]
+; CHECK-NEXT: [[SRCI:%.*]] = getelementptr inbounds i8, ptr [[SRC]], i64 [[STEP]]
+; CHECK-NEXT: [[V:%.*]] = load i8, ptr [[SRCI]], align 1
+; CHECK-NEXT: [[DESTI:%.*]] = getelementptr inbounds i8, ptr [[SRC]], i64 [[INDVAR]]
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp sgt i64 [[INDVAR]], 1
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_BODY]], label [[FOR_END_LOOPEXIT:%.*]]
; CHECK: for.end.loopexit:
@@ -1171,10 +1148,10 @@ bb.nph:
for.body: ; preds = %bb.nph, %.for.body
%indvar = phi i64 [ %Step, %for.body ], [ %Size, %bb.nph ]
%Step = add nsw i64 %indvar, -1
- %SrcI = getelementptr inbounds i8, i8* %Src, i64 %Step
- %V = load i8, i8* %SrcI, align 1
- %DestI = getelementptr inbounds i8, i8* %Src, i64 %indvar
- store i8 %V, i8* %DestI, align 1
+ %SrcI = getelementptr inbounds i8, ptr %Src, i64 %Step
+ %V = load i8, ptr %SrcI, align 1
+ %DestI = getelementptr inbounds i8, ptr %Src, i64 %indvar
+ store i8 %V, ptr %DestI, align 1
%exitcond = icmp sgt i64 %indvar, 1
br i1 %exitcond, label %for.body, label %for.end
@@ -1183,20 +1160,20 @@ for.end: ; preds = %.for.body, %bb.nph
}
;; Memmove formation. We expect exactly same memmove result like in PR46179_negative_stride output.
-define void @loop_with_memcpy_PR46179_negative_stride(i8* %Src, i64 %Size) {
+define void @loop_with_memcpy_PR46179_negative_stride(ptr %Src, i64 %Size) {
; CHECK-LABEL: @loop_with_memcpy_PR46179_negative_stride(
; CHECK-NEXT: bb.nph:
; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt i64 [[SIZE:%.*]], 0
; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_END:%.*]]
; CHECK: for.body.preheader:
-; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, i8* [[SRC:%.*]], i64 1
-; CHECK-NEXT: call void @llvm.memmove.p0i8.p0i8.i64(i8* align 1 [[SCEVGEP]], i8* align 1 [[SRC]], i64 [[SIZE]], i1 false)
+; CHECK-NEXT: [[UGLYGEP:%.*]] = getelementptr i8, ptr [[SRC:%.*]], i64 1
+; CHECK-NEXT: call void @llvm.memmove.p0.p0.i64(ptr align 1 [[UGLYGEP]], ptr align 1 [[SRC]], i64 [[SIZE]], i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ [[STEP:%.*]], [[FOR_BODY]] ], [ [[SIZE]], [[FOR_BODY_PREHEADER]] ]
; CHECK-NEXT: [[STEP]] = add nsw i64 [[INDVAR]], -1
-; CHECK-NEXT: [[SRCI:%.*]] = getelementptr inbounds i8, i8* [[SRC]], i64 [[STEP]]
-; CHECK-NEXT: [[DESTI:%.*]] = getelementptr inbounds i8, i8* [[SRC]], i64 [[INDVAR]]
+; CHECK-NEXT: [[SRCI:%.*]] = getelementptr inbounds i8, ptr [[SRC]], i64 [[STEP]]
+; CHECK-NEXT: [[DESTI:%.*]] = getelementptr inbounds i8, ptr [[SRC]], i64 [[INDVAR]]
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp sgt i64 [[INDVAR]], 1
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_BODY]], label [[FOR_END_LOOPEXIT:%.*]]
; CHECK: for.end.loopexit:
@@ -1211,9 +1188,9 @@ bb.nph:
for.body: ; preds = %bb.nph, %.for.body
%indvar = phi i64 [ %Step, %for.body ], [ %Size, %bb.nph ]
%Step = add nsw i64 %indvar, -1
- %SrcI = getelementptr inbounds i8, i8* %Src, i64 %Step
- %DestI = getelementptr inbounds i8, i8* %Src, i64 %indvar
- call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %DestI, i8* align 1 %SrcI, i64 1, i1 false)
+ %SrcI = getelementptr inbounds i8, ptr %Src, i64 %Step
+ %DestI = getelementptr inbounds i8, ptr %Src, i64 %indvar
+ call void @llvm.memcpy.p0.p0.i64(ptr align 1 %DestI, ptr align 1 %SrcI, i64 1, i1 false)
%exitcond = icmp sgt i64 %indvar, 1
br i1 %exitcond, label %for.body, label %for.end
@@ -1222,22 +1199,22 @@ for.end: ; preds = %.for.body, %bb.nph
}
;; Memmove formation.
-define void @loop_with_memcpy_stride16(i8* %Src, i64 %Size) {
+define void @loop_with_memcpy_stride16(ptr %Src, i64 %Size) {
; CHECK-LABEL: @loop_with_memcpy_stride16(
; CHECK-NEXT: bb.nph:
-; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, i8* [[SRC:%.*]], i64 16
+; CHECK-NEXT: [[UGLYGEP:%.*]] = getelementptr i8, ptr [[SRC:%.*]], i64 16
; CHECK-NEXT: [[SMAX:%.*]] = call i64 @llvm.smax.i64(i64 [[SIZE:%.*]], i64 16)
; CHECK-NEXT: [[TMP0:%.*]] = add nsw i64 [[SMAX]], -1
; CHECK-NEXT: [[TMP1:%.*]] = lshr i64 [[TMP0]], 4
; CHECK-NEXT: [[TMP2:%.*]] = shl nuw nsw i64 [[TMP1]], 4
; CHECK-NEXT: [[TMP3:%.*]] = add nuw i64 [[TMP2]], 16
-; CHECK-NEXT: call void @llvm.memmove.p0i8.p0i8.i64(i8* align 1 [[SRC]], i8* align 1 [[SCEVGEP]], i64 [[TMP3]], i1 false)
+; CHECK-NEXT: call void @llvm.memmove.p0.p0.i64(ptr align 1 [[SRC]], ptr align 1 [[UGLYGEP]], i64 [[TMP3]], i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ [[STEP:%.*]], [[FOR_BODY]] ], [ 0, [[BB_NPH:%.*]] ]
; CHECK-NEXT: [[STEP]] = add nuw nsw i64 [[INDVAR]], 16
-; CHECK-NEXT: [[SRCI:%.*]] = getelementptr inbounds i8, i8* [[SRC]], i64 [[STEP]]
-; CHECK-NEXT: [[DESTI:%.*]] = getelementptr inbounds i8, i8* [[SRC]], i64 [[INDVAR]]
+; CHECK-NEXT: [[SRCI:%.*]] = getelementptr inbounds i8, ptr [[SRC]], i64 [[STEP]]
+; CHECK-NEXT: [[DESTI:%.*]] = getelementptr inbounds i8, ptr [[SRC]], i64 [[INDVAR]]
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp slt i64 [[STEP]], [[SIZE]]
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_BODY]], label [[FOR_END:%.*]]
; CHECK: for.end:
@@ -1249,9 +1226,9 @@ bb.nph:
for.body: ; preds = %for.body, %bb.nph
%indvar = phi i64 [ %Step, %for.body ], [ 0, %bb.nph ]
%Step = add nuw nsw i64 %indvar, 16
- %SrcI = getelementptr inbounds i8, i8* %Src, i64 %Step
- %DestI = getelementptr inbounds i8, i8* %Src, i64 %indvar
- call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %DestI, i8* align 1 %SrcI, i64 16, i1 false)
+ %SrcI = getelementptr inbounds i8, ptr %Src, i64 %Step
+ %DestI = getelementptr inbounds i8, ptr %Src, i64 %indvar
+ call void @llvm.memcpy.p0.p0.i64(ptr align 1 %DestI, ptr align 1 %SrcI, i64 16, i1 false)
%exitcond = icmp slt i64 %Step, %Size
br i1 %exitcond, label %for.body, label %for.end
@@ -1260,17 +1237,17 @@ for.end: ; preds = %for.body
}
;; Do not form memmove from previous load when stride is positive.
-define void @do_not_form_memmove1(i8* %Src, i64 %Size) {
+define void @do_not_form_memmove1(ptr %Src, i64 %Size) {
; CHECK-LABEL: @do_not_form_memmove1(
; CHECK-NEXT: bb.nph:
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ 1, [[BB_NPH:%.*]] ], [ [[INDVAR_NEXT:%.*]], [[FOR_BODY]] ]
; CHECK-NEXT: [[STEP:%.*]] = add nuw nsw i64 [[INDVAR]], -1
-; CHECK-NEXT: [[SRCI:%.*]] = getelementptr i8, i8* [[SRC:%.*]], i64 [[STEP]]
-; CHECK-NEXT: [[DESTI:%.*]] = getelementptr i8, i8* [[SRC]], i64 [[INDVAR]]
-; CHECK-NEXT: [[V:%.*]] = load i8, i8* [[SRCI]], align 1
-; CHECK-NEXT: store i8 [[V]], i8* [[DESTI]], align 1
+; CHECK-NEXT: [[SRCI:%.*]] = getelementptr i8, ptr [[SRC:%.*]], i64 [[STEP]]
+; CHECK-NEXT: [[DESTI:%.*]] = getelementptr i8, ptr [[SRC]], i64 [[INDVAR]]
+; CHECK-NEXT: [[V:%.*]] = load i8, ptr [[SRCI]], align 1
+; CHECK-NEXT: store i8 [[V]], ptr [[DESTI]], align 1
; CHECK-NEXT: [[INDVAR_NEXT]] = add i64 [[INDVAR]], 1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVAR_NEXT]], [[SIZE:%.*]]
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
@@ -1283,10 +1260,10 @@ bb.nph:
for.body: ; preds = %bb.nph, %for.body
%indvar = phi i64 [ 1, %bb.nph ], [ %indvar.next, %for.body ]
%Step = add nuw nsw i64 %indvar, -1
- %SrcI = getelementptr i8, i8* %Src, i64 %Step
- %DestI = getelementptr i8, i8* %Src, i64 %indvar
- %V = load i8, i8* %SrcI, align 1
- store i8 %V, i8* %DestI, align 1
+ %SrcI = getelementptr i8, ptr %Src, i64 %Step
+ %DestI = getelementptr i8, ptr %Src, i64 %indvar
+ %V = load i8, ptr %SrcI, align 1
+ store i8 %V, ptr %DestI, align 1
%indvar.next = add i64 %indvar, 1
%exitcond = icmp eq i64 %indvar.next, %Size
br i1 %exitcond, label %for.end, label %for.body
@@ -1296,16 +1273,16 @@ for.end: ; preds = %for.body, %entry
}
;; Do not form memmove from previous load in memcpy when stride is positive.
-define void @do_not_form_memmove2(i8* %Src, i64 %Size) {
+define void @do_not_form_memmove2(ptr %Src, i64 %Size) {
; CHECK-LABEL: @do_not_form_memmove2(
; CHECK-NEXT: bb.nph:
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ 1, [[BB_NPH:%.*]] ], [ [[INDVAR_NEXT:%.*]], [[FOR_BODY]] ]
; CHECK-NEXT: [[STEP:%.*]] = add nuw nsw i64 [[INDVAR]], -1
-; CHECK-NEXT: [[SRCI:%.*]] = getelementptr i8, i8* [[SRC:%.*]], i64 [[STEP]]
-; CHECK-NEXT: [[DESTI:%.*]] = getelementptr i8, i8* [[SRC]], i64 [[INDVAR]]
-; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 [[DESTI]], i8* align 1 [[SRCI]], i64 1, i1 false)
+; CHECK-NEXT: [[SRCI:%.*]] = getelementptr i8, ptr [[SRC:%.*]], i64 [[STEP]]
+; CHECK-NEXT: [[DESTI:%.*]] = getelementptr i8, ptr [[SRC]], i64 [[INDVAR]]
+; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 [[DESTI]], ptr align 1 [[SRCI]], i64 1, i1 false)
; CHECK-NEXT: [[INDVAR_NEXT]] = add i64 [[INDVAR]], 1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVAR_NEXT]], [[SIZE:%.*]]
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
@@ -1318,9 +1295,9 @@ bb.nph:
for.body: ; preds = %bb.nph, %for.body
%indvar = phi i64 [ 1, %bb.nph ], [ %indvar.next, %for.body ]
%Step = add nuw nsw i64 %indvar, -1
- %SrcI = getelementptr i8, i8* %Src, i64 %Step
- %DestI = getelementptr i8, i8* %Src, i64 %indvar
- call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %DestI, i8* align 1 %SrcI, i64 1, i1 false)
+ %SrcI = getelementptr i8, ptr %Src, i64 %Step
+ %DestI = getelementptr i8, ptr %Src, i64 %indvar
+ call void @llvm.memcpy.p0.p0.i64(ptr align 1 %DestI, ptr align 1 %SrcI, i64 1, i1 false)
%indvar.next = add i64 %indvar, 1
%exitcond = icmp eq i64 %indvar.next, %Size
br i1 %exitcond, label %for.end, label %for.body
@@ -1330,7 +1307,7 @@ for.end: ; preds = %for.body, %entry
}
;; Do not form memmove from next load when stride is negative.
-define void @do_not_form_memmove3(i8* %Src, i64 %Size) {
+define void @do_not_form_memmove3(ptr %Src, i64 %Size) {
; CHECK-LABEL: @do_not_form_memmove3(
; CHECK-NEXT: bb.nph:
; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt i64 [[SIZE:%.*]], 0
@@ -1340,10 +1317,10 @@ define void @do_not_form_memmove3(i8* %Src, i64 %Size) {
; CHECK: for.body:
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ [[INDVAR_NEXT:%.*]], [[FOR_BODY]] ], [ [[SIZE]], [[FOR_BODY_PREHEADER]] ]
; CHECK-NEXT: [[STEP:%.*]] = add nuw nsw i64 [[INDVAR]], 1
-; CHECK-NEXT: [[SRCI:%.*]] = getelementptr inbounds i8, i8* [[SRC:%.*]], i64 [[STEP]]
-; CHECK-NEXT: [[V:%.*]] = load i8, i8* [[SRCI]], align 1
-; CHECK-NEXT: [[DESTI:%.*]] = getelementptr inbounds i8, i8* [[SRC]], i64 [[INDVAR]]
-; CHECK-NEXT: store i8 [[V]], i8* [[DESTI]], align 1
+; CHECK-NEXT: [[SRCI:%.*]] = getelementptr inbounds i8, ptr [[SRC:%.*]], i64 [[STEP]]
+; CHECK-NEXT: [[V:%.*]] = load i8, ptr [[SRCI]], align 1
+; CHECK-NEXT: [[DESTI:%.*]] = getelementptr inbounds i8, ptr [[SRC]], i64 [[INDVAR]]
+; CHECK-NEXT: store i8 [[V]], ptr [[DESTI]], align 1
; CHECK-NEXT: [[INDVAR_NEXT]] = add nsw i64 [[INDVAR]], -1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp sgt i64 [[INDVAR]], 1
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_BODY]], label [[FOR_END_LOOPEXIT:%.*]]
@@ -1359,10 +1336,10 @@ bb.nph:
for.body: ; preds = %bb.nph, %.for.body
%indvar = phi i64 [ %indvar.next, %for.body ], [ %Size, %bb.nph ]
%Step = add nuw nsw i64 %indvar, 1
- %SrcI = getelementptr inbounds i8, i8* %Src, i64 %Step
- %V = load i8, i8* %SrcI, align 1
- %DestI = getelementptr inbounds i8, i8* %Src, i64 %indvar
- store i8 %V, i8* %DestI, align 1
+ %SrcI = getelementptr inbounds i8, ptr %Src, i64 %Step
+ %V = load i8, ptr %SrcI, align 1
+ %DestI = getelementptr inbounds i8, ptr %Src, i64 %indvar
+ store i8 %V, ptr %DestI, align 1
%indvar.next = add nsw i64 %indvar, -1
%exitcond = icmp sgt i64 %indvar, 1
br i1 %exitcond, label %for.body, label %for.end
@@ -1372,7 +1349,7 @@ for.end: ; preds = %.for.body, %bb.nph
}
;; Do not form memmove from next load in memcpy when stride is negative.
-define void @do_not_form_memmove4(i8* %Src, i64 %Size) {
+define void @do_not_form_memmove4(ptr %Src, i64 %Size) {
; CHECK-LABEL: @do_not_form_memmove4(
; CHECK-NEXT: bb.nph:
; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt i64 [[SIZE:%.*]], 0
@@ -1382,9 +1359,9 @@ define void @do_not_form_memmove4(i8* %Src, i64 %Size) {
; CHECK: for.body:
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ [[INDVAR_NEXT:%.*]], [[FOR_BODY]] ], [ [[SIZE]], [[FOR_BODY_PREHEADER]] ]
; CHECK-NEXT: [[STEP:%.*]] = add nuw nsw i64 [[INDVAR]], 1
-; CHECK-NEXT: [[SRCI:%.*]] = getelementptr inbounds i8, i8* [[SRC:%.*]], i64 [[STEP]]
-; CHECK-NEXT: [[DESTI:%.*]] = getelementptr inbounds i8, i8* [[SRC]], i64 [[INDVAR]]
-; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 [[DESTI]], i8* align 1 [[SRCI]], i64 1, i1 false)
+; CHECK-NEXT: [[SRCI:%.*]] = getelementptr inbounds i8, ptr [[SRC:%.*]], i64 [[STEP]]
+; CHECK-NEXT: [[DESTI:%.*]] = getelementptr inbounds i8, ptr [[SRC]], i64 [[INDVAR]]
+; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 [[DESTI]], ptr align 1 [[SRCI]], i64 1, i1 false)
; CHECK-NEXT: [[INDVAR_NEXT]] = add nsw i64 [[INDVAR]], -1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp sgt i64 [[INDVAR]], 1
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_BODY]], label [[FOR_END_LOOPEXIT:%.*]]
@@ -1400,9 +1377,9 @@ bb.nph:
for.body: ; preds = %bb.nph, %.for.body
%indvar = phi i64 [ %indvar.next, %for.body ], [ %Size, %bb.nph ]
%Step = add nuw nsw i64 %indvar, 1
- %SrcI = getelementptr inbounds i8, i8* %Src, i64 %Step
- %DestI = getelementptr inbounds i8, i8* %Src, i64 %indvar
- call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %DestI, i8* align 1 %SrcI, i64 1, i1 false)
+ %SrcI = getelementptr inbounds i8, ptr %Src, i64 %Step
+ %DestI = getelementptr inbounds i8, ptr %Src, i64 %indvar
+ call void @llvm.memcpy.p0.p0.i64(ptr align 1 %DestI, ptr align 1 %SrcI, i64 1, i1 false)
%indvar.next = add nsw i64 %indvar, -1
%exitcond = icmp sgt i64 %indvar, 1
br i1 %exitcond, label %for.body, label %for.end
@@ -1412,42 +1389,36 @@ for.end: ; preds = %.for.body, %bb.nph
}
;; Do not form memmove when underaligned load is overlapped with store.
-define void @do_not_form_memmove5(i32* %s, i64 %size) {
+define void @do_not_form_memmove5(ptr %s, i64 %size) {
; CHECK-LABEL: @do_not_form_memmove5(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[END_IDX:%.*]] = add i64 [[SIZE:%.*]], -1
-; CHECK-NEXT: [[END_PTR:%.*]] = getelementptr inbounds i32, i32* [[S:%.*]], i64 [[END_IDX]]
+; CHECK-NEXT: [[END_PTR:%.*]] = getelementptr inbounds i32, ptr [[S:%.*]], i64 [[END_IDX]]
; CHECK-NEXT: br label [[WHILE_BODY:%.*]]
; CHECK: while.body:
-; CHECK-NEXT: [[PHI_PTR:%.*]] = phi i32* [ [[S]], [[ENTRY:%.*]] ], [ [[NEXT_PTR:%.*]], [[WHILE_BODY]] ]
-; CHECK-NEXT: [[NEXT:%.*]] = bitcast i32* [[PHI_PTR]] to i16*
-; CHECK-NEXT: [[SRC_PTR:%.*]] = getelementptr i16, i16* [[NEXT]], i64 1
-; CHECK-NEXT: [[SRC_PTR2:%.*]] = bitcast i16* [[SRC_PTR]] to i32*
-; CHECK-NEXT: [[VAL:%.*]] = load i32, i32* [[SRC_PTR2]], align 2
-; CHECK-NEXT: [[DST_PTR:%.*]] = getelementptr i32, i32* [[PHI_PTR]], i64 0
-; CHECK-NEXT: store i32 [[VAL]], i32* [[DST_PTR]], align 4
-; CHECK-NEXT: [[NEXT_PTR]] = getelementptr i32, i32* [[PHI_PTR]], i64 1
-; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32* [[NEXT_PTR]], [[END_PTR]]
+; CHECK-NEXT: [[PHI_PTR:%.*]] = phi ptr [ [[S]], [[ENTRY:%.*]] ], [ [[NEXT_PTR:%.*]], [[WHILE_BODY]] ]
+; CHECK-NEXT: [[SRC_PTR:%.*]] = getelementptr i16, ptr [[PHI_PTR]], i64 1
+; CHECK-NEXT: [[VAL:%.*]] = load i32, ptr [[SRC_PTR]], align 2
+; CHECK-NEXT: store i32 [[VAL]], ptr [[PHI_PTR]], align 4
+; CHECK-NEXT: [[NEXT_PTR]] = getelementptr i32, ptr [[PHI_PTR]], i64 1
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq ptr [[NEXT_PTR]], [[END_PTR]]
; CHECK-NEXT: br i1 [[CMP]], label [[EXIT:%.*]], label [[WHILE_BODY]]
; CHECK: exit:
; CHECK-NEXT: ret void
;
entry:
%end.idx = add i64 %size, -1
- %end.ptr = getelementptr inbounds i32, i32* %s, i64 %end.idx
+ %end.ptr = getelementptr inbounds i32, ptr %s, i64 %end.idx
br label %while.body
while.body:
- %phi.ptr = phi i32* [ %s, %entry ], [ %next.ptr, %while.body ]
- %next = bitcast i32* %phi.ptr to i16*
- %src.ptr = getelementptr i16, i16* %next, i64 1
- %src.ptr2 = bitcast i16* %src.ptr to i32*
+ %phi.ptr = phi ptr [ %s, %entry ], [ %next.ptr, %while.body ]
+ %src.ptr = getelementptr i16, ptr %phi.ptr, i64 1
; below underaligned load is overlapped with store.
- %val = load i32, i32* %src.ptr2, align 2
- %dst.ptr = getelementptr i32, i32* %phi.ptr, i64 0
- store i32 %val, i32* %dst.ptr, align 4
- %next.ptr = getelementptr i32, i32* %phi.ptr, i64 1
- %cmp = icmp eq i32* %next.ptr, %end.ptr
+ %val = load i32, ptr %src.ptr, align 2
+ store i32 %val, ptr %phi.ptr, align 4
+ %next.ptr = getelementptr i32, ptr %phi.ptr, i64 1
+ %cmp = icmp eq ptr %next.ptr, %end.ptr
br i1 %cmp, label %exit, label %while.body
exit:
@@ -1455,18 +1426,18 @@ exit:
}
;; Do not form memmove for memcpy with aliasing store.
-define void @do_not_form_memmove6(i8* %Src, i64 %Size) {
+define void @do_not_form_memmove6(ptr %Src, i64 %Size) {
; CHECK-LABEL: @do_not_form_memmove6(
; CHECK-NEXT: bb.nph:
-; CHECK-NEXT: [[BASEALIAS:%.*]] = call i8* @external(i8* [[SRC:%.*]])
+; CHECK-NEXT: [[BASEALIAS:%.*]] = call ptr @external(ptr [[SRC:%.*]])
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ 0, [[BB_NPH:%.*]] ], [ [[INDVAR_NEXT:%.*]], [[FOR_BODY]] ]
; CHECK-NEXT: [[STEP:%.*]] = add nuw nsw i64 [[INDVAR]], 1
-; CHECK-NEXT: [[SRCI:%.*]] = getelementptr i8, i8* [[SRC]], i64 [[STEP]]
-; CHECK-NEXT: [[DESTI:%.*]] = getelementptr i8, i8* [[SRC]], i64 [[INDVAR]]
-; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 [[DESTI]], i8* align 1 [[SRCI]], i64 1, i1 false)
-; CHECK-NEXT: store i8 4, i8* [[BASEALIAS]], align 1
+; CHECK-NEXT: [[SRCI:%.*]] = getelementptr i8, ptr [[SRC]], i64 [[STEP]]
+; CHECK-NEXT: [[DESTI:%.*]] = getelementptr i8, ptr [[SRC]], i64 [[INDVAR]]
+; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 [[DESTI]], ptr align 1 [[SRCI]], i64 1, i1 false)
+; CHECK-NEXT: store i8 4, ptr [[BASEALIAS]], align 1
; CHECK-NEXT: [[INDVAR_NEXT]] = add i64 [[INDVAR]], 1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVAR_NEXT]], [[SIZE:%.*]]
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
@@ -1474,16 +1445,16 @@ define void @do_not_form_memmove6(i8* %Src, i64 %Size) {
; CHECK-NEXT: ret void
;
bb.nph:
- %BaseAlias = call i8* @external(i8* %Src)
+ %BaseAlias = call ptr @external(ptr %Src)
br label %for.body
for.body: ; preds = %bb.nph, %for.body
%indvar = phi i64 [ 0, %bb.nph ], [ %indvar.next, %for.body ]
%Step = add nuw nsw i64 %indvar, 1
- %SrcI = getelementptr i8, i8* %Src, i64 %Step
- %DestI = getelementptr i8, i8* %Src, i64 %indvar
- call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %DestI, i8* align 1 %SrcI, i64 1, i1 false)
- store i8 4, i8* %BaseAlias
+ %SrcI = getelementptr i8, ptr %Src, i64 %Step
+ %DestI = getelementptr i8, ptr %Src, i64 %indvar
+ call void @llvm.memcpy.p0.p0.i64(ptr align 1 %DestI, ptr align 1 %SrcI, i64 1, i1 false)
+ store i8 4, ptr %BaseAlias
%indvar.next = add i64 %indvar, 1
%exitcond = icmp eq i64 %indvar.next, %Size
br i1 %exitcond, label %for.end, label %for.body
@@ -1493,7 +1464,7 @@ for.end: ; preds = %for.body, %entry
}
;; Do not form memmove when load has more than one use.
-define i32 @do_not_form_memmove7(i32* %p) {
+define i32 @do_not_form_memmove7(ptr %p) {
; CHECK-LABEL: @do_not_form_memmove7(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
@@ -1505,11 +1476,11 @@ define i32 @do_not_form_memmove7(i32* %p) {
; CHECK-NEXT: [[SUM:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[ADD]], [[FOR_BODY]] ]
; CHECK-NEXT: [[SUB]] = add nsw i32 [[INDEX]], -1
; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[SUB]] to i64
-; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[P:%.*]], i64 [[TMP0]]
-; CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* [[ARRAYIDX]], align 4
+; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[P:%.*]], i64 [[TMP0]]
+; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
; CHECK-NEXT: [[IDXPROM:%.*]] = zext i32 [[INDEX]] to i64
-; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds i32, i32* [[P]], i64 [[IDXPROM]]
-; CHECK-NEXT: store i32 [[TMP1]], i32* [[ARRAYIDX2]], align 4
+; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds i32, ptr [[P]], i64 [[IDXPROM]]
+; CHECK-NEXT: store i32 [[TMP1]], ptr [[ARRAYIDX2]], align 4
; CHECK-NEXT: [[ADD]] = add nsw i32 [[TMP1]], [[SUM]]
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[INDEX]], 1
; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_COND_CLEANUP:%.*]]
@@ -1526,11 +1497,11 @@ for.body: ; preds = %entry, %for.body
%sum = phi i32 [ 0, %entry ], [ %add, %for.body ]
%sub = add nsw i32 %index, -1
%0 = zext i32 %sub to i64
- %arrayidx = getelementptr inbounds i32, i32* %p, i64 %0
- %1 = load i32, i32* %arrayidx, align 4
+ %arrayidx = getelementptr inbounds i32, ptr %p, i64 %0
+ %1 = load i32, ptr %arrayidx, align 4
%idxprom = zext i32 %index to i64
- %arrayidx2 = getelementptr inbounds i32, i32* %p, i64 %idxprom
- store i32 %1, i32* %arrayidx2, align 4
+ %arrayidx2 = getelementptr inbounds i32, ptr %p, i64 %idxprom
+ store i32 %1, ptr %arrayidx2, align 4
%add = add nsw i32 %1, %sum
%cmp = icmp sgt i32 %index, 1
br i1 %cmp, label %for.body, label %for.cond.cleanup
@@ -1538,28 +1509,26 @@ for.body: ; preds = %entry, %for.body
; Do not form memmove when there's an aliasing operation, even
; if the memcpy source and destination are in the same object.
-define void @do_not_form_memmove8(i64* %p) {
+define void @do_not_form_memmove8(ptr %p) {
; CHECK-LABEL: @do_not_form_memmove8(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[P2:%.*]] = getelementptr inbounds i64, i64* [[P:%.*]], i64 1000
+; CHECK-NEXT: [[P2:%.*]] = getelementptr inbounds i64, ptr [[P:%.*]], i64 1000
; CHECK-NEXT: br label [[LOOP:%.*]]
; CHECK: exit:
; CHECK-NEXT: ret void
; CHECK: loop:
; CHECK-NEXT: [[X4:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[X13:%.*]], [[LOOP]] ]
; CHECK-NEXT: [[X5:%.*]] = zext i32 [[X4]] to i64
-; CHECK-NEXT: [[X7:%.*]] = getelementptr inbounds i64, i64* [[P2]], i64 [[X5]]
-; CHECK-NEXT: [[X8:%.*]] = bitcast i64* [[X7]] to i8*
-; CHECK-NEXT: store i64 1, i64* [[X7]], align 4
-; CHECK-NEXT: [[X11:%.*]] = getelementptr inbounds i64, i64* [[P]], i64 [[X5]]
-; CHECK-NEXT: [[X12:%.*]] = bitcast i64* [[X11]] to i8*
-; CHECK-NEXT: tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[X12]], i8* [[X8]], i64 8, i1 false)
+; CHECK-NEXT: [[X7:%.*]] = getelementptr inbounds i64, ptr [[P2]], i64 [[X5]]
+; CHECK-NEXT: store i64 1, ptr [[X7]], align 4
+; CHECK-NEXT: [[X11:%.*]] = getelementptr inbounds i64, ptr [[P]], i64 [[X5]]
+; CHECK-NEXT: tail call void @llvm.memcpy.p0.p0.i64(ptr [[X11]], ptr [[X7]], i64 8, i1 false)
; CHECK-NEXT: [[X13]] = add i32 [[X4]], 1
; CHECK-NEXT: [[X14:%.*]] = icmp eq i32 [[X13]], 44
; CHECK-NEXT: br i1 [[X14]], label [[EXIT:%.*]], label [[LOOP]]
;
entry:
- %p2 = getelementptr inbounds i64, i64* %p, i64 1000
+ %p2 = getelementptr inbounds i64, ptr %p, i64 1000
br label %loop
exit:
@@ -1568,30 +1537,28 @@ exit:
loop:
%x4 = phi i32 [ 0, %entry ], [ %x13, %loop ]
%x5 = zext i32 %x4 to i64
- %x7 = getelementptr inbounds i64, i64* %p2, i64 %x5
- %x8 = bitcast i64* %x7 to i8*
- store i64 1, i64* %x7, align 4
- %x11 = getelementptr inbounds i64, i64* %p, i64 %x5
- %x12 = bitcast i64* %x11 to i8*
- tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %x12, i8* %x8, i64 8, i1 false)
+ %x7 = getelementptr inbounds i64, ptr %p2, i64 %x5
+ store i64 1, ptr %x7, align 4
+ %x11 = getelementptr inbounds i64, ptr %p, i64 %x5
+ tail call void @llvm.memcpy.p0.p0.i64(ptr %x11, ptr %x7, i64 8, i1 false)
%x13 = add i32 %x4, 1
%x14 = icmp eq i32 %x13, 44
br i1 %x14, label %exit, label %loop
}
;; Memcpy formation is still preferred over memmove.
-define void @prefer_memcpy_over_memmove(i8* noalias %Src, i8* noalias %Dest, i64 %Size) {
+define void @prefer_memcpy_over_memmove(ptr noalias %Src, ptr noalias %Dest, i64 %Size) {
; CHECK-LABEL: @prefer_memcpy_over_memmove(
; CHECK-NEXT: bb.nph:
-; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, i8* [[SRC:%.*]], i64 42
-; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 [[DEST:%.*]], i8* align 1 [[SCEVGEP]], i64 [[SIZE:%.*]], i1 false)
+; CHECK-NEXT: [[UGLYGEP:%.*]] = getelementptr i8, ptr [[SRC:%.*]], i64 42
+; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 [[DEST:%.*]], ptr align 1 [[UGLYGEP]], i64 [[SIZE:%.*]], i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ 0, [[BB_NPH:%.*]] ], [ [[INDVAR_NEXT:%.*]], [[FOR_BODY]] ]
; CHECK-NEXT: [[STEP:%.*]] = add nuw nsw i64 [[INDVAR]], 42
-; CHECK-NEXT: [[SRCI:%.*]] = getelementptr i8, i8* [[SRC]], i64 [[STEP]]
-; CHECK-NEXT: [[DESTI:%.*]] = getelementptr i8, i8* [[DEST]], i64 [[INDVAR]]
-; CHECK-NEXT: [[V:%.*]] = load i8, i8* [[SRCI]], align 1
+; CHECK-NEXT: [[SRCI:%.*]] = getelementptr i8, ptr [[SRC]], i64 [[STEP]]
+; CHECK-NEXT: [[DESTI:%.*]] = getelementptr i8, ptr [[DEST]], i64 [[INDVAR]]
+; CHECK-NEXT: [[V:%.*]] = load i8, ptr [[SRCI]], align 1
; CHECK-NEXT: [[INDVAR_NEXT]] = add i64 [[INDVAR]], 1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVAR_NEXT]], [[SIZE]]
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
@@ -1604,10 +1571,10 @@ bb.nph:
for.body: ; preds = %bb.nph, %for.body
%indvar = phi i64 [ 0, %bb.nph ], [ %indvar.next, %for.body ]
%Step = add nuw nsw i64 %indvar, 42
- %SrcI = getelementptr i8, i8* %Src, i64 %Step
- %DestI = getelementptr i8, i8* %Dest, i64 %indvar
- %V = load i8, i8* %SrcI, align 1
- store i8 %V, i8* %DestI, align 1
+ %SrcI = getelementptr i8, ptr %Src, i64 %Step
+ %DestI = getelementptr i8, ptr %Dest, i64 %indvar
+ %V = load i8, ptr %SrcI, align 1
+ store i8 %V, ptr %DestI, align 1
%indvar.next = add i64 %indvar, 1
%exitcond = icmp eq i64 %indvar.next, %Size
br i1 %exitcond, label %for.end, label %for.body
diff --git a/llvm/test/Transforms/LoopIdiom/memcpy-debugify-remarks.ll b/llvm/test/Transforms/LoopIdiom/memcpy-debugify-remarks.ll
index 43606db8d4ab4..264f34dd044af 100644
--- a/llvm/test/Transforms/LoopIdiom/memcpy-debugify-remarks.ll
+++ b/llvm/test/Transforms/LoopIdiom/memcpy-debugify-remarks.ll
@@ -7,7 +7,7 @@ target triple = "x86_64-unknown-linux-gnu"
; Check that everything still works when debuginfo is present, and that it is reasonably propagated.
-; CHECK: remark: <stdin>:6:1: Formed a call to llvm.memcpy.p0i8.p0i8.i64() intrinsic from load and store instruction in test6_dest_align function{{$}}
+; CHECK: remark: <stdin>:6:1: Formed a call to llvm.memcpy.p0.p0.i64() intrinsic from load and store instruction in test6_dest_align function{{$}}
; YAML: --- !Passed
; YAML-NEXT: Pass: loop-idiom
@@ -16,7 +16,7 @@ target triple = "x86_64-unknown-linux-gnu"
; YAML-NEXT: Function: test6_dest_align
; YAML-NEXT: Args:
; YAML-NEXT: - String: 'Formed a call to '
-; YAML-NEXT: - NewFunction: llvm.memcpy.p0i8.p0i8.i64
+; YAML-NEXT: - NewFunction: llvm.memcpy.p0.p0.i64
; YAML-NEXT: - String: '() intrinsic from '
; YAML-NEXT: - Inst: load and store
; YAML-NEXT: - String: ' instruction in '
@@ -27,22 +27,20 @@ target triple = "x86_64-unknown-linux-gnu"
; YAML-NEXT: - ToBlock: bb.nph
; YAML-NEXT: ...
-define void @test6_dest_align(i32* noalias align 1 %Base, i32* noalias align 4 %Dest, i64 %Size) nounwind ssp {
+define void @test6_dest_align(ptr noalias align 1 %Base, ptr noalias align 4 %Dest, i64 %Size) nounwind ssp {
; CHECK-LABEL: @test6_dest_align(
; CHECK-NEXT: bb.nph:
-; CHECK-NEXT: [[DEST1:%.*]] = bitcast i32* [[DEST:%.*]] to i8*, !dbg [[DBG18:![0-9]+]]
-; CHECK-NEXT: [[BASE2:%.*]] = bitcast i32* [[BASE:%.*]] to i8*, !dbg [[DBG18]]
-; CHECK-NEXT: [[TMP0:%.*]] = shl nuw i64 [[SIZE:%.*]], 2, !dbg [[DBG18]]
-; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 [[DEST1]], i8* align 1 [[BASE2]], i64 [[TMP0]], i1 false), !dbg [[DBG19:![0-9]+]]
+; CHECK-NEXT: [[TMP0:%.*]] = shl nuw i64 [[SIZE:%.*]], 2, !dbg [[DBG18:![0-9]+]]
+; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 [[DEST:%.*]], ptr align 1 [[BASE:%.*]], i64 [[TMP0]], i1 false), !dbg [[DBG19:![0-9]+]]
; CHECK-NEXT: br label [[FOR_BODY:%.*]], !dbg [[DBG18]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ 0, [[BB_NPH:%.*]] ], [ [[INDVAR_NEXT:%.*]], [[FOR_BODY]] ], !dbg [[DBG20:![0-9]+]]
; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 [[INDVAR]], metadata [[META9:![0-9]+]], metadata !DIExpression()), !dbg [[DBG20]]
-; CHECK-NEXT: [[I_0_014:%.*]] = getelementptr i32, i32* [[BASE]], i64 [[INDVAR]], !dbg [[DBG21:![0-9]+]]
-; CHECK-NEXT: call void @llvm.dbg.value(metadata i32* [[I_0_014]], metadata [[META11:![0-9]+]], metadata !DIExpression()), !dbg [[DBG21]]
-; CHECK-NEXT: [[DESTI:%.*]] = getelementptr i32, i32* [[DEST]], i64 [[INDVAR]], !dbg [[DBG22:![0-9]+]]
-; CHECK-NEXT: call void @llvm.dbg.value(metadata i32* [[DESTI]], metadata [[META12:![0-9]+]], metadata !DIExpression()), !dbg [[DBG22]]
-; CHECK-NEXT: [[V:%.*]] = load i32, i32* [[I_0_014]], align 1, !dbg [[DBG23:![0-9]+]]
+; CHECK-NEXT: [[I_0_014:%.*]] = getelementptr i32, ptr [[BASE]], i64 [[INDVAR]], !dbg [[DBG21:![0-9]+]]
+; CHECK-NEXT: call void @llvm.dbg.value(metadata ptr [[I_0_014]], metadata [[META11:![0-9]+]], metadata !DIExpression()), !dbg [[DBG21]]
+; CHECK-NEXT: [[DESTI:%.*]] = getelementptr i32, ptr [[DEST]], i64 [[INDVAR]], !dbg [[DBG22:![0-9]+]]
+; CHECK-NEXT: call void @llvm.dbg.value(metadata ptr [[DESTI]], metadata [[META12:![0-9]+]], metadata !DIExpression()), !dbg [[DBG22]]
+; CHECK-NEXT: [[V:%.*]] = load i32, ptr [[I_0_014]], align 1, !dbg [[DBG23:![0-9]+]]
; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[V]], metadata [[META13:![0-9]+]], metadata !DIExpression()), !dbg [[DBG23]]
; CHECK-NEXT: [[INDVAR_NEXT]] = add i64 [[INDVAR]], 1, !dbg [[DBG24:![0-9]+]]
; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 [[INDVAR_NEXT]], metadata [[META15:![0-9]+]], metadata !DIExpression()), !dbg [[DBG24]]
@@ -57,10 +55,10 @@ bb.nph:
for.body: ; preds = %bb.nph, %for.body
%indvar = phi i64 [ 0, %bb.nph ], [ %indvar.next, %for.body ]
- %I.0.014 = getelementptr i32, i32* %Base, i64 %indvar
- %DestI = getelementptr i32, i32* %Dest, i64 %indvar
- %V = load i32, i32* %I.0.014, align 1
- store i32 %V, i32* %DestI, align 4
+ %I.0.014 = getelementptr i32, ptr %Base, i64 %indvar
+ %DestI = getelementptr i32, ptr %Dest, i64 %indvar
+ %V = load i32, ptr %I.0.014, align 1
+ store i32 %V, ptr %DestI, align 4
%indvar.next = add i64 %indvar, 1
%exitcond = icmp eq i64 %indvar.next, %Size
br i1 %exitcond, label %for.end, label %for.body
diff --git a/llvm/test/Transforms/LoopIdiom/memcpy-intrinsic.ll b/llvm/test/Transforms/LoopIdiom/memcpy-intrinsic.ll
index 54fad34d60e7a..fb56e61509635 100644
--- a/llvm/test/Transforms/LoopIdiom/memcpy-intrinsic.ll
+++ b/llvm/test/Transforms/LoopIdiom/memcpy-intrinsic.ll
@@ -11,17 +11,15 @@
; }
; Function Attrs: nofree nounwind uwtable mustprogress
-define dso_local i32 @copy_noalias(%struct.S* noalias nocapture %a, %struct.S* nocapture readonly %b, i32 %n) local_unnamed_addr {
+define dso_local i32 @copy_noalias(ptr noalias nocapture %a, ptr nocapture readonly %b, i32 %n) local_unnamed_addr {
; CHECK-LABEL: @copy_noalias(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[A1:%.*]] = bitcast %struct.S* [[A:%.*]] to i8*
-; CHECK-NEXT: [[B2:%.*]] = bitcast %struct.S* [[B:%.*]] to i8*
; CHECK-NEXT: [[CMP7:%.*]] = icmp sgt i32 [[N:%.*]], 0
; CHECK-NEXT: br i1 [[CMP7]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_COND_CLEANUP:%.*]]
; CHECK: for.body.preheader:
; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[N]] to i64
; CHECK-NEXT: [[TMP1:%.*]] = mul nuw nsw i64 [[TMP0]], 12
-; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 [[A1]], i8* align 4 [[B2]], i64 [[TMP1]], i1 false)
+; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 [[A:%.*]], ptr align 4 [[B:%.*]], i64 [[TMP1]], i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.cond.cleanup.loopexit:
; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
@@ -30,10 +28,8 @@ define dso_local i32 @copy_noalias(%struct.S* noalias nocapture %a, %struct.S* n
; CHECK: for.body:
; CHECK-NEXT: [[I_08:%.*]] = phi i32 [ [[INC:%.*]], [[FOR_BODY]] ], [ 0, [[FOR_BODY_PREHEADER]] ]
; CHECK-NEXT: [[IDXPROM:%.*]] = zext i32 [[I_08]] to i64
-; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [[STRUCT_S:%.*]], %struct.S* [[B]], i64 [[IDXPROM]]
-; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds [[STRUCT_S]], %struct.S* [[A]], i64 [[IDXPROM]]
-; CHECK-NEXT: [[I:%.*]] = bitcast %struct.S* [[ARRAYIDX2]] to i8*
-; CHECK-NEXT: [[I1:%.*]] = bitcast %struct.S* [[ARRAYIDX]] to i8*
+; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [[STRUCT_S:%.*]], ptr [[B]], i64 [[IDXPROM]]
+; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[A]], i64 [[IDXPROM]]
; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_08]], 1
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[INC]], [[N]]
; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_COND_CLEANUP_LOOPEXIT:%.*]]
@@ -54,11 +50,9 @@ for.cond.cleanup: ; preds = %for.cond.cleanup.lo
for.body: ; preds = %for.body, %for.body.preheader
%i.08 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]
%idxprom = zext i32 %i.08 to i64
- %arrayidx = getelementptr inbounds %struct.S, %struct.S* %b, i64 %idxprom
- %arrayidx2 = getelementptr inbounds %struct.S, %struct.S* %a, i64 %idxprom
- %i = bitcast %struct.S* %arrayidx2 to i8*
- %i1 = bitcast %struct.S* %arrayidx to i8*
- call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 4 dereferenceable(12) %i, i8* nonnull align 4 dereferenceable(12) %i1, i64 12, i1 false)
+ %arrayidx = getelementptr inbounds %struct.S, ptr %b, i64 %idxprom
+ %arrayidx2 = getelementptr inbounds %struct.S, ptr %a, i64 %idxprom
+ call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 4 dereferenceable(12) %arrayidx2, ptr nonnull align 4 dereferenceable(12) %arrayidx, i64 12, i1 false)
%inc = add nuw nsw i32 %i.08, 1
%cmp = icmp slt i32 %inc, %n
br i1 %cmp, label %for.body, label %for.cond.cleanup.loopexit
@@ -72,7 +66,7 @@ for.body: ; preds = %for.body, %for.body
; }
; Function Attrs: nofree nounwind uwtable mustprogress
-define dso_local i32 @copy_may_alias(%struct.S* nocapture %a, %struct.S* nocapture readonly %b, i32 %n) local_unnamed_addr {
+define dso_local i32 @copy_may_alias(ptr nocapture %a, ptr nocapture readonly %b, i32 %n) local_unnamed_addr {
; CHECK-LABEL: @copy_may_alias(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CMP7:%.*]] = icmp sgt i32 [[N:%.*]], 0
@@ -86,11 +80,9 @@ define dso_local i32 @copy_may_alias(%struct.S* nocapture %a, %struct.S* nocaptu
; CHECK: for.body:
; CHECK-NEXT: [[I_08:%.*]] = phi i32 [ [[INC:%.*]], [[FOR_BODY]] ], [ 0, [[FOR_BODY_PREHEADER]] ]
; CHECK-NEXT: [[IDXPROM:%.*]] = zext i32 [[I_08]] to i64
-; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [[STRUCT_S:%.*]], %struct.S* [[B:%.*]], i64 [[IDXPROM]]
-; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds [[STRUCT_S]], %struct.S* [[A:%.*]], i64 [[IDXPROM]]
-; CHECK-NEXT: [[I:%.*]] = bitcast %struct.S* [[ARRAYIDX2]] to i8*
-; CHECK-NEXT: [[I1:%.*]] = bitcast %struct.S* [[ARRAYIDX]] to i8*
-; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 4 dereferenceable(12) [[I]], i8* nonnull align 4 dereferenceable(12) [[I1]], i64 12, i1 false)
+; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [[STRUCT_S:%.*]], ptr [[B:%.*]], i64 [[IDXPROM]]
+; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[A:%.*]], i64 [[IDXPROM]]
+; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 4 dereferenceable(12) [[ARRAYIDX2]], ptr nonnull align 4 dereferenceable(12) [[ARRAYIDX]], i64 12, i1 false)
; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_08]], 1
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[INC]], [[N]]
; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_COND_CLEANUP_LOOPEXIT:%.*]]
@@ -111,11 +103,9 @@ for.cond.cleanup: ; preds = %for.cond.cleanup.lo
for.body: ; preds = %for.body, %for.body.preheader
%i.08 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]
%idxprom = zext i32 %i.08 to i64
- %arrayidx = getelementptr inbounds %struct.S, %struct.S* %b, i64 %idxprom
- %arrayidx2 = getelementptr inbounds %struct.S, %struct.S* %a, i64 %idxprom
- %i = bitcast %struct.S* %arrayidx2 to i8*
- %i1 = bitcast %struct.S* %arrayidx to i8*
- call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 4 dereferenceable(12) %i, i8* nonnull align 4 dereferenceable(12) %i1, i64 12, i1 false)
+ %arrayidx = getelementptr inbounds %struct.S, ptr %b, i64 %idxprom
+ %arrayidx2 = getelementptr inbounds %struct.S, ptr %a, i64 %idxprom
+ call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 4 dereferenceable(12) %arrayidx2, ptr nonnull align 4 dereferenceable(12) %arrayidx, i64 12, i1 false)
%inc = add nuw nsw i32 %i.08, 1
%cmp = icmp slt i32 %inc, %n
br i1 %cmp, label %for.body, label %for.cond.cleanup.loopexit
@@ -131,22 +121,20 @@ for.body: ; preds = %for.body, %for.body
; }
; Function Attrs: nofree nounwind uwtable mustprogress
-define dso_local void @copy_noalias_read(%struct.R* noalias nocapture %x, %struct.R* noalias nocapture readonly %y, i32 %n, i32* nocapture nonnull align 4 dereferenceable(4) %s) local_unnamed_addr {
+define dso_local void @copy_noalias_read(ptr noalias nocapture %x, ptr noalias nocapture readonly %y, i32 %n, ptr nocapture nonnull align 4 dereferenceable(4) %s) local_unnamed_addr {
; CHECK-LABEL: @copy_noalias_read(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[X1:%.*]] = bitcast %struct.R* [[X:%.*]] to i8*
-; CHECK-NEXT: [[Y2:%.*]] = bitcast %struct.R* [[Y:%.*]] to i8*
; CHECK-NEXT: [[CMP11:%.*]] = icmp sgt i32 [[N:%.*]], 0
; CHECK-NEXT: br i1 [[CMP11]], label [[FOR_BODY_LR_PH:%.*]], label [[FOR_COND_CLEANUP:%.*]]
; CHECK: for.body.lr.ph:
-; CHECK-NEXT: [[S_PROMOTED:%.*]] = load i32, i32* [[S:%.*]], align 4
+; CHECK-NEXT: [[S_PROMOTED:%.*]] = load i32, ptr [[S:%.*]], align 4
; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[N]] to i64
; CHECK-NEXT: [[TMP1:%.*]] = mul nuw nsw i64 [[TMP0]], 6
-; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 [[X1]], i8* align 1 [[Y2]], i64 [[TMP1]], i1 false)
+; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 [[X:%.*]], ptr align 1 [[Y:%.*]], i64 [[TMP1]], i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.cond.for.cond.cleanup_crit_edge:
; CHECK-NEXT: [[ADD_LCSSA:%.*]] = phi i32 [ [[ADD:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: store i32 [[ADD_LCSSA]], i32* [[S]], align 4
+; CHECK-NEXT: store i32 [[ADD_LCSSA]], ptr [[S]], align 4
; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
; CHECK: for.cond.cleanup:
; CHECK-NEXT: ret void
@@ -154,10 +142,10 @@ define dso_local void @copy_noalias_read(%struct.R* noalias nocapture %x, %struc
; CHECK-NEXT: [[ADD13:%.*]] = phi i32 [ [[S_PROMOTED]], [[FOR_BODY_LR_PH]] ], [ [[ADD]], [[FOR_BODY]] ]
; CHECK-NEXT: [[I_012:%.*]] = phi i32 [ 0, [[FOR_BODY_LR_PH]] ], [ [[INC:%.*]], [[FOR_BODY]] ]
; CHECK-NEXT: [[IDXPROM:%.*]] = zext i32 [[I_012]] to i64
-; CHECK-NEXT: [[I:%.*]] = getelementptr inbounds [[STRUCT_R:%.*]], %struct.R* [[X]], i64 [[IDXPROM]], i32 0
-; CHECK-NEXT: [[I1:%.*]] = getelementptr inbounds [[STRUCT_R]], %struct.R* [[Y]], i64 [[IDXPROM]], i32 0
-; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_R]], %struct.R* [[Y]], i64 [[IDXPROM]], i32 1
-; CHECK-NEXT: [[I2:%.*]] = load i32, i32* [[B]], align 1
+; CHECK-NEXT: [[I:%.*]] = getelementptr inbounds [[STRUCT_R:%.*]], ptr [[X]], i64 [[IDXPROM]], i32 0
+; CHECK-NEXT: [[I1:%.*]] = getelementptr inbounds [[STRUCT_R]], ptr [[Y]], i64 [[IDXPROM]], i32 0
+; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_R]], ptr [[Y]], i64 [[IDXPROM]], i32 1
+; CHECK-NEXT: [[I2:%.*]] = load i32, ptr [[B]], align 1
; CHECK-NEXT: [[ADD]] = add nsw i32 [[ADD13]], [[I2]]
; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_012]], 1
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[INC]], [[N]]
@@ -168,12 +156,12 @@ entry:
br i1 %cmp11, label %for.body.lr.ph, label %for.cond.cleanup
for.body.lr.ph: ; preds = %entry
- %s.promoted = load i32, i32* %s, align 4
+ %s.promoted = load i32, ptr %s, align 4
br label %for.body
for.cond.for.cond.cleanup_crit_edge: ; preds = %for.body
%add.lcssa = phi i32 [ %add, %for.body ]
- store i32 %add.lcssa, i32* %s, align 4
+ store i32 %add.lcssa, ptr %s, align 4
br label %for.cond.cleanup
for.cond.cleanup: ; preds = %for.cond.for.cond.cleanup_crit_edge, %entry
@@ -183,11 +171,11 @@ for.body: ; preds = %for.body, %for.body
%add13 = phi i32 [ %s.promoted, %for.body.lr.ph ], [ %add, %for.body ]
%i.012 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
%idxprom = zext i32 %i.012 to i64
- %i = getelementptr inbounds %struct.R, %struct.R* %x, i64 %idxprom, i32 0
- %i1 = getelementptr inbounds %struct.R, %struct.R* %y, i64 %idxprom, i32 0
- call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 1 dereferenceable(6) %i, i8* nonnull align 1 dereferenceable(6) %i1, i64 6, i1 false)
- %b = getelementptr inbounds %struct.R, %struct.R* %y, i64 %idxprom, i32 1
- %i2 = load i32, i32* %b, align 1
+ %i = getelementptr inbounds %struct.R, ptr %x, i64 %idxprom, i32 0
+ %i1 = getelementptr inbounds %struct.R, ptr %y, i64 %idxprom, i32 0
+ call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 dereferenceable(6) %i, ptr nonnull align 1 dereferenceable(6) %i1, i64 6, i1 false)
+ %b = getelementptr inbounds %struct.R, ptr %y, i64 %idxprom, i32 1
+ %i2 = load i32, ptr %b, align 1
%add = add nsw i32 %add13, %i2
%inc = add nuw nsw i32 %i.012, 1
%cmp = icmp slt i32 %inc, %n
@@ -202,18 +190,16 @@ for.body: ; preds = %for.body, %for.body
; }
; Function Attrs: nofree nosync nounwind uwtable mustprogress
-define dso_local i32 @copy_noalias_negative_stride(%struct.S* noalias nocapture %arg, %struct.S* nocapture readonly %arg1, i32 %arg2) local_unnamed_addr {
+define dso_local i32 @copy_noalias_negative_stride(ptr noalias nocapture %arg, ptr nocapture readonly %arg1, i32 %arg2) local_unnamed_addr {
; CHECK-LABEL: @copy_noalias_negative_stride(
; CHECK-NEXT: bb:
-; CHECK-NEXT: [[ARG3:%.*]] = bitcast %struct.S* [[ARG:%.*]] to i8*
-; CHECK-NEXT: [[ARG14:%.*]] = bitcast %struct.S* [[ARG1:%.*]] to i8*
; CHECK-NEXT: [[I:%.*]] = icmp sgt i32 [[ARG2:%.*]], -1
; CHECK-NEXT: br i1 [[I]], label [[BB3:%.*]], label [[BB5:%.*]]
; CHECK: bb3:
; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[ARG2]] to i64
; CHECK-NEXT: [[TMP1:%.*]] = mul nuw nsw i64 [[TMP0]], 12
; CHECK-NEXT: [[TMP2:%.*]] = add nuw nsw i64 [[TMP1]], 12
-; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 [[ARG3]], i8* align 4 [[ARG14]], i64 [[TMP2]], i1 false)
+; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 [[ARG:%.*]], ptr align 4 [[ARG1:%.*]], i64 [[TMP2]], i1 false)
; CHECK-NEXT: br label [[BB6:%.*]]
; CHECK: bb4:
; CHECK-NEXT: br label [[BB5]]
@@ -222,10 +208,8 @@ define dso_local i32 @copy_noalias_negative_stride(%struct.S* noalias nocapture
; CHECK: bb6:
; CHECK-NEXT: [[I7:%.*]] = phi i32 [ [[I13:%.*]], [[BB6]] ], [ [[ARG2]], [[BB3]] ]
; CHECK-NEXT: [[I8:%.*]] = zext i32 [[I7]] to i64
-; CHECK-NEXT: [[I9:%.*]] = getelementptr inbounds [[STRUCT_S:%.*]], %struct.S* [[ARG1]], i64 [[I8]]
-; CHECK-NEXT: [[I10:%.*]] = getelementptr inbounds [[STRUCT_S]], %struct.S* [[ARG]], i64 [[I8]]
-; CHECK-NEXT: [[I11:%.*]] = bitcast %struct.S* [[I10]] to i8*
-; CHECK-NEXT: [[I12:%.*]] = bitcast %struct.S* [[I9]] to i8*
+; CHECK-NEXT: [[I9:%.*]] = getelementptr inbounds [[STRUCT_S:%.*]], ptr [[ARG1]], i64 [[I8]]
+; CHECK-NEXT: [[I10:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[ARG]], i64 [[I8]]
; CHECK-NEXT: [[I13]] = add nsw i32 [[I7]], -1
; CHECK-NEXT: [[I14:%.*]] = icmp sgt i32 [[I7]], 0
; CHECK-NEXT: br i1 [[I14]], label [[BB6]], label [[BB4:%.*]]
@@ -246,11 +230,9 @@ bb5: ; preds = %bb4, %bb
bb6: ; preds = %bb6, %bb3
%i7 = phi i32 [ %i13, %bb6 ], [ %arg2, %bb3 ]
%i8 = zext i32 %i7 to i64
- %i9 = getelementptr inbounds %struct.S, %struct.S* %arg1, i64 %i8
- %i10 = getelementptr inbounds %struct.S, %struct.S* %arg, i64 %i8
- %i11 = bitcast %struct.S* %i10 to i8*
- %i12 = bitcast %struct.S* %i9 to i8*
- tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 4 dereferenceable(12) %i11, i8* noundef nonnull align 4 dereferenceable(12) %i12, i64 12, i1 false)
+ %i9 = getelementptr inbounds %struct.S, ptr %arg1, i64 %i8
+ %i10 = getelementptr inbounds %struct.S, ptr %arg, i64 %i8
+ tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %i10, ptr noundef nonnull align 4 dereferenceable(12) %i9, i64 12, i1 false)
%i13 = add nsw i32 %i7, -1
%i14 = icmp sgt i32 %i7, 0
br i1 %i14, label %bb6, label %bb4
@@ -264,7 +246,7 @@ bb6: ; preds = %bb6, %bb3
; }
; Function Attrs: nofree nosync nounwind uwtable mustprogress
-define dso_local i32 @copy_noalias_opposite_stride(%struct.S* noalias nocapture %arg, %struct.S* nocapture readonly %arg1, i32 %arg2) local_unnamed_addr {
+define dso_local i32 @copy_noalias_opposite_stride(ptr noalias nocapture %arg, ptr nocapture readonly %arg1, i32 %arg2) local_unnamed_addr {
; CHECK-LABEL: @copy_noalias_opposite_stride(
; CHECK-NEXT: bb:
; CHECK-NEXT: [[I:%.*]] = icmp sgt i32 [[ARG2:%.*]], 0
@@ -279,12 +261,10 @@ define dso_local i32 @copy_noalias_opposite_stride(%struct.S* noalias nocapture
; CHECK-NEXT: [[I7:%.*]] = phi i32 [ [[I16:%.*]], [[BB6]] ], [ [[ARG2]], [[BB3]] ]
; CHECK-NEXT: [[I8:%.*]] = phi i32 [ [[I15:%.*]], [[BB6]] ], [ 0, [[BB3]] ]
; CHECK-NEXT: [[I9:%.*]] = zext i32 [[I7]] to i64
-; CHECK-NEXT: [[I10:%.*]] = getelementptr inbounds [[STRUCT_S:%.*]], %struct.S* [[ARG1:%.*]], i64 [[I9]]
+; CHECK-NEXT: [[I10:%.*]] = getelementptr inbounds [[STRUCT_S:%.*]], ptr [[ARG1:%.*]], i64 [[I9]]
; CHECK-NEXT: [[I11:%.*]] = zext i32 [[I8]] to i64
-; CHECK-NEXT: [[I12:%.*]] = getelementptr inbounds [[STRUCT_S]], %struct.S* [[ARG:%.*]], i64 [[I11]]
-; CHECK-NEXT: [[I13:%.*]] = bitcast %struct.S* [[I12]] to i8*
-; CHECK-NEXT: [[I14:%.*]] = bitcast %struct.S* [[I10]] to i8*
-; CHECK-NEXT: tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 4 dereferenceable(12) [[I13]], i8* noundef nonnull align 4 dereferenceable(12) [[I14]], i64 12, i1 false)
+; CHECK-NEXT: [[I12:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[ARG:%.*]], i64 [[I11]]
+; CHECK-NEXT: tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) [[I12]], ptr noundef nonnull align 4 dereferenceable(12) [[I10]], i64 12, i1 false)
; CHECK-NEXT: [[I15]] = add nuw nsw i32 [[I8]], 1
; CHECK-NEXT: [[I16]] = add nsw i32 [[I7]], -1
; CHECK-NEXT: [[I17:%.*]] = icmp slt i32 [[I15]], [[ARG2]]
@@ -309,12 +289,10 @@ bb6: ; preds = %bb6, %bb3
%i7 = phi i32 [ %i16, %bb6 ], [ %arg2, %bb3 ]
%i8 = phi i32 [ %i15, %bb6 ], [ 0, %bb3 ]
%i9 = zext i32 %i7 to i64
- %i10 = getelementptr inbounds %struct.S, %struct.S* %arg1, i64 %i9
+ %i10 = getelementptr inbounds %struct.S, ptr %arg1, i64 %i9
%i11 = zext i32 %i8 to i64
- %i12 = getelementptr inbounds %struct.S, %struct.S* %arg, i64 %i11
- %i13 = bitcast %struct.S* %i12 to i8*
- %i14 = bitcast %struct.S* %i10 to i8*
- tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 4 dereferenceable(12) %i13, i8* noundef nonnull align 4 dereferenceable(12) %i14, i64 12, i1 false)
+ %i12 = getelementptr inbounds %struct.S, ptr %arg, i64 %i11
+ tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %i12, ptr noundef nonnull align 4 dereferenceable(12) %i10, i64 12, i1 false)
%i15 = add nuw nsw i32 %i8, 1
%i16 = add nsw i32 %i7, -1
%i17 = icmp slt i32 %i15, %arg2
@@ -326,17 +304,15 @@ bb6: ; preds = %bb6, %bb3
%struct.SPacked = type <{ i32, i32, i8 }>
; Function Attrs: nofree nounwind uwtable mustprogress
-define dso_local i32 @copy_noalias_packed(%struct.SPacked* noalias nocapture %a, %struct.SPacked* nocapture readonly %b, i32 %n) local_unnamed_addr {
+define dso_local i32 @copy_noalias_packed(ptr noalias nocapture %a, ptr nocapture readonly %b, i32 %n) local_unnamed_addr {
; CHECK-LABEL: @copy_noalias_packed(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[A1:%.*]] = bitcast %struct.SPacked* [[A:%.*]] to i8*
-; CHECK-NEXT: [[B2:%.*]] = bitcast %struct.SPacked* [[B:%.*]] to i8*
; CHECK-NEXT: [[CMP7:%.*]] = icmp sgt i32 [[N:%.*]], 0
; CHECK-NEXT: br i1 [[CMP7]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_COND_CLEANUP:%.*]]
; CHECK: for.body.preheader:
; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[N]] to i64
; CHECK-NEXT: [[TMP1:%.*]] = mul nuw nsw i64 [[TMP0]], 9
-; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 [[A1]], i8* align 1 [[B2]], i64 [[TMP1]], i1 false)
+; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 [[A:%.*]], ptr align 1 [[B:%.*]], i64 [[TMP1]], i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.cond.cleanup.loopexit:
; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
@@ -345,10 +321,8 @@ define dso_local i32 @copy_noalias_packed(%struct.SPacked* noalias nocapture %a,
; CHECK: for.body:
; CHECK-NEXT: [[I_08:%.*]] = phi i32 [ [[INC:%.*]], [[FOR_BODY]] ], [ 0, [[FOR_BODY_PREHEADER]] ]
; CHECK-NEXT: [[IDXPROM:%.*]] = zext i32 [[I_08]] to i64
-; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [[STRUCT_SPACKED:%.*]], %struct.SPacked* [[B]], i64 [[IDXPROM]]
-; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds [[STRUCT_SPACKED]], %struct.SPacked* [[A]], i64 [[IDXPROM]]
-; CHECK-NEXT: [[I:%.*]] = bitcast %struct.SPacked* [[ARRAYIDX2]] to i8*
-; CHECK-NEXT: [[I1:%.*]] = bitcast %struct.SPacked* [[ARRAYIDX]] to i8*
+; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [[STRUCT_SPACKED:%.*]], ptr [[B]], i64 [[IDXPROM]]
+; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds [[STRUCT_SPACKED]], ptr [[A]], i64 [[IDXPROM]]
; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_08]], 1
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[INC]], [[N]]
; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_COND_CLEANUP_LOOPEXIT:%.*]]
@@ -369,11 +343,9 @@ for.cond.cleanup: ; preds = %for.cond.cleanup.lo
for.body: ; preds = %for.body, %for.body.preheader
%i.08 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]
%idxprom = zext i32 %i.08 to i64
- %arrayidx = getelementptr inbounds %struct.SPacked, %struct.SPacked* %b, i64 %idxprom
- %arrayidx2 = getelementptr inbounds %struct.SPacked, %struct.SPacked* %a, i64 %idxprom
- %i = bitcast %struct.SPacked* %arrayidx2 to i8*
- %i1 = bitcast %struct.SPacked* %arrayidx to i8*
- call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 1 dereferenceable(9) %i, i8* nonnull align 1 dereferenceable(9) %i1, i64 9, i1 false)
+ %arrayidx = getelementptr inbounds %struct.SPacked, ptr %b, i64 %idxprom
+ %arrayidx2 = getelementptr inbounds %struct.SPacked, ptr %a, i64 %idxprom
+ call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 dereferenceable(9) %arrayidx2, ptr nonnull align 1 dereferenceable(9) %arrayidx, i64 9, i1 false)
%inc = add nuw nsw i32 %i.08, 1
%cmp = icmp slt i32 %inc, %n
br i1 %cmp, label %for.body, label %for.cond.cleanup.loopexit
@@ -381,17 +353,15 @@ for.body: ; preds = %for.body, %for.body
%struct.SAligned = type { i32, i32, i8, [7 x i8] }
-define dso_local i32 @copy_noalias_aligned(%struct.SAligned* noalias nocapture %a, %struct.SAligned* nocapture readonly %b, i32 %n) local_unnamed_addr {
+define dso_local i32 @copy_noalias_aligned(ptr noalias nocapture %a, ptr nocapture readonly %b, i32 %n) local_unnamed_addr {
; CHECK-LABEL: @copy_noalias_aligned(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[A1:%.*]] = bitcast %struct.SAligned* [[A:%.*]] to i8*
-; CHECK-NEXT: [[B2:%.*]] = bitcast %struct.SAligned* [[B:%.*]] to i8*
; CHECK-NEXT: [[CMP7:%.*]] = icmp sgt i32 [[N:%.*]], 0
; CHECK-NEXT: br i1 [[CMP7]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_COND_CLEANUP:%.*]]
; CHECK: for.body.preheader:
; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[N]] to i64
; CHECK-NEXT: [[TMP1:%.*]] = shl nuw nsw i64 [[TMP0]], 4
-; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 16 [[A1]], i8* align 16 [[B2]], i64 [[TMP1]], i1 false)
+; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 16 [[A:%.*]], ptr align 16 [[B:%.*]], i64 [[TMP1]], i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.cond.cleanup.loopexit:
; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
@@ -400,10 +370,8 @@ define dso_local i32 @copy_noalias_aligned(%struct.SAligned* noalias nocapture %
; CHECK: for.body:
; CHECK-NEXT: [[I_08:%.*]] = phi i32 [ [[INC:%.*]], [[FOR_BODY]] ], [ 0, [[FOR_BODY_PREHEADER]] ]
; CHECK-NEXT: [[IDXPROM:%.*]] = zext i32 [[I_08]] to i64
-; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [[STRUCT_SALIGNED:%.*]], %struct.SAligned* [[B]], i64 [[IDXPROM]]
-; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds [[STRUCT_SALIGNED]], %struct.SAligned* [[A]], i64 [[IDXPROM]]
-; CHECK-NEXT: [[I:%.*]] = bitcast %struct.SAligned* [[ARRAYIDX2]] to i8*
-; CHECK-NEXT: [[I1:%.*]] = bitcast %struct.SAligned* [[ARRAYIDX]] to i8*
+; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [[STRUCT_SALIGNED:%.*]], ptr [[B]], i64 [[IDXPROM]]
+; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds [[STRUCT_SALIGNED]], ptr [[A]], i64 [[IDXPROM]]
; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_08]], 1
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[INC]], [[N]]
; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_COND_CLEANUP_LOOPEXIT:%.*]]
@@ -424,15 +392,13 @@ for.cond.cleanup: ; preds = %for.cond.cleanup.lo
for.body: ; preds = %for.body, %for.body.preheader
%i.08 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]
%idxprom = zext i32 %i.08 to i64
- %arrayidx = getelementptr inbounds %struct.SAligned, %struct.SAligned* %b, i64 %idxprom
- %arrayidx2 = getelementptr inbounds %struct.SAligned, %struct.SAligned* %a, i64 %idxprom
- %i = bitcast %struct.SAligned* %arrayidx2 to i8*
- %i1 = bitcast %struct.SAligned* %arrayidx to i8*
- call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 16 dereferenceable(16) %i, i8* nonnull align 16 dereferenceable(16) %i1, i64 16, i1 false)
+ %arrayidx = getelementptr inbounds %struct.SAligned, ptr %b, i64 %idxprom
+ %arrayidx2 = getelementptr inbounds %struct.SAligned, ptr %a, i64 %idxprom
+ call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 dereferenceable(16) %arrayidx2, ptr nonnull align 16 dereferenceable(16) %arrayidx, i64 16, i1 false)
%inc = add nuw nsw i32 %i.08, 1
%cmp = icmp slt i32 %inc, %n
br i1 %cmp, label %for.body, label %for.cond.cleanup.loopexit
}
; Function Attrs: argmemonly nofree nosync nounwind willreturn
-declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1
+declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1
diff --git a/llvm/test/Transforms/LoopIdiom/memset-debugify-remarks.ll b/llvm/test/Transforms/LoopIdiom/memset-debugify-remarks.ll
index 7021276dd38c0..7ff6446fb4770 100644
--- a/llvm/test/Transforms/LoopIdiom/memset-debugify-remarks.ll
+++ b/llvm/test/Transforms/LoopIdiom/memset-debugify-remarks.ll
@@ -12,7 +12,7 @@ target triple = "x86_64-unknown-linux-gnu"
; *begin = value;
; }
-; CHECK: remark: <stdin>:4:1: Transformed loop-strided store in _Z15my_basic_memsetPcS_c function into a call to llvm.memset.p0i8.i64() intrinsic{{$}}
+; CHECK: remark: <stdin>:4:1: Transformed loop-strided store in _Z15my_basic_memsetPcS_c function into a call to llvm.memset.p0.i64() intrinsic{{$}}
; YAML: --- !Passed
; YAML-NEXT: Pass: loop-idiom
@@ -24,30 +24,30 @@ target triple = "x86_64-unknown-linux-gnu"
; YAML-NEXT: - Function: _Z15my_basic_memsetPcS_c
; YAML-NEXT: DebugLoc: { File: '<stdin>', Line: 1, Column: 0 }
; YAML-NEXT: - String: ' function into a call to '
-; YAML-NEXT: - NewFunction: llvm.memset.p0i8.i64
+; YAML-NEXT: - NewFunction: llvm.memset.p0.i64
; YAML-NEXT: - String: '() intrinsic'
; YAML-NEXT: - FromBlock: for.body
; YAML-NEXT: - ToBlock: for.body.preheader
; YAML-NEXT: ...
-define void @_Z15my_basic_memsetPcS_c(i8* %ptr, i8* %end, i8 %value) {
+define void @_Z15my_basic_memsetPcS_c(ptr %ptr, ptr %end, i8 %value) {
; CHECK-LABEL: @_Z15my_basic_memsetPcS_c(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[PTR2:%.*]] = ptrtoint i8* [[PTR:%.*]] to i64, !dbg [[DBG15:![0-9]+]]
-; CHECK-NEXT: [[END1:%.*]] = ptrtoint i8* [[END:%.*]] to i64, !dbg [[DBG15]]
-; CHECK-NEXT: [[CMP3:%.*]] = icmp eq i8* [[PTR]], [[END]], !dbg [[DBG15]]
+; CHECK-NEXT: [[PTR2:%.*]] = ptrtoint ptr [[PTR:%.*]] to i64, !dbg [[DBG15:![0-9]+]]
+; CHECK-NEXT: [[END1:%.*]] = ptrtoint ptr [[END:%.*]] to i64, !dbg [[DBG15]]
+; CHECK-NEXT: [[CMP3:%.*]] = icmp eq ptr [[PTR]], [[END]], !dbg [[DBG15]]
; CHECK-NEXT: call void @llvm.dbg.value(metadata i1 [[CMP3]], metadata [[META9:![0-9]+]], metadata !DIExpression()), !dbg [[DBG15]]
; CHECK-NEXT: br i1 [[CMP3]], label [[FOR_END:%.*]], label [[FOR_BODY_PREHEADER:%.*]], !dbg [[DBG16:![0-9]+]]
; CHECK: for.body.preheader:
; CHECK-NEXT: [[TMP0:%.*]] = sub i64 [[END1]], [[PTR2]], !dbg [[DBG17:![0-9]+]]
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 1 [[PTR]], i8 [[VALUE:%.*]], i64 [[TMP0]], i1 false), !dbg [[DBG18:![0-9]+]]
+; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[PTR]], i8 [[VALUE:%.*]], i64 [[TMP0]], i1 false), !dbg [[DBG18:![0-9]+]]
; CHECK-NEXT: br label [[FOR_BODY:%.*]], !dbg [[DBG17]]
; CHECK: for.body:
-; CHECK-NEXT: [[PTR_ADDR_04:%.*]] = phi i8* [ [[INCDEC_PTR:%.*]], [[FOR_BODY]] ], [ [[PTR]], [[FOR_BODY_PREHEADER]] ], !dbg [[DBG19:![0-9]+]]
-; CHECK-NEXT: call void @llvm.dbg.value(metadata i8* [[PTR_ADDR_04]], metadata [[META11:![0-9]+]], metadata !DIExpression()), !dbg [[DBG19]]
-; CHECK-NEXT: [[INCDEC_PTR]] = getelementptr inbounds i8, i8* [[PTR_ADDR_04]], i64 1, !dbg [[DBG20:![0-9]+]]
-; CHECK-NEXT: call void @llvm.dbg.value(metadata i8* [[INCDEC_PTR]], metadata [[META13:![0-9]+]], metadata !DIExpression()), !dbg [[DBG20]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8* [[INCDEC_PTR]], [[END]], !dbg [[DBG21:![0-9]+]]
+; CHECK-NEXT: [[PTR_ADDR_04:%.*]] = phi ptr [ [[INCDEC_PTR:%.*]], [[FOR_BODY]] ], [ [[PTR]], [[FOR_BODY_PREHEADER]] ], !dbg [[DBG19:![0-9]+]]
+; CHECK-NEXT: call void @llvm.dbg.value(metadata ptr [[PTR_ADDR_04]], metadata [[META11:![0-9]+]], metadata !DIExpression()), !dbg [[DBG19]]
+; CHECK-NEXT: [[INCDEC_PTR]] = getelementptr inbounds i8, ptr [[PTR_ADDR_04]], i64 1, !dbg [[DBG20:![0-9]+]]
+; CHECK-NEXT: call void @llvm.dbg.value(metadata ptr [[INCDEC_PTR]], metadata [[META13:![0-9]+]], metadata !DIExpression()), !dbg [[DBG20]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq ptr [[INCDEC_PTR]], [[END]], !dbg [[DBG21:![0-9]+]]
; CHECK-NEXT: call void @llvm.dbg.value(metadata i1 [[CMP]], metadata [[META14:![0-9]+]], metadata !DIExpression()), !dbg [[DBG21]]
; CHECK-NEXT: br i1 [[CMP]], label [[FOR_END_LOOPEXIT:%.*]], label [[FOR_BODY]], !dbg [[DBG17]]
; CHECK: for.end.loopexit:
@@ -56,14 +56,14 @@ define void @_Z15my_basic_memsetPcS_c(i8* %ptr, i8* %end, i8 %value) {
; CHECK-NEXT: ret void, !dbg [[DBG22]]
;
entry:
- %cmp3 = icmp eq i8* %ptr, %end
+ %cmp3 = icmp eq ptr %ptr, %end
br i1 %cmp3, label %for.end, label %for.body
for.body: ; preds = %entry, %for.body
- %ptr.addr.04 = phi i8* [ %incdec.ptr, %for.body ], [ %ptr, %entry ]
- store i8 %value, i8* %ptr.addr.04, align 1
- %incdec.ptr = getelementptr inbounds i8, i8* %ptr.addr.04, i64 1
- %cmp = icmp eq i8* %incdec.ptr, %end
+ %ptr.addr.04 = phi ptr [ %incdec.ptr, %for.body ], [ %ptr, %entry ]
+ store i8 %value, ptr %ptr.addr.04, align 1
+ %incdec.ptr = getelementptr inbounds i8, ptr %ptr.addr.04, i64 1
+ %cmp = icmp eq ptr %incdec.ptr, %end
br i1 %cmp, label %for.end, label %for.body
for.end: ; preds = %for.body, %entry
diff --git a/llvm/test/Transforms/LoopIdiom/memset-pr52104.ll b/llvm/test/Transforms/LoopIdiom/memset-pr52104.ll
index 6e5733cb283ab..0c7d1ec59b2cd 100644
--- a/llvm/test/Transforms/LoopIdiom/memset-pr52104.ll
+++ b/llvm/test/Transforms/LoopIdiom/memset-pr52104.ll
@@ -1,28 +1,28 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -passes=loop-idiom < %s -S | FileCheck %s
-define void @f(i32* nocapture nonnull align 4 dereferenceable(20) %0, i32 %1) local_unnamed_addr #0 align 32 {
+define void @f(ptr nocapture nonnull align 4 dereferenceable(20) %0, i32 %1) local_unnamed_addr #0 align 32 {
; CHECK-LABEL: @f(
; CHECK-NEXT: [[TMP3:%.*]] = trunc i32 [[TMP1:%.*]] to i2
; CHECK-NEXT: [[TMP4:%.*]] = zext i2 [[TMP3]] to i64
-; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i32, i32* [[TMP0:%.*]], i64 [[TMP4]]
-; CHECK-NEXT: [[SCEVGEP1:%.*]] = bitcast i32* [[SCEVGEP]] to i8*
-; CHECK-NEXT: [[TMP5:%.*]] = sub i2 -1, [[TMP3]]
-; CHECK-NEXT: [[TMP6:%.*]] = zext i2 [[TMP5]] to i64
-; CHECK-NEXT: [[TMP7:%.*]] = shl nuw nsw i64 [[TMP6]], 2
-; CHECK-NEXT: [[TMP8:%.*]] = add nuw nsw i64 [[TMP7]], 4
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 4 [[SCEVGEP1]], i8 0, i64 [[TMP8]], i1 false)
-; CHECK-NEXT: br label [[TMP9:%.*]]
-; CHECK: 9:
-; CHECK-NEXT: [[TMP10:%.*]] = phi i32 [ [[TMP14:%.*]], [[TMP9]] ], [ [[TMP1]], [[TMP2:%.*]] ]
-; CHECK-NEXT: [[TMP11:%.*]] = and i32 [[TMP10]], 3
-; CHECK-NEXT: [[TMP12:%.*]] = zext i32 [[TMP11]] to i64
-; CHECK-NEXT: [[TMP13:%.*]] = getelementptr inbounds i32, i32* [[TMP0]], i64 [[TMP12]]
-; CHECK-NEXT: [[TMP14]] = add nsw i32 [[TMP10]], 1
-; CHECK-NEXT: [[TMP15:%.*]] = and i32 [[TMP14]], 3
-; CHECK-NEXT: [[TMP16:%.*]] = icmp eq i32 [[TMP15]], 0
-; CHECK-NEXT: br i1 [[TMP16]], label [[TMP17:%.*]], label [[TMP9]]
-; CHECK: 17:
+; CHECK-NEXT: [[TMP5:%.*]] = shl nuw nsw i64 [[TMP4]], 2
+; CHECK-NEXT: [[UGLYGEP:%.*]] = getelementptr i8, ptr [[TMP0:%.*]], i64 [[TMP5]]
+; CHECK-NEXT: [[TMP6:%.*]] = sub i2 -1, [[TMP3]]
+; CHECK-NEXT: [[TMP7:%.*]] = zext i2 [[TMP6]] to i64
+; CHECK-NEXT: [[TMP8:%.*]] = shl nuw nsw i64 [[TMP7]], 2
+; CHECK-NEXT: [[TMP9:%.*]] = add nuw nsw i64 [[TMP8]], 4
+; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 4 [[UGLYGEP]], i8 0, i64 [[TMP9]], i1 false)
+; CHECK-NEXT: br label [[TMP10:%.*]]
+; CHECK: 10:
+; CHECK-NEXT: [[TMP11:%.*]] = phi i32 [ [[TMP15:%.*]], [[TMP10]] ], [ [[TMP1]], [[TMP2:%.*]] ]
+; CHECK-NEXT: [[TMP12:%.*]] = and i32 [[TMP11]], 3
+; CHECK-NEXT: [[TMP13:%.*]] = zext i32 [[TMP12]] to i64
+; CHECK-NEXT: [[TMP14:%.*]] = getelementptr inbounds i32, ptr [[TMP0]], i64 [[TMP13]]
+; CHECK-NEXT: [[TMP15]] = add nsw i32 [[TMP11]], 1
+; CHECK-NEXT: [[TMP16:%.*]] = and i32 [[TMP15]], 3
+; CHECK-NEXT: [[TMP17:%.*]] = icmp eq i32 [[TMP16]], 0
+; CHECK-NEXT: br i1 [[TMP17]], label [[TMP18:%.*]], label [[TMP10]]
+; CHECK: 18:
; CHECK-NEXT: ret void
;
br label %3
@@ -31,8 +31,8 @@ define void @f(i32* nocapture nonnull align 4 dereferenceable(20) %0, i32 %1) lo
%4 = phi i32 [ %8, %3 ], [ %1, %2 ]
%5 = and i32 %4, 3
%6 = zext i32 %5 to i64
- %7 = getelementptr inbounds i32, i32* %0, i64 %6
- store i32 0, i32* %7, align 4
+ %7 = getelementptr inbounds i32, ptr %0, i64 %6
+ store i32 0, ptr %7, align 4
%8 = add nsw i32 %4, 1
%9 = and i32 %8, 3
%10 = icmp eq i32 %9, 0
diff --git a/llvm/test/Transforms/LoopIdiom/memset-runtime-32bit.ll b/llvm/test/Transforms/LoopIdiom/memset-runtime-32bit.ll
index f26d602f1b105..c87397aabec7d 100644
--- a/llvm/test/Transforms/LoopIdiom/memset-runtime-32bit.ll
+++ b/llvm/test/Transforms/LoopIdiom/memset-runtime-32bit.ll
@@ -14,17 +14,16 @@ target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f8
; memset(arr, 0, m * sizeof(int));
; }
; }
-define dso_local void @PositiveFor32(i32* %ar, i32 %n, i32 %m) {
+define dso_local void @PositiveFor32(ptr %ar, i32 %n, i32 %m) {
; CHECK-LABEL: @PositiveFor32(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[AR1:%.*]] = bitcast i32* [[AR:%.*]] to i8*
; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i32 0, [[N:%.*]]
; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_BODY_LR_PH:%.*]], label [[FOR_END:%.*]]
; CHECK: for.body.lr.ph:
; CHECK-NEXT: [[MUL1:%.*]] = mul i32 [[M:%.*]], 4
; CHECK-NEXT: [[TMP0:%.*]] = mul i32 [[M]], [[N]]
; CHECK-NEXT: [[TMP1:%.*]] = shl i32 [[TMP0]], 2
-; CHECK-NEXT: call void @llvm.memset.p0i8.i32(i8* align 4 [[AR1]], i8 0, i32 [[TMP1]], i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i32(ptr align 4 [[AR:%.*]], i8 0, i32 [[TMP1]], i1 false)
; CHECK-NEXT: br label [[FOR_END]]
; CHECK: for.end:
; CHECK-NEXT: ret void
@@ -40,9 +39,8 @@ for.body.lr.ph: ; preds = %entry
for.body: ; preds = %for.body.lr.ph, %for.body
%i.02 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
%mul = mul nsw i32 %i.02, %m
- %add.ptr = getelementptr inbounds i32, i32* %ar, i32 %mul
- %0 = bitcast i32* %add.ptr to i8*
- call void @llvm.memset.p0i8.i32(i8* align 4 %0, i8 0, i32 %mul1, i1 false)
+ %add.ptr = getelementptr inbounds i32, ptr %ar, i32 %mul
+ call void @llvm.memset.p0.i32(ptr align 4 %add.ptr, i8 0, i32 %mul1, i1 false)
%inc = add nsw i32 %i.02, 1
%cmp = icmp slt i32 %inc, %n
br i1 %cmp, label %for.body, label %for.end
@@ -58,10 +56,9 @@ for.end: ; preds = %for.body, %entry
; memset(arr, 0, m * sizeof(int));
; }
; }
-define void @NegativeFor32(i32* %ar, i32 %n, i32 %m) {
+define void @NegativeFor32(ptr %ar, i32 %n, i32 %m) {
; CHECK-LABEL: @NegativeFor32(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[AR1:%.*]] = bitcast i32* [[AR:%.*]] to i8*
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 [[N:%.*]], 1
; CHECK-NEXT: [[CMP1:%.*]] = icmp sge i32 [[SUB]], 0
; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_BODY_LR_PH:%.*]], label [[FOR_END:%.*]]
@@ -69,7 +66,7 @@ define void @NegativeFor32(i32* %ar, i32 %n, i32 %m) {
; CHECK-NEXT: [[MUL1:%.*]] = mul i32 [[M:%.*]], 4
; CHECK-NEXT: [[TMP0:%.*]] = mul i32 [[M]], [[N]]
; CHECK-NEXT: [[TMP1:%.*]] = shl i32 [[TMP0]], 2
-; CHECK-NEXT: call void @llvm.memset.p0i8.i32(i8* align 4 [[AR1]], i8 0, i32 [[TMP1]], i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i32(ptr align 4 [[AR:%.*]], i8 0, i32 [[TMP1]], i1 false)
; CHECK-NEXT: br label [[FOR_END]]
; CHECK: for.end:
; CHECK-NEXT: ret void
@@ -86,9 +83,8 @@ for.body.lr.ph: ; preds = %entry
for.body: ; preds = %for.body.lr.ph, %for.body
%i.02 = phi i32 [ %sub, %for.body.lr.ph ], [ %dec, %for.body ]
%mul = mul nsw i32 %i.02, %m
- %add.ptr = getelementptr inbounds i32, i32* %ar, i32 %mul
- %0 = bitcast i32* %add.ptr to i8*
- call void @llvm.memset.p0i8.i32(i8* align 4 %0, i8 0, i32 %mul1, i1 false)
+ %add.ptr = getelementptr inbounds i32, ptr %ar, i32 %mul
+ call void @llvm.memset.p0.i32(ptr align 4 %add.ptr, i8 0, i32 %mul1, i1 false)
%dec = add nsw i32 %i.02, -1
%cmp = icmp sge i32 %dec, 0
br i1 %cmp, label %for.body, label %for.end
@@ -106,10 +102,9 @@ for.end: ; preds = %for.body, %entry
; }
; }
; }
-define void @NestedFor32(i32* %ar, i32 %n, i32 %m, i32 %o) {
+define void @NestedFor32(ptr %ar, i32 %n, i32 %m, i32 %o) {
; CHECK-LABEL: @NestedFor32(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[AR2:%.*]] = bitcast i32* [[AR:%.*]] to i8*
; CHECK-NEXT: [[CMP3:%.*]] = icmp slt i32 0, [[N:%.*]]
; CHECK-NEXT: [[CMP21:%.*]] = icmp slt i32 0, [[M:%.*]]
; CHECK-NEXT: [[MUL7:%.*]] = mul i32 [[O:%.*]], 4
@@ -120,7 +115,7 @@ define void @NestedFor32(i32* %ar, i32 %n, i32 %m, i32 %o) {
; CHECK-NEXT: [[TMP1:%.*]] = shl i32 [[TMP0]], 2
; CHECK-NEXT: [[TMP2:%.*]] = mul i32 [[TMP0]], [[N]]
; CHECK-NEXT: [[TMP3:%.*]] = shl i32 [[TMP2]], 2
-; CHECK-NEXT: call void @llvm.memset.p0i8.i32(i8* align 4 [[AR2]], i8 0, i32 [[TMP3]], i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i32(ptr align 4 [[AR:%.*]], i8 0, i32 [[TMP3]], i1 false)
; CHECK-NEXT: br label [[FOR_END10]]
; CHECK: for.end10:
; CHECK-NEXT: ret void
@@ -141,15 +136,14 @@ for.body.us: ; preds = %for.body.us.prehead
%i.04.us = phi i32 [ %inc9.us, %for.cond1.for.end_crit_edge.us ], [ 0, %for.body.us.preheader ]
%mul.us = mul nsw i32 %i.04.us, %m
%mul4.us = mul nsw i32 %mul.us, %o
- %add.ptr.us = getelementptr inbounds i32, i32* %ar, i32 %mul4.us
+ %add.ptr.us = getelementptr inbounds i32, ptr %ar, i32 %mul4.us
br label %for.body3.us
for.body3.us: ; preds = %for.body.us, %for.body3.us
%j.02.us = phi i32 [ 0, %for.body.us ], [ %inc.us, %for.body3.us ]
%mul5.us = mul nsw i32 %j.02.us, %o
- %add.ptr6.us = getelementptr inbounds i32, i32* %add.ptr.us, i32 %mul5.us
- %0 = bitcast i32* %add.ptr6.us to i8*
- call void @llvm.memset.p0i8.i32(i8* align 4 %0, i8 0, i32 %mul7, i1 false)
+ %add.ptr6.us = getelementptr inbounds i32, ptr %add.ptr.us, i32 %mul5.us
+ call void @llvm.memset.p0.i32(ptr align 4 %add.ptr6.us, i8 0, i32 %mul7, i1 false)
%inc.us = add nuw nsw i32 %j.02.us, 1
%exitcond = icmp ne i32 %inc.us, %m
br i1 %exitcond, label %for.body3.us, label %for.cond1.for.end_crit_edge.us
@@ -173,10 +167,9 @@ for.end10: ; preds = %for.end10.loopexit,
; memset(arr, 0, m * sizeof(int));
; }
; }
-define dso_local void @PositiveFor64(i32* %ar, i64 %n, i64 %m) #0 {
+define dso_local void @PositiveFor64(ptr %ar, i64 %n, i64 %m) #0 {
; CHECK-LABEL: @PositiveFor64(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[AR1:%.*]] = bitcast i32* [[AR:%.*]] to i8*
; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i64 0, [[N:%.*]]
; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_BODY_LR_PH:%.*]], label [[FOR_END:%.*]]
; CHECK: for.body.lr.ph:
@@ -186,7 +179,7 @@ define dso_local void @PositiveFor64(i32* %ar, i64 %n, i64 %m) #0 {
; CHECK-NEXT: [[TMP1:%.*]] = trunc i64 [[N]] to i32
; CHECK-NEXT: [[TMP2:%.*]] = mul i32 [[TMP0]], [[TMP1]]
; CHECK-NEXT: [[TMP3:%.*]] = shl i32 [[TMP2]], 2
-; CHECK-NEXT: call void @llvm.memset.p0i8.i32(i8* align 4 [[AR1]], i8 0, i32 [[TMP3]], i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i32(ptr align 4 [[AR:%.*]], i8 0, i32 [[TMP3]], i1 false)
; CHECK-NEXT: br label [[FOR_END]]
; CHECK: for.end:
; CHECK-NEXT: ret void
@@ -205,9 +198,8 @@ for.body: ; preds = %for.body.lr.ph, %fo
%conv2 = sext i32 %i.02 to i64
%mul = mul nsw i64 %conv2, %m
%idx.ext = trunc i64 %mul to i32
- %add.ptr = getelementptr inbounds i32, i32* %ar, i32 %idx.ext
- %0 = bitcast i32* %add.ptr to i8*
- call void @llvm.memset.p0i8.i32(i8* align 4 %0, i8 0, i32 %conv4, i1 false)
+ %add.ptr = getelementptr inbounds i32, ptr %ar, i32 %idx.ext
+ call void @llvm.memset.p0.i32(ptr align 4 %add.ptr, i8 0, i32 %conv4, i1 false)
%inc = add nuw nsw i32 %i.02, 1
%conv = sext i32 %inc to i64
%cmp = icmp slt i64 %conv, %n
@@ -227,10 +219,9 @@ for.end: ; preds = %for.end.loopexit, %
; memset(arr, 0, m * sizeof(int));
; }
; }
-define dso_local void @NegativeFor64(i32* %ar, i64 %n, i64 %m) #0 {
+define dso_local void @NegativeFor64(ptr %ar, i64 %n, i64 %m) #0 {
; CHECK-LABEL: @NegativeFor64(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[AR1:%.*]] = bitcast i32* [[AR:%.*]] to i8*
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i64 [[N:%.*]], 1
; CHECK-NEXT: [[CONV:%.*]] = trunc i64 [[SUB]] to i32
; CHECK-NEXT: [[CMP1:%.*]] = icmp sge i32 [[CONV]], 0
@@ -242,7 +233,7 @@ define dso_local void @NegativeFor64(i32* %ar, i64 %n, i64 %m) #0 {
; CHECK-NEXT: [[TMP1:%.*]] = trunc i64 [[N]] to i32
; CHECK-NEXT: [[TMP2:%.*]] = mul i32 [[TMP0]], [[TMP1]]
; CHECK-NEXT: [[TMP3:%.*]] = shl i32 [[TMP2]], 2
-; CHECK-NEXT: call void @llvm.memset.p0i8.i32(i8* align 4 [[AR1]], i8 0, i32 [[TMP3]], i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i32(ptr align 4 [[AR:%.*]], i8 0, i32 [[TMP3]], i1 false)
; CHECK-NEXT: br label [[FOR_END]]
; CHECK: for.end:
; CHECK-NEXT: ret void
@@ -263,9 +254,8 @@ for.body: ; preds = %for.body.lr.ph, %fo
%conv2 = sext i32 %i.02 to i64
%mul = mul nsw i64 %conv2, %m
%idx.ext = trunc i64 %mul to i32
- %add.ptr = getelementptr inbounds i32, i32* %ar, i32 %idx.ext
- %0 = bitcast i32* %add.ptr to i8*
- call void @llvm.memset.p0i8.i32(i8* align 4 %0, i8 0, i32 %conv4, i1 false)
+ %add.ptr = getelementptr inbounds i32, ptr %ar, i32 %idx.ext
+ call void @llvm.memset.p0.i32(ptr align 4 %add.ptr, i8 0, i32 %conv4, i1 false)
%dec = add nsw i32 %i.02, -1
%cmp = icmp sge i32 %dec, 0
br i1 %cmp, label %for.body, label %for.end.loopexit
@@ -286,7 +276,7 @@ for.end: ; preds = %for.end.loopexit, %
; }
; }
; }
-define dso_local void @NestedFor64(i32* %ar, i64 %n, i64 %m, i64 %o) #0 {
+define dso_local void @NestedFor64(ptr %ar, i64 %n, i64 %m, i64 %o) #0 {
; CHECK-LABEL: @NestedFor64(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CMP3:%.*]] = icmp slt i64 0, [[N:%.*]]
@@ -298,22 +288,22 @@ define dso_local void @NestedFor64(i32* %ar, i64 %n, i64 %m, i64 %o) #0 {
; CHECK: for.body.us.preheader:
; CHECK-NEXT: [[TMP0:%.*]] = mul i64 [[O]], [[M]]
; CHECK-NEXT: [[TMP1:%.*]] = trunc i64 [[TMP0]] to i32
-; CHECK-NEXT: [[TMP2:%.*]] = trunc i64 [[O]] to i32
-; CHECK-NEXT: [[TMP3:%.*]] = trunc i64 [[M]] to i32
-; CHECK-NEXT: [[TMP4:%.*]] = mul i32 [[TMP2]], [[TMP3]]
-; CHECK-NEXT: [[TMP5:%.*]] = shl i32 [[TMP4]], 2
+; CHECK-NEXT: [[TMP2:%.*]] = shl i32 [[TMP1]], 2
+; CHECK-NEXT: [[TMP3:%.*]] = trunc i64 [[O]] to i32
+; CHECK-NEXT: [[TMP4:%.*]] = trunc i64 [[M]] to i32
+; CHECK-NEXT: [[TMP5:%.*]] = mul i32 [[TMP3]], [[TMP4]]
+; CHECK-NEXT: [[TMP6:%.*]] = shl i32 [[TMP5]], 2
; CHECK-NEXT: br label [[FOR_BODY_US:%.*]]
; CHECK: for.body.us:
; CHECK-NEXT: [[I_04_US:%.*]] = phi i32 [ [[INC16_US:%.*]], [[FOR_BODY_US]] ], [ 0, [[FOR_BODY_US_PREHEADER]] ]
-; CHECK-NEXT: [[TMP6:%.*]] = mul i32 [[TMP1]], [[I_04_US]]
-; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i32, i32* [[AR:%.*]], i32 [[TMP6]]
-; CHECK-NEXT: [[SCEVGEP1:%.*]] = bitcast i32* [[SCEVGEP]] to i8*
+; CHECK-NEXT: [[TMP7:%.*]] = mul i32 [[TMP2]], [[I_04_US]]
+; CHECK-NEXT: [[UGLYGEP:%.*]] = getelementptr i8, ptr [[AR:%.*]], i32 [[TMP7]]
; CHECK-NEXT: [[CONV7_US:%.*]] = sext i32 [[I_04_US]] to i64
; CHECK-NEXT: [[MUL_US:%.*]] = mul nsw i64 [[CONV7_US]], [[M]]
; CHECK-NEXT: [[MUL8_US:%.*]] = mul nsw i64 [[MUL_US]], [[O]]
; CHECK-NEXT: [[IDX_EXT_US:%.*]] = trunc i64 [[MUL8_US]] to i32
-; CHECK-NEXT: [[ADD_PTR_US:%.*]] = getelementptr inbounds i32, i32* [[AR]], i32 [[IDX_EXT_US]]
-; CHECK-NEXT: call void @llvm.memset.p0i8.i32(i8* align 4 [[SCEVGEP1]], i8 0, i32 [[TMP5]], i1 false)
+; CHECK-NEXT: [[ADD_PTR_US:%.*]] = getelementptr inbounds i32, ptr [[AR]], i32 [[IDX_EXT_US]]
+; CHECK-NEXT: call void @llvm.memset.p0.i32(ptr align 4 [[UGLYGEP]], i8 0, i32 [[TMP6]], i1 false)
; CHECK-NEXT: [[INC16_US]] = add nuw nsw i32 [[I_04_US]], 1
; CHECK-NEXT: [[CONV_US:%.*]] = sext i32 [[INC16_US]] to i64
; CHECK-NEXT: [[CMP_US:%.*]] = icmp slt i64 [[CONV_US]], [[N]]
@@ -340,7 +330,7 @@ for.body.us: ; preds = %for.body.us.prehead
%mul.us = mul nsw i64 %conv7.us, %m
%mul8.us = mul nsw i64 %mul.us, %o
%idx.ext.us = trunc i64 %mul8.us to i32
- %add.ptr.us = getelementptr inbounds i32, i32* %ar, i32 %idx.ext.us
+ %add.ptr.us = getelementptr inbounds i32, ptr %ar, i32 %idx.ext.us
br label %for.body6.us
for.body6.us: ; preds = %for.body.us, %for.body6.us
@@ -348,9 +338,8 @@ for.body6.us: ; preds = %for.body.us, %for.b
%conv9.us = sext i32 %j.02.us to i64
%mul10.us = mul nsw i64 %conv9.us, %o
%idx.ext11.us = trunc i64 %mul10.us to i32
- %add.ptr12.us = getelementptr inbounds i32, i32* %add.ptr.us, i32 %idx.ext11.us
- %0 = bitcast i32* %add.ptr12.us to i8*
- call void @llvm.memset.p0i8.i32(i8* align 4 %0, i8 0, i32 %conv14, i1 false)
+ %add.ptr12.us = getelementptr inbounds i32, ptr %add.ptr.us, i32 %idx.ext11.us
+ call void @llvm.memset.p0.i32(ptr align 4 %add.ptr12.us, i8 0, i32 %conv14, i1 false)
%inc.us = add nuw nsw i32 %j.02.us, 1
%conv3.us = sext i32 %inc.us to i64
%cmp4.us = icmp slt i64 %conv3.us, %m
@@ -375,10 +364,9 @@ for.end17: ; preds = %for.end17.loopexit,
; memset(arr, 0, m * sizeof(int));
; }
; }
-define void @NegStart(i32 %n, i32 %m, i32* %ar) {
+define void @NegStart(i32 %n, i32 %m, ptr %ar) {
; CHECK-LABEL: @NegStart(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[AR1:%.*]] = bitcast i32* [[AR:%.*]] to i8*
; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i32 -100, [[N:%.*]]
; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_BODY_LR_PH:%.*]], label [[FOR_END:%.*]]
; CHECK: for.body.lr.ph:
@@ -386,7 +374,7 @@ define void @NegStart(i32 %n, i32 %m, i32* %ar) {
; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[N]], 100
; CHECK-NEXT: [[TMP1:%.*]] = mul i32 [[M]], [[TMP0]]
; CHECK-NEXT: [[TMP2:%.*]] = shl i32 [[TMP1]], 2
-; CHECK-NEXT: call void @llvm.memset.p0i8.i32(i8* align 4 [[AR1]], i8 0, i32 [[TMP2]], i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i32(ptr align 4 [[AR:%.*]], i8 0, i32 [[TMP2]], i1 false)
; CHECK-NEXT: br label [[FOR_END]]
; CHECK: for.end:
; CHECK-NEXT: ret void
@@ -403,9 +391,8 @@ for.body: ; preds = %for.body.lr.ph, %fo
%i.02 = phi i32 [ -100, %for.body.lr.ph ], [ %inc, %for.body ]
%add = add nsw i32 %i.02, 100
%mul = mul nsw i32 %add, %m
- %add.ptr = getelementptr inbounds i32, i32* %ar, i32 %mul
- %0 = bitcast i32* %add.ptr to i8*
- call void @llvm.memset.p0i8.i32(i8* align 4 %0, i8 0, i32 %mul1, i1 false)
+ %add.ptr = getelementptr inbounds i32, ptr %ar, i32 %mul
+ call void @llvm.memset.p0.i32(ptr align 4 %add.ptr, i8 0, i32 %mul1, i1 false)
%inc = add nsw i32 %i.02, 1
%exitcond = icmp ne i32 %inc, %n
br i1 %exitcond, label %for.body, label %for.end.loopexit
@@ -417,4 +404,4 @@ for.end: ; preds = %for.end.loopexit, %
ret void
}
-declare void @llvm.memset.p0i8.i32(i8* nocapture writeonly, i8, i32, i1 immarg)
+declare void @llvm.memset.p0.i32(ptr nocapture writeonly, i8, i32, i1 immarg)
diff --git a/llvm/test/Transforms/LoopIdiom/memset-runtime-64bit.ll b/llvm/test/Transforms/LoopIdiom/memset-runtime-64bit.ll
index 0350ae261dc41..6ce935044e951 100644
--- a/llvm/test/Transforms/LoopIdiom/memset-runtime-64bit.ll
+++ b/llvm/test/Transforms/LoopIdiom/memset-runtime-64bit.ll
@@ -14,17 +14,16 @@ target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16
; memset(arr, 0, m * sizeof(int));
; }
; }
-define dso_local void @PositiveFor64(i32* %ar, i64 %n, i64 %m) {
+define dso_local void @PositiveFor64(ptr %ar, i64 %n, i64 %m) {
; CHECK-LABEL: @PositiveFor64(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[AR1:%.*]] = bitcast i32* [[AR:%.*]] to i8*
; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i64 0, [[N:%.*]]
; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_BODY_LR_PH:%.*]], label [[FOR_END:%.*]]
; CHECK: for.body.lr.ph:
; CHECK-NEXT: [[MUL1:%.*]] = mul i64 [[M:%.*]], 4
; CHECK-NEXT: [[TMP0:%.*]] = mul i64 [[M]], [[N]]
; CHECK-NEXT: [[TMP1:%.*]] = shl i64 [[TMP0]], 2
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 4 [[AR1]], i8 0, i64 [[TMP1]], i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 4 [[AR:%.*]], i8 0, i64 [[TMP1]], i1 false)
; CHECK-NEXT: br label [[FOR_END]]
; CHECK: for.end:
; CHECK-NEXT: ret void
@@ -40,9 +39,8 @@ for.body.lr.ph: ; preds = %entry
for.body: ; preds = %for.body.lr.ph, %for.body
%i.02 = phi i64 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
%mul = mul nsw i64 %i.02, %m
- %add.ptr = getelementptr inbounds i32, i32* %ar, i64 %mul
- %0 = bitcast i32* %add.ptr to i8*
- call void @llvm.memset.p0i8.i64(i8* align 4 %0, i8 0, i64 %mul1, i1 false)
+ %add.ptr = getelementptr inbounds i32, ptr %ar, i64 %mul
+ call void @llvm.memset.p0.i64(ptr align 4 %add.ptr, i8 0, i64 %mul1, i1 false)
%inc = add nsw i64 %i.02, 1
%cmp = icmp slt i64 %inc, %n
br i1 %cmp, label %for.body, label %for.end
@@ -58,10 +56,9 @@ for.end: ; preds = %for.body, %entry
; memset(arr, 0, m * sizeof(int));
; }
; }
-define dso_local void @NegativeFor64(i32* %ar, i64 %n, i64 %m) {
+define dso_local void @NegativeFor64(ptr %ar, i64 %n, i64 %m) {
; CHECK-LABEL: @NegativeFor64(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[AR1:%.*]] = bitcast i32* [[AR:%.*]] to i8*
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i64 [[N:%.*]], 1
; CHECK-NEXT: [[CMP1:%.*]] = icmp sge i64 [[SUB]], 0
; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_BODY_LR_PH:%.*]], label [[FOR_END:%.*]]
@@ -69,7 +66,7 @@ define dso_local void @NegativeFor64(i32* %ar, i64 %n, i64 %m) {
; CHECK-NEXT: [[MUL1:%.*]] = mul i64 [[M:%.*]], 4
; CHECK-NEXT: [[TMP0:%.*]] = mul i64 [[M]], [[N]]
; CHECK-NEXT: [[TMP1:%.*]] = shl i64 [[TMP0]], 2
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 4 [[AR1]], i8 0, i64 [[TMP1]], i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 4 [[AR:%.*]], i8 0, i64 [[TMP1]], i1 false)
; CHECK-NEXT: br label [[FOR_END]]
; CHECK: for.end:
; CHECK-NEXT: ret void
@@ -86,9 +83,8 @@ for.body.lr.ph: ; preds = %entry
for.body: ; preds = %for.body.lr.ph, %for.body
%i.02 = phi i64 [ %sub, %for.body.lr.ph ], [ %dec, %for.body ]
%mul = mul nsw i64 %i.02, %m
- %add.ptr = getelementptr inbounds i32, i32* %ar, i64 %mul
- %0 = bitcast i32* %add.ptr to i8*
- call void @llvm.memset.p0i8.i64(i8* align 4 %0, i8 0, i64 %mul1, i1 false)
+ %add.ptr = getelementptr inbounds i32, ptr %ar, i64 %mul
+ call void @llvm.memset.p0.i64(ptr align 4 %add.ptr, i8 0, i64 %mul1, i1 false)
%dec = add nsw i64 %i.02, -1
%cmp = icmp sge i64 %dec, 0
br i1 %cmp, label %for.body, label %for.end
@@ -106,10 +102,9 @@ for.end: ; preds = %for.body, %entry
; }
; }
; }
-define void @NestedFor64(i32* %ar, i64 %n, i64 %m, i64 %o) {
+define void @NestedFor64(ptr %ar, i64 %n, i64 %m, i64 %o) {
; CHECK-LABEL: @NestedFor64(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[AR2:%.*]] = bitcast i32* [[AR:%.*]] to i8*
; CHECK-NEXT: [[CMP3:%.*]] = icmp slt i64 0, [[N:%.*]]
; CHECK-NEXT: [[CMP21:%.*]] = icmp slt i64 0, [[M:%.*]]
; CHECK-NEXT: [[MUL7:%.*]] = mul i64 [[O:%.*]], 4
@@ -120,7 +115,7 @@ define void @NestedFor64(i32* %ar, i64 %n, i64 %m, i64 %o) {
; CHECK-NEXT: [[TMP1:%.*]] = shl i64 [[TMP0]], 2
; CHECK-NEXT: [[TMP2:%.*]] = mul i64 [[TMP0]], [[N]]
; CHECK-NEXT: [[TMP3:%.*]] = shl i64 [[TMP2]], 2
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 4 [[AR2]], i8 0, i64 [[TMP3]], i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 4 [[AR:%.*]], i8 0, i64 [[TMP3]], i1 false)
; CHECK-NEXT: br label [[FOR_END10]]
; CHECK: for.end10:
; CHECK-NEXT: ret void
@@ -141,15 +136,14 @@ for.body.us: ; preds = %for.body.us.prehead
%i.04.us = phi i64 [ %inc9.us, %for.cond1.for.end_crit_edge.us ], [ 0, %for.body.us.preheader ]
%mul.us = mul nsw i64 %i.04.us, %m
%mul4.us = mul nsw i64 %mul.us, %o
- %add.ptr.us = getelementptr inbounds i32, i32* %ar, i64 %mul4.us
+ %add.ptr.us = getelementptr inbounds i32, ptr %ar, i64 %mul4.us
br label %for.body3.us
for.body3.us: ; preds = %for.body.us, %for.body3.us
%j.02.us = phi i64 [ 0, %for.body.us ], [ %inc.us, %for.body3.us ]
%mul5.us = mul nsw i64 %j.02.us, %o
- %add.ptr6.us = getelementptr inbounds i32, i32* %add.ptr.us, i64 %mul5.us
- %0 = bitcast i32* %add.ptr6.us to i8*
- call void @llvm.memset.p0i8.i64(i8* align 4 %0, i8 0, i64 %mul7, i1 false)
+ %add.ptr6.us = getelementptr inbounds i32, ptr %add.ptr.us, i64 %mul5.us
+ call void @llvm.memset.p0.i64(ptr align 4 %add.ptr6.us, i8 0, i64 %mul7, i1 false)
%inc.us = add nuw nsw i64 %j.02.us, 1
%exitcond = icmp ne i64 %inc.us, %m
br i1 %exitcond, label %for.body3.us, label %for.cond1.for.end_crit_edge.us
@@ -173,10 +167,9 @@ for.end10: ; preds = %for.end10.loopexit,
; memset(arr, 0, m * sizeof(int));
; }
; }
-define void @PositiveFor32(i32* %ar, i32 %n, i32 %m) {
+define void @PositiveFor32(ptr %ar, i32 %n, i32 %m) {
; CHECK-LABEL: @PositiveFor32(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[AR1:%.*]] = bitcast i32* [[AR:%.*]] to i8*
; CHECK-NEXT: [[CONV:%.*]] = sext i32 [[N:%.*]] to i64
; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i64 0, [[CONV]]
; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_BODY_LR_PH:%.*]], label [[FOR_END:%.*]]
@@ -186,7 +179,7 @@ define void @PositiveFor32(i32* %ar, i32 %n, i32 %m) {
; CHECK-NEXT: [[MUL3:%.*]] = mul i64 [[CONV2]], 4
; CHECK-NEXT: [[TMP0:%.*]] = mul i64 [[CONV1]], [[CONV]]
; CHECK-NEXT: [[TMP1:%.*]] = shl i64 [[TMP0]], 2
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 4 [[AR1]], i8 0, i64 [[TMP1]], i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 4 [[AR:%.*]], i8 0, i64 [[TMP1]], i1 false)
; CHECK-NEXT: br label [[FOR_END]]
; CHECK: for.end:
; CHECK-NEXT: ret void
@@ -205,9 +198,8 @@ for.body.lr.ph: ; preds = %entry
for.body: ; preds = %for.body.lr.ph, %for.body
%i.02 = phi i64 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
%mul = mul nsw i64 %i.02, %conv1
- %add.ptr = getelementptr inbounds i32, i32* %ar, i64 %mul
- %0 = bitcast i32* %add.ptr to i8*
- call void @llvm.memset.p0i8.i64(i8* align 4 %0, i8 0, i64 %mul3, i1 false)
+ %add.ptr = getelementptr inbounds i32, ptr %ar, i64 %mul
+ call void @llvm.memset.p0.i64(ptr align 4 %add.ptr, i8 0, i64 %mul3, i1 false)
%inc = add nsw i64 %i.02, 1
%cmp = icmp slt i64 %inc, %conv
br i1 %cmp, label %for.body, label %for.end
@@ -223,10 +215,9 @@ for.end: ; preds = %for.body, %entry
; memset(arr, 0, m * sizeof(int));
; }
; }
-define void @Negative32(i32* %ar, i32 %n, i32 %m) {
+define void @Negative32(ptr %ar, i32 %n, i32 %m) {
; CHECK-LABEL: @Negative32(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[AR1:%.*]] = bitcast i32* [[AR:%.*]] to i8*
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 [[N:%.*]], 1
; CHECK-NEXT: [[CONV:%.*]] = sext i32 [[SUB]] to i64
; CHECK-NEXT: [[CMP1:%.*]] = icmp sge i64 [[CONV]], 0
@@ -238,7 +229,7 @@ define void @Negative32(i32* %ar, i32 %n, i32 %m) {
; CHECK-NEXT: [[TMP0:%.*]] = sext i32 [[N]] to i64
; CHECK-NEXT: [[TMP1:%.*]] = mul i64 [[CONV1]], [[TMP0]]
; CHECK-NEXT: [[TMP2:%.*]] = shl i64 [[TMP1]], 2
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 4 [[AR1]], i8 0, i64 [[TMP2]], i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 4 [[AR:%.*]], i8 0, i64 [[TMP2]], i1 false)
; CHECK-NEXT: br label [[FOR_END]]
; CHECK: for.end:
; CHECK-NEXT: ret void
@@ -258,9 +249,8 @@ for.body.lr.ph: ; preds = %entry
for.body: ; preds = %for.body.lr.ph, %for.body
%i.02 = phi i64 [ %conv, %for.body.lr.ph ], [ %dec, %for.body ]
%mul = mul nsw i64 %i.02, %conv1
- %add.ptr = getelementptr inbounds i32, i32* %ar, i64 %mul
- %0 = bitcast i32* %add.ptr to i8*
- call void @llvm.memset.p0i8.i64(i8* align 4 %0, i8 0, i64 %mul3, i1 false)
+ %add.ptr = getelementptr inbounds i32, ptr %ar, i64 %mul
+ call void @llvm.memset.p0.i64(ptr align 4 %add.ptr, i8 0, i64 %mul3, i1 false)
%dec = add nsw i64 %i.02, -1
%cmp = icmp sge i64 %dec, 0
br i1 %cmp, label %for.body, label %for.end
@@ -284,10 +274,9 @@ for.end: ; preds = %for.body, %entry
; }
; }
; }
-define void @NestedFor32(i32* %ar, i32 %n, i32 %m, i32 %o) {
+define void @NestedFor32(ptr %ar, i32 %n, i32 %m, i32 %o) {
; CHECK-LABEL: @NestedFor32(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[AR2:%.*]] = bitcast i32* [[AR:%.*]] to i8*
; CHECK-NEXT: [[CMP3:%.*]] = icmp slt i32 0, [[N:%.*]]
; CHECK-NEXT: br i1 [[CMP3]], label [[FOR_BODY_LR_PH:%.*]], label [[FOR_END11:%.*]]
; CHECK: for.body.lr.ph:
@@ -300,12 +289,13 @@ define void @NestedFor32(i32* %ar, i32 %n, i32 %m, i32 %o) {
; CHECK-NEXT: [[TMP1:%.*]] = sext i32 [[M]] to i64
; CHECK-NEXT: [[WIDE_TRIP_COUNT10:%.*]] = zext i32 [[N]] to i64
; CHECK-NEXT: [[TMP2:%.*]] = mul i64 [[TMP0]], [[TMP1]]
-; CHECK-NEXT: [[TMP3:%.*]] = zext i32 [[M]] to i64
-; CHECK-NEXT: [[TMP4:%.*]] = mul i64 [[TMP0]], [[TMP3]]
-; CHECK-NEXT: [[TMP5:%.*]] = shl i64 [[TMP4]], 2
-; CHECK-NEXT: [[TMP6:%.*]] = mul i64 [[TMP4]], [[WIDE_TRIP_COUNT10]]
-; CHECK-NEXT: [[TMP7:%.*]] = shl i64 [[TMP6]], 2
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 4 [[AR2]], i8 0, i64 [[TMP7]], i1 false)
+; CHECK-NEXT: [[TMP3:%.*]] = shl i64 [[TMP2]], 2
+; CHECK-NEXT: [[TMP4:%.*]] = zext i32 [[M]] to i64
+; CHECK-NEXT: [[TMP5:%.*]] = mul i64 [[TMP0]], [[TMP4]]
+; CHECK-NEXT: [[TMP6:%.*]] = shl i64 [[TMP5]], 2
+; CHECK-NEXT: [[TMP7:%.*]] = mul i64 [[TMP5]], [[WIDE_TRIP_COUNT10]]
+; CHECK-NEXT: [[TMP8:%.*]] = shl i64 [[TMP7]], 2
+; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 4 [[AR:%.*]], i8 0, i64 [[TMP8]], i1 false)
; CHECK-NEXT: br label [[FOR_END11]]
; CHECK: for.end11:
; CHECK-NEXT: ret void
@@ -331,16 +321,15 @@ for.body.us: ; preds = %for.body.us.prehead
%indvars.iv6 = phi i64 [ 0, %for.body.us.preheader ], [ %indvars.iv.next7, %for.cond1.for.end_crit_edge.us ]
%3 = mul nsw i64 %indvars.iv6, %1
%4 = mul nsw i64 %3, %2
- %add.ptr.us = getelementptr inbounds i32, i32* %ar, i64 %4
+ %add.ptr.us = getelementptr inbounds i32, ptr %ar, i64 %4
%wide.trip.count = zext i32 %m to i64
br label %for.body3.us
for.body3.us: ; preds = %for.body.us, %for.body3.us
%indvars.iv = phi i64 [ 0, %for.body.us ], [ %indvars.iv.next, %for.body3.us ]
%5 = mul nsw i64 %indvars.iv, %0
- %add.ptr7.us = getelementptr inbounds i32, i32* %add.ptr.us, i64 %5
- %6 = bitcast i32* %add.ptr7.us to i8*
- call void @llvm.memset.p0i8.i64(i8* align 4 %6, i8 0, i64 %mul8, i1 false)
+ %add.ptr7.us = getelementptr inbounds i32, ptr %add.ptr.us, i64 %5
+ call void @llvm.memset.p0.i64(ptr align 4 %add.ptr7.us, i8 0, i64 %mul8, i1 false)
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond = icmp ne i64 %indvars.iv.next, %wide.trip.count
br i1 %exitcond, label %for.body3.us, label %for.cond1.for.end_crit_edge.us
@@ -363,10 +352,9 @@ for.end11: ; preds = %for.end11.loopexit,
; memset(arr, 0, m * sizeof(int));
; }
; }
-define void @NegStart(i32 %n, i32 %m, i32* %ar) {
+define void @NegStart(i32 %n, i32 %m, ptr %ar) {
; CHECK-LABEL: @NegStart(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[AR1:%.*]] = bitcast i32* [[AR:%.*]] to i8*
; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i32 -100, [[N:%.*]]
; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_BODY_LR_PH:%.*]], label [[FOR_END:%.*]]
; CHECK: for.body.lr.ph:
@@ -377,7 +365,7 @@ define void @NegStart(i32 %n, i32 %m, i32* %ar) {
; CHECK-NEXT: [[TMP1:%.*]] = add nsw i64 [[WIDE_TRIP_COUNT]], 100
; CHECK-NEXT: [[TMP2:%.*]] = mul i64 [[TMP1]], [[TMP0]]
; CHECK-NEXT: [[TMP3:%.*]] = shl i64 [[TMP2]], 2
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 4 [[AR1]], i8 0, i64 [[TMP3]], i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 4 [[AR:%.*]], i8 0, i64 [[TMP3]], i1 false)
; CHECK-NEXT: br label [[FOR_END]]
; CHECK: for.end:
; CHECK-NEXT: ret void
@@ -397,9 +385,8 @@ for.body: ; preds = %for.body.lr.ph, %fo
%indvars.iv = phi i64 [ -100, %for.body.lr.ph ], [ %indvars.iv.next, %for.body ]
%1 = add nsw i64 %indvars.iv, 100
%2 = mul nsw i64 %1, %0
- %add.ptr = getelementptr inbounds i32, i32* %ar, i64 %2
- %3 = bitcast i32* %add.ptr to i8*
- call void @llvm.memset.p0i8.i64(i8* align 4 %3, i8 0, i64 %mul1, i1 false)
+ %add.ptr = getelementptr inbounds i32, ptr %ar, i64 %2
+ call void @llvm.memset.p0.i64(ptr align 4 %add.ptr, i8 0, i64 %mul1, i1 false)
%indvars.iv.next = add nsw i64 %indvars.iv, 1
%exitcond = icmp ne i64 %indvars.iv.next, %wide.trip.count
br i1 %exitcond, label %for.body, label %for.end.loopexit
@@ -411,4 +398,4 @@ for.end: ; preds = %for.end.loopexit, %
ret void
}
-declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1 immarg)
+declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg)
diff --git a/llvm/test/Transforms/LoopIdiom/phi-insertion.ll b/llvm/test/Transforms/LoopIdiom/phi-insertion.ll
index f8f6cf23c8c80..b35178e168d77 100644
--- a/llvm/test/Transforms/LoopIdiom/phi-insertion.ll
+++ b/llvm/test/Transforms/LoopIdiom/phi-insertion.ll
@@ -1,28 +1,28 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -passes=loop-idiom -S %s | FileCheck %s
-define void @phi_insertion(i1 %c, i32* %ptr.start, i32* %ptr.end, i64 %offset) {
+define void @phi_insertion(i1 %c, ptr %ptr.start, ptr %ptr.end, i64 %offset) {
; CHECK-LABEL: @phi_insertion(
; CHECK-NEXT: bb5:
; CHECK-NEXT: br i1 [[C:%.*]], label [[LOOP_0_PH:%.*]], label [[EXIT:%.*]]
; CHECK: loop.0.ph:
; CHECK-NEXT: br label [[LOOP_0:%.*]]
; CHECK: loop.0:
-; CHECK-NEXT: [[IV_0:%.*]] = phi i32* [ [[IV_0_NEXT:%.*]], [[LOOP_0_LATCH:%.*]] ], [ [[PTR_START:%.*]], [[LOOP_0_PH]] ]
-; CHECK-NEXT: [[COND:%.*]] = icmp eq i32* [[IV_0]], [[PTR_END:%.*]]
+; CHECK-NEXT: [[IV_0:%.*]] = phi ptr [ [[IV_0_NEXT:%.*]], [[LOOP_0_LATCH:%.*]] ], [ [[PTR_START:%.*]], [[LOOP_0_PH]] ]
+; CHECK-NEXT: [[COND:%.*]] = icmp eq ptr [[IV_0]], [[PTR_END:%.*]]
; CHECK-NEXT: br i1 [[COND]], label [[LOOP_1_PREHEADER:%.*]], label [[EXIT_LOOPEXIT:%.*]]
; CHECK: loop.1.preheader:
; CHECK-NEXT: br label [[LOOP_1:%.*]]
; CHECK: loop.1:
-; CHECK-NEXT: [[PTR_1:%.*]] = getelementptr inbounds i32, i32* [[IV_0]], i64 0
-; CHECK-NEXT: [[LV:%.*]] = load i32, i32* [[PTR_1]], align 8
-; CHECK-NEXT: [[PTR_2:%.*]] = getelementptr inbounds i32, i32* [[IV_0]], i64 0
-; CHECK-NEXT: store i32 [[LV]], i32* [[PTR_2]], align 8
+; CHECK-NEXT: [[PTR_1:%.*]] = getelementptr inbounds i32, ptr [[IV_0]], i64 0
+; CHECK-NEXT: [[LV:%.*]] = load i32, ptr [[PTR_1]], align 8
+; CHECK-NEXT: [[PTR_2:%.*]] = getelementptr inbounds i32, ptr [[IV_0]], i64 0
+; CHECK-NEXT: store i32 [[LV]], ptr [[PTR_2]], align 8
; CHECK-NEXT: [[IV_1_NEXT:%.*]] = add nuw nsw i64 0, 1
; CHECK-NEXT: [[EC:%.*]] = icmp eq i64 [[IV_1_NEXT]], 100
; CHECK-NEXT: br i1 [[EC]], label [[LOOP_0_LATCH]], label [[LOOP_1]]
; CHECK: loop.0.latch:
-; CHECK-NEXT: [[IV_0_NEXT]] = getelementptr inbounds i32, i32* [[IV_0]], i64 [[OFFSET:%.*]]
+; CHECK-NEXT: [[IV_0_NEXT]] = getelementptr inbounds i32, ptr [[IV_0]], i64 [[OFFSET:%.*]]
; CHECK-NEXT: br label [[LOOP_0]]
; CHECK: exit.loopexit:
; CHECK-NEXT: br label [[EXIT]]
@@ -36,22 +36,22 @@ loop.0.ph: ; preds = %bb5
br label %loop.0
loop.0: ; preds = %loop.0.latch, %loop.0.ph
- %iv.0 = phi i32* [ %iv.0.next, %loop.0.latch ], [ %ptr.start, %loop.0.ph ]
- %cond = icmp eq i32* %iv.0, %ptr.end
+ %iv.0 = phi ptr [ %iv.0.next, %loop.0.latch ], [ %ptr.start, %loop.0.ph ]
+ %cond = icmp eq ptr %iv.0, %ptr.end
br i1 %cond, label %loop.1, label %exit
loop.1: ; preds = %loop.1, %loop.0
%iv.1 = phi i64 [ 0, %loop.0 ], [ %iv.1, %loop.1 ]
- %ptr.1 = getelementptr inbounds i32, i32* %iv.0, i64 %iv.1
- %lv = load i32, i32* %ptr.1, align 8
- %ptr.2 = getelementptr inbounds i32, i32* %iv.0, i64 %iv.1
- store i32 %lv, i32* %ptr.2, align 8
+ %ptr.1 = getelementptr inbounds i32, ptr %iv.0, i64 %iv.1
+ %lv = load i32, ptr %ptr.1, align 8
+ %ptr.2 = getelementptr inbounds i32, ptr %iv.0, i64 %iv.1
+ store i32 %lv, ptr %ptr.2, align 8
%iv.1.next = add nuw nsw i64 %iv.1, 1
%ec = icmp eq i64 %iv.1.next, 100
br i1 %ec, label %loop.0.latch, label %loop.1
loop.0.latch: ; preds = %loop.1
- %iv.0.next = getelementptr inbounds i32, i32* %iv.0, i64 %offset
+ %iv.0.next = getelementptr inbounds i32, ptr %iv.0, i64 %offset
br label %loop.0
exit: ; preds = %loop.0, %bb5
diff --git a/llvm/test/Transforms/LoopIdiom/struct-custom-dl.ll b/llvm/test/Transforms/LoopIdiom/struct-custom-dl.ll
index 149a2abc0162c..9794adcaeed64 100644
--- a/llvm/test/Transforms/LoopIdiom/struct-custom-dl.ll
+++ b/llvm/test/Transforms/LoopIdiom/struct-custom-dl.ll
@@ -12,20 +12,19 @@ target datalayout = "e-p:40:64:64:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64
; f[i].b = 0;
; }
;}
-define void @bar1(%struct.foo* %f, i32 %n) nounwind ssp {
+define void @bar1(ptr %f, i32 %n) nounwind ssp {
; CHECK-LABEL: @bar1(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[F1:%.*]] = bitcast %struct.foo* [[F:%.*]] to i8*
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[N:%.*]], 0
; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_END:%.*]], label [[FOR_BODY_PREHEADER:%.*]]
; CHECK: for.body.preheader:
; CHECK-NEXT: [[TMP0:%.*]] = shl nuw i32 [[N]], 3
-; CHECK-NEXT: call void @llvm.memset.p0i8.i32(i8* align 4 [[F1]], i8 0, i32 [[TMP0]], i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i32(ptr align 4 [[F:%.*]], i8 0, i32 [[TMP0]], i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i32 [ 0, [[FOR_BODY_PREHEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO:%.*]], %struct.foo* [[F]], i32 [[INDVARS_IV]], i32 0
-; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO]], %struct.foo* [[F]], i32 [[INDVARS_IV]], i32 1
+; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO:%.*]], ptr [[F]], i32 [[INDVARS_IV]], i32 0
+; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO]], ptr [[F]], i32 [[INDVARS_IV]], i32 1
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i32 [[INDVARS_IV]], 1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i32 [[INDVARS_IV_NEXT]], [[N]]
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_BODY]], label [[FOR_END_LOOPEXIT:%.*]]
@@ -43,10 +42,10 @@ for.body.preheader: ; preds = %entry
for.body: ; preds = %for.body.preheader, %for.body
%indvars.iv = phi i32 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
- %a = getelementptr inbounds %struct.foo, %struct.foo* %f, i32 %indvars.iv, i32 0
- store i32 0, i32* %a, align 4
- %b = getelementptr inbounds %struct.foo, %struct.foo* %f, i32 %indvars.iv, i32 1
- store i32 0, i32* %b, align 4
+ %a = getelementptr inbounds %struct.foo, ptr %f, i32 %indvars.iv, i32 0
+ store i32 0, ptr %a, align 4
+ %b = getelementptr inbounds %struct.foo, ptr %f, i32 %indvars.iv, i32 1
+ store i32 0, ptr %b, align 4
%indvars.iv.next = add nuw nsw i32 %indvars.iv, 1
%exitcond = icmp ne i32 %indvars.iv.next, %n
br i1 %exitcond, label %for.body, label %for.end.loopexit
@@ -64,20 +63,19 @@ for.end: ; preds = %for.end.loopexit, %
; f[i].a = 0;
; }
;}
-define void @bar2(%struct.foo* %f, i32 %n) nounwind ssp {
+define void @bar2(ptr %f, i32 %n) nounwind ssp {
; CHECK-LABEL: @bar2(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[F1:%.*]] = bitcast %struct.foo* [[F:%.*]] to i8*
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[N:%.*]], 0
; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_END:%.*]], label [[FOR_BODY_PREHEADER:%.*]]
; CHECK: for.body.preheader:
; CHECK-NEXT: [[TMP0:%.*]] = shl nuw i32 [[N]], 3
-; CHECK-NEXT: call void @llvm.memset.p0i8.i32(i8* align 4 [[F1]], i8 0, i32 [[TMP0]], i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i32(ptr align 4 [[F:%.*]], i8 0, i32 [[TMP0]], i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i32 [ 0, [[FOR_BODY_PREHEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO:%.*]], %struct.foo* [[F]], i32 [[INDVARS_IV]], i32 1
-; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO]], %struct.foo* [[F]], i32 [[INDVARS_IV]], i32 0
+; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO:%.*]], ptr [[F]], i32 [[INDVARS_IV]], i32 1
+; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO]], ptr [[F]], i32 [[INDVARS_IV]], i32 0
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i32 [[INDVARS_IV]], 1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i32 [[INDVARS_IV_NEXT]], [[N]]
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_BODY]], label [[FOR_END_LOOPEXIT:%.*]]
@@ -95,10 +93,10 @@ for.body.preheader: ; preds = %entry
for.body: ; preds = %for.body.preheader, %for.body
%indvars.iv = phi i32 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
- %b = getelementptr inbounds %struct.foo, %struct.foo* %f, i32 %indvars.iv, i32 1
- store i32 0, i32* %b, align 4
- %a = getelementptr inbounds %struct.foo, %struct.foo* %f, i32 %indvars.iv, i32 0
- store i32 0, i32* %a, align 4
+ %b = getelementptr inbounds %struct.foo, ptr %f, i32 %indvars.iv, i32 1
+ store i32 0, ptr %b, align 4
+ %a = getelementptr inbounds %struct.foo, ptr %f, i32 %indvars.iv, i32 0
+ store i32 0, ptr %a, align 4
%indvars.iv.next = add nuw nsw i32 %indvars.iv, 1
%exitcond = icmp ne i32 %indvars.iv.next, %n
br i1 %exitcond, label %for.body, label %for.end.loopexit
@@ -116,21 +114,20 @@ for.end: ; preds = %for.end.loopexit, %
; f[i].b = 0;
; }
;}
-define void @bar3(%struct.foo* nocapture %f, i32 %n) nounwind ssp {
+define void @bar3(ptr nocapture %f, i32 %n) nounwind ssp {
; CHECK-LABEL: @bar3(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[N:%.*]], 0
; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_END:%.*]], label [[FOR_BODY_PREHEADER:%.*]]
; CHECK: for.body.preheader:
-; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr [[STRUCT_FOO:%.*]], %struct.foo* [[F:%.*]], i32 1
-; CHECK-NEXT: [[SCEVGEP1:%.*]] = bitcast %struct.foo* [[SCEVGEP]] to i8*
+; CHECK-NEXT: [[UGLYGEP:%.*]] = getelementptr i8, ptr [[F:%.*]], i32 8
; CHECK-NEXT: [[TMP0:%.*]] = shl nuw i32 [[N]], 3
-; CHECK-NEXT: call void @llvm.memset.p0i8.i32(i8* align 4 [[SCEVGEP1]], i8 0, i32 [[TMP0]], i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i32(ptr align 4 [[UGLYGEP]], i8 0, i32 [[TMP0]], i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i32 [ [[N]], [[FOR_BODY_PREHEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO]], %struct.foo* [[F]], i32 [[INDVARS_IV]], i32 0
-; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO]], %struct.foo* [[F]], i32 [[INDVARS_IV]], i32 1
+; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO:%.*]], ptr [[F]], i32 [[INDVARS_IV]], i32 0
+; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO]], ptr [[F]], i32 [[INDVARS_IV]], i32 1
; CHECK-NEXT: [[DEC:%.*]] = add i32 [[INDVARS_IV]], -1
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[DEC]], 0
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i32 [[INDVARS_IV]], -1
@@ -149,10 +146,10 @@ for.body.preheader: ; preds = %entry
for.body: ; preds = %for.body.preheader, %for.body
%indvars.iv = phi i32 [ %n, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
- %a = getelementptr inbounds %struct.foo, %struct.foo* %f, i32 %indvars.iv, i32 0
- store i32 0, i32* %a, align 4
- %b = getelementptr inbounds %struct.foo, %struct.foo* %f, i32 %indvars.iv, i32 1
- store i32 0, i32* %b, align 4
+ %a = getelementptr inbounds %struct.foo, ptr %f, i32 %indvars.iv, i32 0
+ store i32 0, ptr %a, align 4
+ %b = getelementptr inbounds %struct.foo, ptr %f, i32 %indvars.iv, i32 1
+ store i32 0, ptr %b, align 4
%dec = add i32 %indvars.iv, -1
%cmp = icmp eq i32 %dec, 0
%indvars.iv.next = add nsw i32 %indvars.iv, -1
@@ -171,7 +168,7 @@ for.end: ; preds = %for.end.loopexit, %
; f[i].b = 1;
; }
;}
-define void @bar4(%struct.foo* nocapture %f, i32 %n) nounwind ssp {
+define void @bar4(ptr nocapture %f, i32 %n) nounwind ssp {
; CHECK-LABEL: @bar4(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[N:%.*]], 0
@@ -180,10 +177,10 @@ define void @bar4(%struct.foo* nocapture %f, i32 %n) nounwind ssp {
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i32 [ 0, [[FOR_BODY_PREHEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO:%.*]], %struct.foo* [[F:%.*]], i32 [[INDVARS_IV]], i32 0
-; CHECK-NEXT: store i32 0, i32* [[A]], align 4
-; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO]], %struct.foo* [[F]], i32 [[INDVARS_IV]], i32 1
-; CHECK-NEXT: store i32 1, i32* [[B]], align 4
+; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO:%.*]], ptr [[F:%.*]], i32 [[INDVARS_IV]], i32 0
+; CHECK-NEXT: store i32 0, ptr [[A]], align 4
+; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO]], ptr [[F]], i32 [[INDVARS_IV]], i32 1
+; CHECK-NEXT: store i32 1, ptr [[B]], align 4
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i32 [[INDVARS_IV]], 1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i32 [[INDVARS_IV_NEXT]], [[N]]
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_BODY]], label [[FOR_END_LOOPEXIT:%.*]]
@@ -201,10 +198,10 @@ for.body.preheader: ; preds = %entry
for.body: ; preds = %for.body.preheader, %for.body
%indvars.iv = phi i32 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
- %a = getelementptr inbounds %struct.foo, %struct.foo* %f, i32 %indvars.iv, i32 0
- store i32 0, i32* %a, align 4
- %b = getelementptr inbounds %struct.foo, %struct.foo* %f, i32 %indvars.iv, i32 1
- store i32 1, i32* %b, align 4
+ %a = getelementptr inbounds %struct.foo, ptr %f, i32 %indvars.iv, i32 0
+ store i32 0, ptr %a, align 4
+ %b = getelementptr inbounds %struct.foo, ptr %f, i32 %indvars.iv, i32 1
+ store i32 1, ptr %b, align 4
%indvars.iv.next = add nuw nsw i32 %indvars.iv, 1
%exitcond = icmp ne i32 %indvars.iv.next, %n
br i1 %exitcond, label %for.body, label %for.end.loopexit
@@ -222,7 +219,7 @@ for.end: ; preds = %for.end.loopexit, %
; f[i].b = 0;
; }
;}
-define void @bar5(%struct.foo1* nocapture %f, i32 %n) nounwind ssp {
+define void @bar5(ptr nocapture %f, i32 %n) nounwind ssp {
; CHECK-LABEL: @bar5(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[N:%.*]], 0
@@ -231,10 +228,10 @@ define void @bar5(%struct.foo1* nocapture %f, i32 %n) nounwind ssp {
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i32 [ 0, [[FOR_BODY_PREHEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO1:%.*]], %struct.foo1* [[F:%.*]], i32 [[INDVARS_IV]], i32 0
-; CHECK-NEXT: store i32 0, i32* [[A]], align 4
-; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO1]], %struct.foo1* [[F]], i32 [[INDVARS_IV]], i32 1
-; CHECK-NEXT: store i32 0, i32* [[B]], align 4
+; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO1:%.*]], ptr [[F:%.*]], i32 [[INDVARS_IV]], i32 0
+; CHECK-NEXT: store i32 0, ptr [[A]], align 4
+; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO1]], ptr [[F]], i32 [[INDVARS_IV]], i32 1
+; CHECK-NEXT: store i32 0, ptr [[B]], align 4
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i32 [[INDVARS_IV]], 1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i32 [[INDVARS_IV_NEXT]], [[N]]
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_BODY]], label [[FOR_END_LOOPEXIT:%.*]]
@@ -252,10 +249,10 @@ for.body.preheader: ; preds = %entry
for.body: ; preds = %for.body.preheader, %for.body
%indvars.iv = phi i32 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
- %a = getelementptr inbounds %struct.foo1, %struct.foo1* %f, i32 %indvars.iv, i32 0
- store i32 0, i32* %a, align 4
- %b = getelementptr inbounds %struct.foo1, %struct.foo1* %f, i32 %indvars.iv, i32 1
- store i32 0, i32* %b, align 4
+ %a = getelementptr inbounds %struct.foo1, ptr %f, i32 %indvars.iv, i32 0
+ store i32 0, ptr %a, align 4
+ %b = getelementptr inbounds %struct.foo1, ptr %f, i32 %indvars.iv, i32 1
+ store i32 0, ptr %b, align 4
%indvars.iv.next = add nuw nsw i32 %indvars.iv, 1
%exitcond = icmp ne i32 %indvars.iv.next, %n
br i1 %exitcond, label %for.body, label %for.end.loopexit
@@ -274,21 +271,20 @@ for.end: ; preds = %for.end.loopexit, %
; f[i].c = 0;
; }
;}
-define void @bar6(%struct.foo2* nocapture %f, i32 %n) nounwind ssp {
+define void @bar6(ptr nocapture %f, i32 %n) nounwind ssp {
; CHECK-LABEL: @bar6(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[F1:%.*]] = bitcast %struct.foo2* [[F:%.*]] to i8*
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[N:%.*]], 0
; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_END:%.*]], label [[FOR_BODY_PREHEADER:%.*]]
; CHECK: for.body.preheader:
; CHECK-NEXT: [[TMP0:%.*]] = shl nuw i32 [[N]], 3
-; CHECK-NEXT: call void @llvm.memset.p0i8.i32(i8* align 4 [[F1]], i8 0, i32 [[TMP0]], i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i32(ptr align 4 [[F:%.*]], i8 0, i32 [[TMP0]], i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i32 [ 0, [[FOR_BODY_PREHEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO2:%.*]], %struct.foo2* [[F]], i32 [[INDVARS_IV]], i32 0
-; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO2]], %struct.foo2* [[F]], i32 [[INDVARS_IV]], i32 1
-; CHECK-NEXT: [[C:%.*]] = getelementptr inbounds [[STRUCT_FOO2]], %struct.foo2* [[F]], i32 [[INDVARS_IV]], i32 2
+; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO2:%.*]], ptr [[F]], i32 [[INDVARS_IV]], i32 0
+; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO2]], ptr [[F]], i32 [[INDVARS_IV]], i32 1
+; CHECK-NEXT: [[C:%.*]] = getelementptr inbounds [[STRUCT_FOO2]], ptr [[F]], i32 [[INDVARS_IV]], i32 2
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i32 [[INDVARS_IV]], 1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i32 [[INDVARS_IV_NEXT]], [[N]]
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_BODY]], label [[FOR_END_LOOPEXIT:%.*]]
@@ -306,12 +302,12 @@ for.body.preheader: ; preds = %entry
for.body: ; preds = %for.body.preheader, %for.body
%indvars.iv = phi i32 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
- %a = getelementptr inbounds %struct.foo2, %struct.foo2* %f, i32 %indvars.iv, i32 0
- store i32 0, i32* %a, align 4
- %b = getelementptr inbounds %struct.foo2, %struct.foo2* %f, i32 %indvars.iv, i32 1
- store i16 0, i16* %b, align 4
- %c = getelementptr inbounds %struct.foo2, %struct.foo2* %f, i32 %indvars.iv, i32 2
- store i16 0, i16* %c, align 2
+ %a = getelementptr inbounds %struct.foo2, ptr %f, i32 %indvars.iv, i32 0
+ store i32 0, ptr %a, align 4
+ %b = getelementptr inbounds %struct.foo2, ptr %f, i32 %indvars.iv, i32 1
+ store i16 0, ptr %b, align 4
+ %c = getelementptr inbounds %struct.foo2, ptr %f, i32 %indvars.iv, i32 2
+ store i16 0, ptr %c, align 2
%indvars.iv.next = add nuw nsw i32 %indvars.iv, 1
%exitcond = icmp ne i32 %indvars.iv.next, %n
br i1 %exitcond, label %for.body, label %for.end.loopexit
diff --git a/llvm/test/Transforms/LoopIdiom/struct.ll b/llvm/test/Transforms/LoopIdiom/struct.ll
index a6cebb86d8578..73d569113f898 100644
--- a/llvm/test/Transforms/LoopIdiom/struct.ll
+++ b/llvm/test/Transforms/LoopIdiom/struct.ll
@@ -14,21 +14,20 @@ target triple = "x86_64-apple-darwin10.0.0"
; f[i].b = 0;
; }
;}
-define void @bar1(%struct.foo* %f, i32 %n) nounwind ssp {
+define void @bar1(ptr %f, i32 %n) nounwind ssp {
; CHECK-LABEL: @bar1(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[F1:%.*]] = bitcast %struct.foo* [[F:%.*]] to i8*
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[N:%.*]], 0
; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_END:%.*]], label [[FOR_BODY_PREHEADER:%.*]]
; CHECK: for.body.preheader:
; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[N]] to i64
; CHECK-NEXT: [[TMP1:%.*]] = shl nuw nsw i64 [[TMP0]], 3
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 4 [[F1]], i8 0, i64 [[TMP1]], i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 4 [[F:%.*]], i8 0, i64 [[TMP1]], i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[FOR_BODY_PREHEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO:%.*]], %struct.foo* [[F]], i64 [[INDVARS_IV]], i32 0
-; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO]], %struct.foo* [[F]], i64 [[INDVARS_IV]], i32 1
+; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO:%.*]], ptr [[F]], i64 [[INDVARS_IV]], i32 0
+; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO]], ptr [[F]], i64 [[INDVARS_IV]], i32 1
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
; CHECK-NEXT: [[LFTR_WIDEIV:%.*]] = trunc i64 [[INDVARS_IV_NEXT]] to i32
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i32 [[LFTR_WIDEIV]], [[N]]
@@ -47,10 +46,10 @@ for.body.preheader: ; preds = %entry
for.body: ; preds = %for.body.preheader, %for.body
%indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
- %a = getelementptr inbounds %struct.foo, %struct.foo* %f, i64 %indvars.iv, i32 0
- store i32 0, i32* %a, align 4
- %b = getelementptr inbounds %struct.foo, %struct.foo* %f, i64 %indvars.iv, i32 1
- store i32 0, i32* %b, align 4
+ %a = getelementptr inbounds %struct.foo, ptr %f, i64 %indvars.iv, i32 0
+ store i32 0, ptr %a, align 4
+ %b = getelementptr inbounds %struct.foo, ptr %f, i64 %indvars.iv, i32 1
+ store i32 0, ptr %b, align 4
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%lftr.wideiv = trunc i64 %indvars.iv.next to i32
%exitcond = icmp ne i32 %lftr.wideiv, %n
@@ -69,21 +68,20 @@ for.end: ; preds = %for.end.loopexit, %
; f[i].a = 0;
; }
;}
-define void @bar2(%struct.foo* %f, i32 %n) nounwind ssp {
+define void @bar2(ptr %f, i32 %n) nounwind ssp {
; CHECK-LABEL: @bar2(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[F1:%.*]] = bitcast %struct.foo* [[F:%.*]] to i8*
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[N:%.*]], 0
; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_END:%.*]], label [[FOR_BODY_PREHEADER:%.*]]
; CHECK: for.body.preheader:
; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[N]] to i64
; CHECK-NEXT: [[TMP1:%.*]] = shl nuw nsw i64 [[TMP0]], 3
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 4 [[F1]], i8 0, i64 [[TMP1]], i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 4 [[F:%.*]], i8 0, i64 [[TMP1]], i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[FOR_BODY_PREHEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO:%.*]], %struct.foo* [[F]], i64 [[INDVARS_IV]], i32 1
-; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO]], %struct.foo* [[F]], i64 [[INDVARS_IV]], i32 0
+; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO:%.*]], ptr [[F]], i64 [[INDVARS_IV]], i32 1
+; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO]], ptr [[F]], i64 [[INDVARS_IV]], i32 0
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
; CHECK-NEXT: [[LFTR_WIDEIV:%.*]] = trunc i64 [[INDVARS_IV_NEXT]] to i32
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i32 [[LFTR_WIDEIV]], [[N]]
@@ -102,10 +100,10 @@ for.body.preheader: ; preds = %entry
for.body: ; preds = %for.body.preheader, %for.body
%indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
- %b = getelementptr inbounds %struct.foo, %struct.foo* %f, i64 %indvars.iv, i32 1
- store i32 0, i32* %b, align 4
- %a = getelementptr inbounds %struct.foo, %struct.foo* %f, i64 %indvars.iv, i32 0
- store i32 0, i32* %a, align 4
+ %b = getelementptr inbounds %struct.foo, ptr %f, i64 %indvars.iv, i32 1
+ store i32 0, ptr %b, align 4
+ %a = getelementptr inbounds %struct.foo, ptr %f, i64 %indvars.iv, i32 0
+ store i32 0, ptr %a, align 4
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%lftr.wideiv = trunc i64 %indvars.iv.next to i32
%exitcond = icmp ne i32 %lftr.wideiv, %n
@@ -124,27 +122,27 @@ for.end: ; preds = %for.end.loopexit, %
; f[i].b = 0;
; }
;}
-define void @bar3(%struct.foo* nocapture %f, i32 %n) nounwind ssp {
+define void @bar3(ptr nocapture %f, i32 %n) nounwind ssp {
; CHECK-LABEL: @bar3(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[N:%.*]], 0
; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_END:%.*]], label [[FOR_BODY_PREHEADER:%.*]]
; CHECK: for.body.preheader:
; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[N]] to i64
-; CHECK-NEXT: [[TMP1:%.*]] = add i32 [[N]], -1
-; CHECK-NEXT: [[TMP2:%.*]] = zext i32 [[TMP1]] to i64
-; CHECK-NEXT: [[TMP3:%.*]] = sub i64 [[TMP0]], [[TMP2]]
-; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr [[STRUCT_FOO:%.*]], %struct.foo* [[F:%.*]], i64 [[TMP3]]
-; CHECK-NEXT: [[SCEVGEP1:%.*]] = bitcast %struct.foo* [[SCEVGEP]] to i8*
-; CHECK-NEXT: [[TMP4:%.*]] = shl nuw nsw i64 [[TMP0]], 3
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 4 [[SCEVGEP1]], i8 0, i64 [[TMP4]], i1 false)
+; CHECK-NEXT: [[TMP1:%.*]] = shl nuw nsw i64 [[TMP0]], 3
+; CHECK-NEXT: [[TMP2:%.*]] = add i32 [[N]], -1
+; CHECK-NEXT: [[TMP3:%.*]] = zext i32 [[TMP2]] to i64
+; CHECK-NEXT: [[TMP4:%.*]] = shl nuw nsw i64 [[TMP3]], 3
+; CHECK-NEXT: [[TMP5:%.*]] = sub i64 [[TMP1]], [[TMP4]]
+; CHECK-NEXT: [[UGLYGEP:%.*]] = getelementptr i8, ptr [[F:%.*]], i64 [[TMP5]]
+; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 4 [[UGLYGEP]], i8 0, i64 [[TMP1]], i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[TMP0]], [[FOR_BODY_PREHEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO]], %struct.foo* [[F]], i64 [[INDVARS_IV]], i32 0
-; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO]], %struct.foo* [[F]], i64 [[INDVARS_IV]], i32 1
-; CHECK-NEXT: [[TMP5:%.*]] = trunc i64 [[INDVARS_IV]] to i32
-; CHECK-NEXT: [[DEC:%.*]] = add i32 [[TMP5]], -1
+; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO:%.*]], ptr [[F]], i64 [[INDVARS_IV]], i32 0
+; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO]], ptr [[F]], i64 [[INDVARS_IV]], i32 1
+; CHECK-NEXT: [[TMP6:%.*]] = trunc i64 [[INDVARS_IV]] to i32
+; CHECK-NEXT: [[DEC:%.*]] = add i32 [[TMP6]], -1
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[DEC]], 0
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], -1
; CHECK-NEXT: br i1 [[CMP]], label [[FOR_END_LOOPEXIT:%.*]], label [[FOR_BODY]]
@@ -163,10 +161,10 @@ for.body.preheader: ; preds = %entry
for.body: ; preds = %for.body.preheader, %for.body
%indvars.iv = phi i64 [ %0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
- %a = getelementptr inbounds %struct.foo, %struct.foo* %f, i64 %indvars.iv, i32 0
- store i32 0, i32* %a, align 4
- %b = getelementptr inbounds %struct.foo, %struct.foo* %f, i64 %indvars.iv, i32 1
- store i32 0, i32* %b, align 4
+ %a = getelementptr inbounds %struct.foo, ptr %f, i64 %indvars.iv, i32 0
+ store i32 0, ptr %a, align 4
+ %b = getelementptr inbounds %struct.foo, ptr %f, i64 %indvars.iv, i32 1
+ store i32 0, ptr %b, align 4
%1 = trunc i64 %indvars.iv to i32
%dec = add i32 %1, -1
%cmp = icmp eq i32 %dec, 0
@@ -186,7 +184,7 @@ for.end: ; preds = %for.end.loopexit, %
; f[i].b = 1;
; }
;}
-define void @bar4(%struct.foo* nocapture %f, i32 %n) nounwind ssp {
+define void @bar4(ptr nocapture %f, i32 %n) nounwind ssp {
; CHECK-LABEL: @bar4(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[N:%.*]], 0
@@ -195,10 +193,10 @@ define void @bar4(%struct.foo* nocapture %f, i32 %n) nounwind ssp {
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[FOR_BODY_PREHEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO:%.*]], %struct.foo* [[F:%.*]], i64 [[INDVARS_IV]], i32 0
-; CHECK-NEXT: store i32 0, i32* [[A]], align 4
-; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO]], %struct.foo* [[F]], i64 [[INDVARS_IV]], i32 1
-; CHECK-NEXT: store i32 1, i32* [[B]], align 4
+; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO:%.*]], ptr [[F:%.*]], i64 [[INDVARS_IV]], i32 0
+; CHECK-NEXT: store i32 0, ptr [[A]], align 4
+; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO]], ptr [[F]], i64 [[INDVARS_IV]], i32 1
+; CHECK-NEXT: store i32 1, ptr [[B]], align 4
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
; CHECK-NEXT: [[LFTR_WIDEIV:%.*]] = trunc i64 [[INDVARS_IV_NEXT]] to i32
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i32 [[LFTR_WIDEIV]], [[N]]
@@ -217,10 +215,10 @@ for.body.preheader: ; preds = %entry
for.body: ; preds = %for.body.preheader, %for.body
%indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
- %a = getelementptr inbounds %struct.foo, %struct.foo* %f, i64 %indvars.iv, i32 0
- store i32 0, i32* %a, align 4
- %b = getelementptr inbounds %struct.foo, %struct.foo* %f, i64 %indvars.iv, i32 1
- store i32 1, i32* %b, align 4
+ %a = getelementptr inbounds %struct.foo, ptr %f, i64 %indvars.iv, i32 0
+ store i32 0, ptr %a, align 4
+ %b = getelementptr inbounds %struct.foo, ptr %f, i64 %indvars.iv, i32 1
+ store i32 1, ptr %b, align 4
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%lftr.wideiv = trunc i64 %indvars.iv.next to i32
%exitcond = icmp ne i32 %lftr.wideiv, %n
@@ -239,7 +237,7 @@ for.end: ; preds = %for.end.loopexit, %
; f[i].b = 0;
; }
;}
-define void @bar5(%struct.foo1* nocapture %f, i32 %n) nounwind ssp {
+define void @bar5(ptr nocapture %f, i32 %n) nounwind ssp {
; CHECK-LABEL: @bar5(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[N:%.*]], 0
@@ -248,10 +246,10 @@ define void @bar5(%struct.foo1* nocapture %f, i32 %n) nounwind ssp {
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[FOR_BODY_PREHEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO1:%.*]], %struct.foo1* [[F:%.*]], i64 [[INDVARS_IV]], i32 0
-; CHECK-NEXT: store i32 0, i32* [[A]], align 4
-; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO1]], %struct.foo1* [[F]], i64 [[INDVARS_IV]], i32 1
-; CHECK-NEXT: store i32 0, i32* [[B]], align 4
+; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO1:%.*]], ptr [[F:%.*]], i64 [[INDVARS_IV]], i32 0
+; CHECK-NEXT: store i32 0, ptr [[A]], align 4
+; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO1]], ptr [[F]], i64 [[INDVARS_IV]], i32 1
+; CHECK-NEXT: store i32 0, ptr [[B]], align 4
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
; CHECK-NEXT: [[LFTR_WIDEIV:%.*]] = trunc i64 [[INDVARS_IV_NEXT]] to i32
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i32 [[LFTR_WIDEIV]], [[N]]
@@ -270,10 +268,10 @@ for.body.preheader: ; preds = %entry
for.body: ; preds = %for.body.preheader, %for.body
%indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
- %a = getelementptr inbounds %struct.foo1, %struct.foo1* %f, i64 %indvars.iv, i32 0
- store i32 0, i32* %a, align 4
- %b = getelementptr inbounds %struct.foo1, %struct.foo1* %f, i64 %indvars.iv, i32 1
- store i32 0, i32* %b, align 4
+ %a = getelementptr inbounds %struct.foo1, ptr %f, i64 %indvars.iv, i32 0
+ store i32 0, ptr %a, align 4
+ %b = getelementptr inbounds %struct.foo1, ptr %f, i64 %indvars.iv, i32 1
+ store i32 0, ptr %b, align 4
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%lftr.wideiv = trunc i64 %indvars.iv.next to i32
%exitcond = icmp ne i32 %lftr.wideiv, %n
@@ -293,22 +291,21 @@ for.end: ; preds = %for.end.loopexit, %
; f[i].c = 0;
; }
;}
-define void @bar6(%struct.foo2* nocapture %f, i32 %n) nounwind ssp {
+define void @bar6(ptr nocapture %f, i32 %n) nounwind ssp {
; CHECK-LABEL: @bar6(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[F1:%.*]] = bitcast %struct.foo2* [[F:%.*]] to i8*
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[N:%.*]], 0
; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_END:%.*]], label [[FOR_BODY_PREHEADER:%.*]]
; CHECK: for.body.preheader:
; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[N]] to i64
; CHECK-NEXT: [[TMP1:%.*]] = shl nuw nsw i64 [[TMP0]], 3
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 4 [[F1]], i8 0, i64 [[TMP1]], i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 4 [[F:%.*]], i8 0, i64 [[TMP1]], i1 false)
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[FOR_BODY_PREHEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO2:%.*]], %struct.foo2* [[F]], i64 [[INDVARS_IV]], i32 0
-; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO2]], %struct.foo2* [[F]], i64 [[INDVARS_IV]], i32 1
-; CHECK-NEXT: [[C:%.*]] = getelementptr inbounds [[STRUCT_FOO2]], %struct.foo2* [[F]], i64 [[INDVARS_IV]], i32 2
+; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO2:%.*]], ptr [[F]], i64 [[INDVARS_IV]], i32 0
+; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO2]], ptr [[F]], i64 [[INDVARS_IV]], i32 1
+; CHECK-NEXT: [[C:%.*]] = getelementptr inbounds [[STRUCT_FOO2]], ptr [[F]], i64 [[INDVARS_IV]], i32 2
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
; CHECK-NEXT: [[LFTR_WIDEIV:%.*]] = trunc i64 [[INDVARS_IV_NEXT]] to i32
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i32 [[LFTR_WIDEIV]], [[N]]
@@ -327,12 +324,12 @@ for.body.preheader: ; preds = %entry
for.body: ; preds = %for.body.preheader, %for.body
%indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
- %a = getelementptr inbounds %struct.foo2, %struct.foo2* %f, i64 %indvars.iv, i32 0
- store i32 0, i32* %a, align 4
- %b = getelementptr inbounds %struct.foo2, %struct.foo2* %f, i64 %indvars.iv, i32 1
- store i16 0, i16* %b, align 4
- %c = getelementptr inbounds %struct.foo2, %struct.foo2* %f, i64 %indvars.iv, i32 2
- store i16 0, i16* %c, align 2
+ %a = getelementptr inbounds %struct.foo2, ptr %f, i64 %indvars.iv, i32 0
+ store i32 0, ptr %a, align 4
+ %b = getelementptr inbounds %struct.foo2, ptr %f, i64 %indvars.iv, i32 1
+ store i16 0, ptr %b, align 4
+ %c = getelementptr inbounds %struct.foo2, ptr %f, i64 %indvars.iv, i32 2
+ store i16 0, ptr %c, align 2
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%lftr.wideiv = trunc i64 %indvars.iv.next to i32
%exitcond = icmp ne i32 %lftr.wideiv, %n
diff --git a/llvm/test/Transforms/LoopIdiom/struct_pattern.ll b/llvm/test/Transforms/LoopIdiom/struct_pattern.ll
index 4ad78350ea756..5335b12e63982 100644
--- a/llvm/test/Transforms/LoopIdiom/struct_pattern.ll
+++ b/llvm/test/Transforms/LoopIdiom/struct_pattern.ll
@@ -17,21 +17,20 @@ target triple = "x86_64-apple-darwin10.0.0"
; f[i].b = 2;
; }
;}
-define void @bar1(%struct.foo* %f, i32 %n) nounwind ssp {
+define void @bar1(ptr %f, i32 %n) nounwind ssp {
; CHECK-LABEL: @bar1(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[F1:%.*]] = bitcast %struct.foo* [[F:%.*]] to i8*
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[N:%.*]], 0
; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_END:%.*]], label [[FOR_BODY_PREHEADER:%.*]]
; CHECK: for.body.preheader:
; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[N]] to i64
; CHECK-NEXT: [[TMP1:%.*]] = shl nuw nsw i64 [[TMP0]], 3
-; CHECK-NEXT: call void @memset_pattern16(i8* [[F1]], i8* bitcast ([4 x i32]* @.memset_pattern to i8*), i64 [[TMP1]])
+; CHECK-NEXT: call void @memset_pattern16(ptr [[F:%.*]], ptr @.memset_pattern, i64 [[TMP1]])
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[FOR_BODY_PREHEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO:%.*]], %struct.foo* [[F]], i64 [[INDVARS_IV]], i32 0
-; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO]], %struct.foo* [[F]], i64 [[INDVARS_IV]], i32 1
+; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO:%.*]], ptr [[F]], i64 [[INDVARS_IV]], i32 0
+; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO]], ptr [[F]], i64 [[INDVARS_IV]], i32 1
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
; CHECK-NEXT: [[LFTR_WIDEIV:%.*]] = trunc i64 [[INDVARS_IV_NEXT]] to i32
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i32 [[LFTR_WIDEIV]], [[N]]
@@ -50,10 +49,10 @@ for.body.preheader: ; preds = %entry
for.body: ; preds = %for.body.preheader, %for.body
%indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
- %a = getelementptr inbounds %struct.foo, %struct.foo* %f, i64 %indvars.iv, i32 0
- store i32 2, i32* %a, align 4
- %b = getelementptr inbounds %struct.foo, %struct.foo* %f, i64 %indvars.iv, i32 1
- store i32 2, i32* %b, align 4
+ %a = getelementptr inbounds %struct.foo, ptr %f, i64 %indvars.iv, i32 0
+ store i32 2, ptr %a, align 4
+ %b = getelementptr inbounds %struct.foo, ptr %f, i64 %indvars.iv, i32 1
+ store i32 2, ptr %b, align 4
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%lftr.wideiv = trunc i64 %indvars.iv.next to i32
%exitcond = icmp ne i32 %lftr.wideiv, %n
@@ -72,21 +71,20 @@ for.end: ; preds = %for.end.loopexit, %
; f[i].a = 2;
; }
;}
-define void @bar2(%struct.foo* %f, i32 %n) nounwind ssp {
+define void @bar2(ptr %f, i32 %n) nounwind ssp {
; CHECK-LABEL: @bar2(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[F1:%.*]] = bitcast %struct.foo* [[F:%.*]] to i8*
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[N:%.*]], 0
; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_END:%.*]], label [[FOR_BODY_PREHEADER:%.*]]
; CHECK: for.body.preheader:
; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[N]] to i64
; CHECK-NEXT: [[TMP1:%.*]] = shl nuw nsw i64 [[TMP0]], 3
-; CHECK-NEXT: call void @memset_pattern16(i8* [[F1]], i8* bitcast ([4 x i32]* @.memset_pattern.1 to i8*), i64 [[TMP1]])
+; CHECK-NEXT: call void @memset_pattern16(ptr [[F:%.*]], ptr @.memset_pattern.1, i64 [[TMP1]])
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[FOR_BODY_PREHEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO:%.*]], %struct.foo* [[F]], i64 [[INDVARS_IV]], i32 1
-; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO]], %struct.foo* [[F]], i64 [[INDVARS_IV]], i32 0
+; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO:%.*]], ptr [[F]], i64 [[INDVARS_IV]], i32 1
+; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO]], ptr [[F]], i64 [[INDVARS_IV]], i32 0
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
; CHECK-NEXT: [[LFTR_WIDEIV:%.*]] = trunc i64 [[INDVARS_IV_NEXT]] to i32
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i32 [[LFTR_WIDEIV]], [[N]]
@@ -105,10 +103,10 @@ for.body.preheader: ; preds = %entry
for.body: ; preds = %for.body.preheader, %for.body
%indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
- %b = getelementptr inbounds %struct.foo, %struct.foo* %f, i64 %indvars.iv, i32 1
- store i32 2, i32* %b, align 4
- %a = getelementptr inbounds %struct.foo, %struct.foo* %f, i64 %indvars.iv, i32 0
- store i32 2, i32* %a, align 4
+ %b = getelementptr inbounds %struct.foo, ptr %f, i64 %indvars.iv, i32 1
+ store i32 2, ptr %b, align 4
+ %a = getelementptr inbounds %struct.foo, ptr %f, i64 %indvars.iv, i32 0
+ store i32 2, ptr %a, align 4
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%lftr.wideiv = trunc i64 %indvars.iv.next to i32
%exitcond = icmp ne i32 %lftr.wideiv, %n
@@ -127,27 +125,27 @@ for.end: ; preds = %for.end.loopexit, %
; f[i].b = 2;
; }
;}
-define void @bar3(%struct.foo* nocapture %f, i32 %n) nounwind ssp {
+define void @bar3(ptr nocapture %f, i32 %n) nounwind ssp {
; CHECK-LABEL: @bar3(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[N:%.*]], 0
; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_END:%.*]], label [[FOR_BODY_PREHEADER:%.*]]
; CHECK: for.body.preheader:
; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[N]] to i64
-; CHECK-NEXT: [[TMP1:%.*]] = add i32 [[N]], -1
-; CHECK-NEXT: [[TMP2:%.*]] = zext i32 [[TMP1]] to i64
-; CHECK-NEXT: [[TMP3:%.*]] = sub i64 [[TMP0]], [[TMP2]]
-; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr [[STRUCT_FOO:%.*]], %struct.foo* [[F:%.*]], i64 [[TMP3]]
-; CHECK-NEXT: [[SCEVGEP1:%.*]] = bitcast %struct.foo* [[SCEVGEP]] to i8*
-; CHECK-NEXT: [[TMP4:%.*]] = shl nuw nsw i64 [[TMP0]], 3
-; CHECK-NEXT: call void @memset_pattern16(i8* [[SCEVGEP1]], i8* bitcast ([4 x i32]* @.memset_pattern.2 to i8*), i64 [[TMP4]])
+; CHECK-NEXT: [[TMP1:%.*]] = shl nuw nsw i64 [[TMP0]], 3
+; CHECK-NEXT: [[TMP2:%.*]] = add i32 [[N]], -1
+; CHECK-NEXT: [[TMP3:%.*]] = zext i32 [[TMP2]] to i64
+; CHECK-NEXT: [[TMP4:%.*]] = shl nuw nsw i64 [[TMP3]], 3
+; CHECK-NEXT: [[TMP5:%.*]] = sub i64 [[TMP1]], [[TMP4]]
+; CHECK-NEXT: [[UGLYGEP:%.*]] = getelementptr i8, ptr [[F:%.*]], i64 [[TMP5]]
+; CHECK-NEXT: call void @memset_pattern16(ptr [[UGLYGEP]], ptr @.memset_pattern.2, i64 [[TMP1]])
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[TMP0]], [[FOR_BODY_PREHEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO]], %struct.foo* [[F]], i64 [[INDVARS_IV]], i32 0
-; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO]], %struct.foo* [[F]], i64 [[INDVARS_IV]], i32 1
-; CHECK-NEXT: [[TMP5:%.*]] = trunc i64 [[INDVARS_IV]] to i32
-; CHECK-NEXT: [[DEC:%.*]] = add i32 [[TMP5]], -1
+; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO:%.*]], ptr [[F]], i64 [[INDVARS_IV]], i32 0
+; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO]], ptr [[F]], i64 [[INDVARS_IV]], i32 1
+; CHECK-NEXT: [[TMP6:%.*]] = trunc i64 [[INDVARS_IV]] to i32
+; CHECK-NEXT: [[DEC:%.*]] = add i32 [[TMP6]], -1
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[DEC]], 0
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], -1
; CHECK-NEXT: br i1 [[CMP]], label [[FOR_END_LOOPEXIT:%.*]], label [[FOR_BODY]]
@@ -166,10 +164,10 @@ for.body.preheader: ; preds = %entry
for.body: ; preds = %for.body.preheader, %for.body
%indvars.iv = phi i64 [ %0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
- %a = getelementptr inbounds %struct.foo, %struct.foo* %f, i64 %indvars.iv, i32 0
- store i32 2, i32* %a, align 4
- %b = getelementptr inbounds %struct.foo, %struct.foo* %f, i64 %indvars.iv, i32 1
- store i32 2, i32* %b, align 4
+ %a = getelementptr inbounds %struct.foo, ptr %f, i64 %indvars.iv, i32 0
+ store i32 2, ptr %a, align 4
+ %b = getelementptr inbounds %struct.foo, ptr %f, i64 %indvars.iv, i32 1
+ store i32 2, ptr %b, align 4
%1 = trunc i64 %indvars.iv to i32
%dec = add i32 %1, -1
%cmp = icmp eq i32 %dec, 0
@@ -189,7 +187,7 @@ for.end: ; preds = %for.end.loopexit, %
; f[i].b = 1;
; }
;}
-define void @bar4(%struct.foo* nocapture %f, i32 %n) nounwind ssp {
+define void @bar4(ptr nocapture %f, i32 %n) nounwind ssp {
; CHECK-LABEL: @bar4(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[N:%.*]], 0
@@ -198,10 +196,10 @@ define void @bar4(%struct.foo* nocapture %f, i32 %n) nounwind ssp {
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[FOR_BODY_PREHEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO:%.*]], %struct.foo* [[F:%.*]], i64 [[INDVARS_IV]], i32 0
-; CHECK-NEXT: store i32 0, i32* [[A]], align 4
-; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO]], %struct.foo* [[F]], i64 [[INDVARS_IV]], i32 1
-; CHECK-NEXT: store i32 1, i32* [[B]], align 4
+; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO:%.*]], ptr [[F:%.*]], i64 [[INDVARS_IV]], i32 0
+; CHECK-NEXT: store i32 0, ptr [[A]], align 4
+; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO]], ptr [[F]], i64 [[INDVARS_IV]], i32 1
+; CHECK-NEXT: store i32 1, ptr [[B]], align 4
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
; CHECK-NEXT: [[LFTR_WIDEIV:%.*]] = trunc i64 [[INDVARS_IV_NEXT]] to i32
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i32 [[LFTR_WIDEIV]], [[N]]
@@ -220,10 +218,10 @@ for.body.preheader: ; preds = %entry
for.body: ; preds = %for.body.preheader, %for.body
%indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
- %a = getelementptr inbounds %struct.foo, %struct.foo* %f, i64 %indvars.iv, i32 0
- store i32 0, i32* %a, align 4
- %b = getelementptr inbounds %struct.foo, %struct.foo* %f, i64 %indvars.iv, i32 1
- store i32 1, i32* %b, align 4
+ %a = getelementptr inbounds %struct.foo, ptr %f, i64 %indvars.iv, i32 0
+ store i32 0, ptr %a, align 4
+ %b = getelementptr inbounds %struct.foo, ptr %f, i64 %indvars.iv, i32 1
+ store i32 1, ptr %b, align 4
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%lftr.wideiv = trunc i64 %indvars.iv.next to i32
%exitcond = icmp ne i32 %lftr.wideiv, %n
@@ -242,7 +240,7 @@ for.end: ; preds = %for.end.loopexit, %
; f[i].b = 1;
; }
;}
-define void @bar5(%struct.foo1* nocapture %f, i32 %n) nounwind ssp {
+define void @bar5(ptr nocapture %f, i32 %n) nounwind ssp {
; CHECK-LABEL: @bar5(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[N:%.*]], 0
@@ -251,10 +249,10 @@ define void @bar5(%struct.foo1* nocapture %f, i32 %n) nounwind ssp {
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[FOR_BODY_PREHEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO1:%.*]], %struct.foo1* [[F:%.*]], i64 [[INDVARS_IV]], i32 0
-; CHECK-NEXT: store i32 1, i32* [[A]], align 4
-; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO1]], %struct.foo1* [[F]], i64 [[INDVARS_IV]], i32 1
-; CHECK-NEXT: store i32 1, i32* [[B]], align 4
+; CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[STRUCT_FOO1:%.*]], ptr [[F:%.*]], i64 [[INDVARS_IV]], i32 0
+; CHECK-NEXT: store i32 1, ptr [[A]], align 4
+; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_FOO1]], ptr [[F]], i64 [[INDVARS_IV]], i32 1
+; CHECK-NEXT: store i32 1, ptr [[B]], align 4
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
; CHECK-NEXT: [[LFTR_WIDEIV:%.*]] = trunc i64 [[INDVARS_IV_NEXT]] to i32
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i32 [[LFTR_WIDEIV]], [[N]]
@@ -273,10 +271,10 @@ for.body.preheader: ; preds = %entry
for.body: ; preds = %for.body.preheader, %for.body
%indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
- %a = getelementptr inbounds %struct.foo1, %struct.foo1* %f, i64 %indvars.iv, i32 0
- store i32 1, i32* %a, align 4
- %b = getelementptr inbounds %struct.foo1, %struct.foo1* %f, i64 %indvars.iv, i32 1
- store i32 1, i32* %b, align 4
+ %a = getelementptr inbounds %struct.foo1, ptr %f, i64 %indvars.iv, i32 0
+ store i32 1, ptr %a, align 4
+ %b = getelementptr inbounds %struct.foo1, ptr %f, i64 %indvars.iv, i32 1
+ store i32 1, ptr %b, align 4
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%lftr.wideiv = trunc i64 %indvars.iv.next to i32
%exitcond = icmp ne i32 %lftr.wideiv, %n
More information about the llvm-commits
mailing list