2019-04-17 12:52:47 +08:00
|
|
|
; RUN: opt -basicaa -loop-unroll-and-jam -allow-unroll-and-jam -unroll-and-jam-count=4 < %s -S | FileCheck %s
|
2020-01-10 00:15:53 +08:00
|
|
|
; RUN: opt -aa-pipeline=basic-aa -passes='unroll-and-jam' -allow-unroll-and-jam -unroll-and-jam-count=4 < %s -S | FileCheck %s
|
2019-04-17 12:52:47 +08:00
|
|
|
|
|
|
|
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
|
|
|
|
|
|
|
|
; CHECK-LABEL: fore_aft_less
|
|
|
|
; CHECK: %j = phi
|
|
|
|
; CHECK: %j.1 = phi
|
|
|
|
; CHECK: %j.2 = phi
|
|
|
|
; CHECK: %j.3 = phi
|
|
|
|
define void @fore_aft_less(i32* noalias nocapture %A, i32 %N, i32* noalias nocapture readonly %B) {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp sgt i32 %N, 0
|
|
|
|
br i1 %cmp, label %for.outer, label %cleanup
|
|
|
|
|
|
|
|
for.outer:
|
|
|
|
%i = phi i32 [ %add7, %for.latch ], [ 0, %entry ]
|
|
|
|
%arrayidx = getelementptr inbounds i32, i32* %A, i32 %i
|
|
|
|
store i32 1, i32* %arrayidx, align 4
|
|
|
|
br label %for.inner
|
|
|
|
|
|
|
|
for.inner:
|
|
|
|
%j = phi i32 [ %add6, %for.inner ], [ 0, %for.outer ]
|
|
|
|
%sum = phi i32 [ %add, %for.inner ], [ 0, %for.outer ]
|
|
|
|
%arrayidx5 = getelementptr inbounds i32, i32* %B, i32 %j
|
|
|
|
%0 = load i32, i32* %arrayidx5, align 4
|
|
|
|
%mul = mul nsw i32 %0, %i
|
|
|
|
%add = add nsw i32 %mul, %sum
|
|
|
|
%add6 = add nuw nsw i32 %j, 1
|
|
|
|
%exitcond = icmp eq i32 %add6, %N
|
|
|
|
br i1 %exitcond, label %for.latch, label %for.inner
|
|
|
|
|
|
|
|
for.latch:
|
|
|
|
%add7 = add nuw nsw i32 %i, 1
|
|
|
|
%add72 = add nuw nsw i32 %i, -1
|
|
|
|
%arrayidx8 = getelementptr inbounds i32, i32* %A, i32 %add72
|
|
|
|
store i32 %add, i32* %arrayidx8, align 4
|
|
|
|
%exitcond29 = icmp eq i32 %add7, %N
|
|
|
|
br i1 %exitcond29, label %cleanup, label %for.outer
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
; CHECK-LABEL: fore_aft_eq
|
|
|
|
; CHECK: %j = phi
|
|
|
|
; CHECK: %j.1 = phi
|
|
|
|
; CHECK: %j.2 = phi
|
|
|
|
; CHECK: %j.3 = phi
|
|
|
|
define void @fore_aft_eq(i32* noalias nocapture %A, i32 %N, i32* noalias nocapture readonly %B) {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp sgt i32 %N, 0
|
|
|
|
br i1 %cmp, label %for.outer, label %cleanup
|
|
|
|
|
|
|
|
for.outer:
|
|
|
|
%i = phi i32 [ %add7, %for.latch ], [ 0, %entry ]
|
|
|
|
%arrayidx = getelementptr inbounds i32, i32* %A, i32 %i
|
|
|
|
store i32 1, i32* %arrayidx, align 4
|
|
|
|
br label %for.inner
|
|
|
|
|
|
|
|
for.inner:
|
|
|
|
%j = phi i32 [ %add6, %for.inner ], [ 0, %for.outer ]
|
|
|
|
%sum = phi i32 [ %add, %for.inner ], [ 0, %for.outer ]
|
|
|
|
%arrayidx5 = getelementptr inbounds i32, i32* %B, i32 %j
|
|
|
|
%0 = load i32, i32* %arrayidx5, align 4
|
|
|
|
%mul = mul nsw i32 %0, %i
|
|
|
|
%add = add nsw i32 %mul, %sum
|
|
|
|
%add6 = add nuw nsw i32 %j, 1
|
|
|
|
%exitcond = icmp eq i32 %add6, %N
|
|
|
|
br i1 %exitcond, label %for.latch, label %for.inner
|
|
|
|
|
|
|
|
for.latch:
|
|
|
|
%add7 = add nuw nsw i32 %i, 1
|
|
|
|
%add72 = add nuw nsw i32 %i, 0
|
|
|
|
%arrayidx8 = getelementptr inbounds i32, i32* %A, i32 %i
|
|
|
|
store i32 %add, i32* %arrayidx8, align 4
|
|
|
|
%exitcond29 = icmp eq i32 %add7, %N
|
|
|
|
br i1 %exitcond29, label %cleanup, label %for.outer
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
; CHECK-LABEL: fore_aft_more
|
|
|
|
; CHECK: %j = phi
|
|
|
|
; CHECK-NOT: %j.1 = phi
|
|
|
|
define void @fore_aft_more(i32* noalias nocapture %A, i32 %N, i32* noalias nocapture readonly %B) {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp sgt i32 %N, 0
|
|
|
|
br i1 %cmp, label %for.outer, label %cleanup
|
|
|
|
|
|
|
|
for.outer:
|
|
|
|
%i = phi i32 [ %add7, %for.latch ], [ 0, %entry ]
|
|
|
|
%arrayidx = getelementptr inbounds i32, i32* %A, i32 %i
|
|
|
|
store i32 1, i32* %arrayidx, align 4
|
|
|
|
br label %for.inner
|
|
|
|
|
|
|
|
for.inner:
|
|
|
|
%j = phi i32 [ %add6, %for.inner ], [ 0, %for.outer ]
|
|
|
|
%sum = phi i32 [ %add, %for.inner ], [ 0, %for.outer ]
|
|
|
|
%arrayidx5 = getelementptr inbounds i32, i32* %B, i32 %j
|
|
|
|
%0 = load i32, i32* %arrayidx5, align 4
|
|
|
|
%mul = mul nsw i32 %0, %i
|
|
|
|
%add = add nsw i32 %mul, %sum
|
|
|
|
%add6 = add nuw nsw i32 %j, 1
|
|
|
|
%exitcond = icmp eq i32 %add6, %N
|
|
|
|
br i1 %exitcond, label %for.latch, label %for.inner
|
|
|
|
|
|
|
|
for.latch:
|
|
|
|
%add7 = add nuw nsw i32 %i, 1
|
|
|
|
%add72 = add nuw nsw i32 %i, 1
|
|
|
|
%arrayidx8 = getelementptr inbounds i32, i32* %A, i32 %add72
|
|
|
|
store i32 %add, i32* %arrayidx8, align 4
|
|
|
|
%exitcond29 = icmp eq i32 %add7, %N
|
|
|
|
br i1 %exitcond29, label %cleanup, label %for.outer
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
; CHECK-LABEL: fore_sub_less
|
|
|
|
; CHECK: %j = phi
|
|
|
|
; CHECK: %j.1 = phi
|
|
|
|
; CHECK: %j.2 = phi
|
|
|
|
; CHECK: %j.3 = phi
|
|
|
|
define void @fore_sub_less(i32* noalias nocapture %A, i32 %N, i32* noalias nocapture readonly %B) {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp sgt i32 %N, 0
|
|
|
|
br i1 %cmp, label %for.outer, label %cleanup
|
|
|
|
|
|
|
|
for.outer:
|
|
|
|
%i = phi i32 [ %add7, %for.latch ], [ 0, %entry ]
|
|
|
|
%arrayidx = getelementptr inbounds i32, i32* %A, i32 %i
|
|
|
|
store i32 1, i32* %arrayidx, align 4
|
|
|
|
br label %for.inner
|
|
|
|
|
|
|
|
for.inner:
|
|
|
|
%j = phi i32 [ %add6, %for.inner ], [ 0, %for.outer ]
|
|
|
|
%sum = phi i32 [ %add, %for.inner ], [ 0, %for.outer ]
|
|
|
|
%arrayidx5 = getelementptr inbounds i32, i32* %B, i32 %j
|
|
|
|
%0 = load i32, i32* %arrayidx5, align 4
|
|
|
|
%mul = mul nsw i32 %0, %i
|
|
|
|
%add = add nsw i32 %mul, %sum
|
|
|
|
%add72 = add nuw nsw i32 %i, -1
|
|
|
|
%arrayidx8 = getelementptr inbounds i32, i32* %A, i32 %add72
|
|
|
|
store i32 %add, i32* %arrayidx8, align 4
|
|
|
|
%add6 = add nuw nsw i32 %j, 1
|
|
|
|
%exitcond = icmp eq i32 %add6, %N
|
|
|
|
br i1 %exitcond, label %for.latch, label %for.inner
|
|
|
|
|
|
|
|
for.latch:
|
|
|
|
%add7 = add nuw nsw i32 %i, 1
|
|
|
|
%exitcond29 = icmp eq i32 %add7, %N
|
|
|
|
br i1 %exitcond29, label %cleanup, label %for.outer
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
; CHECK-LABEL: fore_sub_eq
|
|
|
|
; CHECK: %j = phi
|
|
|
|
; CHECK: %j.1 = phi
|
|
|
|
; CHECK: %j.2 = phi
|
|
|
|
; CHECK: %j.3 = phi
|
|
|
|
define void @fore_sub_eq(i32* noalias nocapture %A, i32 %N, i32* noalias nocapture readonly %B) {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp sgt i32 %N, 0
|
|
|
|
br i1 %cmp, label %for.outer, label %cleanup
|
|
|
|
|
|
|
|
for.outer:
|
|
|
|
%i = phi i32 [ %add7, %for.latch ], [ 0, %entry ]
|
|
|
|
%arrayidx = getelementptr inbounds i32, i32* %A, i32 %i
|
|
|
|
store i32 1, i32* %arrayidx, align 4
|
|
|
|
br label %for.inner
|
|
|
|
|
|
|
|
for.inner:
|
|
|
|
%j = phi i32 [ %add6, %for.inner ], [ 0, %for.outer ]
|
|
|
|
%sum = phi i32 [ %add, %for.inner ], [ 0, %for.outer ]
|
|
|
|
%arrayidx5 = getelementptr inbounds i32, i32* %B, i32 %j
|
|
|
|
%0 = load i32, i32* %arrayidx5, align 4
|
|
|
|
%mul = mul nsw i32 %0, %i
|
|
|
|
%add = add nsw i32 %mul, %sum
|
|
|
|
%add72 = add nuw nsw i32 %i, 0
|
|
|
|
%arrayidx8 = getelementptr inbounds i32, i32* %A, i32 %add72
|
|
|
|
store i32 %add, i32* %arrayidx8, align 4
|
|
|
|
%add6 = add nuw nsw i32 %j, 1
|
|
|
|
%exitcond = icmp eq i32 %add6, %N
|
|
|
|
br i1 %exitcond, label %for.latch, label %for.inner
|
|
|
|
|
|
|
|
for.latch:
|
|
|
|
%add7 = add nuw nsw i32 %i, 1
|
|
|
|
%exitcond29 = icmp eq i32 %add7, %N
|
|
|
|
br i1 %exitcond29, label %cleanup, label %for.outer
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
; CHECK-LABEL: fore_sub_more
|
|
|
|
; CHECK: %j = phi
|
|
|
|
; CHECK-NOT: %j.1 = phi
|
|
|
|
define void @fore_sub_more(i32* noalias nocapture %A, i32 %N, i32* noalias nocapture readonly %B) {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp sgt i32 %N, 0
|
|
|
|
br i1 %cmp, label %for.outer, label %cleanup
|
|
|
|
|
|
|
|
for.outer:
|
|
|
|
%i = phi i32 [ %add7, %for.latch ], [ 0, %entry ]
|
|
|
|
%arrayidx = getelementptr inbounds i32, i32* %A, i32 %i
|
|
|
|
store i32 1, i32* %arrayidx, align 4
|
|
|
|
br label %for.inner
|
|
|
|
|
|
|
|
for.inner:
|
|
|
|
%j = phi i32 [ %add6, %for.inner ], [ 0, %for.outer ]
|
|
|
|
%sum = phi i32 [ %add, %for.inner ], [ 0, %for.outer ]
|
|
|
|
%arrayidx5 = getelementptr inbounds i32, i32* %B, i32 %j
|
|
|
|
%0 = load i32, i32* %arrayidx5, align 4
|
|
|
|
%mul = mul nsw i32 %0, %i
|
|
|
|
%add = add nsw i32 %mul, %sum
|
|
|
|
%add72 = add nuw nsw i32 %i, 1
|
|
|
|
%arrayidx8 = getelementptr inbounds i32, i32* %A, i32 %add72
|
|
|
|
store i32 %add, i32* %arrayidx8, align 4
|
|
|
|
%add6 = add nuw nsw i32 %j, 1
|
|
|
|
%exitcond = icmp eq i32 %add6, %N
|
|
|
|
br i1 %exitcond, label %for.latch, label %for.inner
|
|
|
|
|
|
|
|
for.latch:
|
|
|
|
%add7 = add nuw nsw i32 %i, 1
|
|
|
|
%exitcond29 = icmp eq i32 %add7, %N
|
|
|
|
br i1 %exitcond29, label %cleanup, label %for.outer
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
; CHECK-LABEL: sub_aft_less
|
|
|
|
; CHECK: %j = phi
|
|
|
|
; CHECK: %j.1 = phi
|
|
|
|
; CHECK: %j.2 = phi
|
|
|
|
; CHECK: %j.3 = phi
|
|
|
|
define void @sub_aft_less(i32* noalias nocapture %A, i32 %N, i32* noalias nocapture readonly %B) {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp sgt i32 %N, 0
|
|
|
|
br i1 %cmp, label %for.outer, label %cleanup
|
|
|
|
|
|
|
|
for.outer:
|
|
|
|
%i = phi i32 [ %add7, %for.latch ], [ 0, %entry ]
|
|
|
|
br label %for.inner
|
|
|
|
|
|
|
|
for.inner:
|
|
|
|
%j = phi i32 [ %add6, %for.inner ], [ 0, %for.outer ]
|
|
|
|
%sum = phi i32 [ %add, %for.inner ], [ 0, %for.outer ]
|
|
|
|
%arrayidx5 = getelementptr inbounds i32, i32* %B, i32 %j
|
|
|
|
%0 = load i32, i32* %arrayidx5, align 4
|
|
|
|
%mul = mul nsw i32 %0, %i
|
|
|
|
%add = add nsw i32 %mul, %sum
|
|
|
|
%add6 = add nuw nsw i32 %j, 1
|
|
|
|
%arrayidx = getelementptr inbounds i32, i32* %A, i32 %i
|
|
|
|
store i32 1, i32* %arrayidx, align 4
|
|
|
|
%exitcond = icmp eq i32 %add6, %N
|
|
|
|
br i1 %exitcond, label %for.latch, label %for.inner
|
|
|
|
|
|
|
|
for.latch:
|
|
|
|
%add7 = add nuw nsw i32 %i, 1
|
|
|
|
%add72 = add nuw nsw i32 %i, -1
|
|
|
|
%arrayidx8 = getelementptr inbounds i32, i32* %A, i32 %add72
|
|
|
|
store i32 %add, i32* %arrayidx8, align 4
|
|
|
|
%exitcond29 = icmp eq i32 %add7, %N
|
|
|
|
br i1 %exitcond29, label %cleanup, label %for.outer
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
; CHECK-LABEL: sub_aft_eq
|
|
|
|
; CHECK: %j = phi
|
|
|
|
; CHECK: %j.1 = phi
|
|
|
|
; CHECK: %j.2 = phi
|
|
|
|
; CHECK: %j.3 = phi
|
|
|
|
define void @sub_aft_eq(i32* noalias nocapture %A, i32 %N, i32* noalias nocapture readonly %B) {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp sgt i32 %N, 0
|
|
|
|
br i1 %cmp, label %for.outer, label %cleanup
|
|
|
|
|
|
|
|
for.outer:
|
|
|
|
%i = phi i32 [ %add7, %for.latch ], [ 0, %entry ]
|
|
|
|
br label %for.inner
|
|
|
|
|
|
|
|
for.inner:
|
|
|
|
%j = phi i32 [ %add6, %for.inner ], [ 0, %for.outer ]
|
|
|
|
%sum = phi i32 [ %add, %for.inner ], [ 0, %for.outer ]
|
|
|
|
%arrayidx5 = getelementptr inbounds i32, i32* %B, i32 %j
|
|
|
|
%0 = load i32, i32* %arrayidx5, align 4
|
|
|
|
%mul = mul nsw i32 %0, %i
|
|
|
|
%add = add nsw i32 %mul, %sum
|
|
|
|
%add6 = add nuw nsw i32 %j, 1
|
|
|
|
%arrayidx = getelementptr inbounds i32, i32* %A, i32 %i
|
|
|
|
store i32 1, i32* %arrayidx, align 4
|
|
|
|
%exitcond = icmp eq i32 %add6, %N
|
|
|
|
br i1 %exitcond, label %for.latch, label %for.inner
|
|
|
|
|
|
|
|
for.latch:
|
|
|
|
%add7 = add nuw nsw i32 %i, 1
|
|
|
|
%add72 = add nuw nsw i32 %i, 0
|
|
|
|
%arrayidx8 = getelementptr inbounds i32, i32* %A, i32 %i
|
|
|
|
store i32 %add, i32* %arrayidx8, align 4
|
|
|
|
%exitcond29 = icmp eq i32 %add7, %N
|
|
|
|
br i1 %exitcond29, label %cleanup, label %for.outer
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
; CHECK-LABEL: sub_aft_more
|
|
|
|
; CHECK: %j = phi
|
|
|
|
; CHECK-NOT: %j.1 = phi
|
|
|
|
define void @sub_aft_more(i32* noalias nocapture %A, i32 %N, i32* noalias nocapture readonly %B) {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp sgt i32 %N, 0
|
|
|
|
br i1 %cmp, label %for.outer, label %cleanup
|
|
|
|
|
|
|
|
for.outer:
|
|
|
|
%i = phi i32 [ %add7, %for.latch ], [ 0, %entry ]
|
|
|
|
br label %for.inner
|
|
|
|
|
|
|
|
for.inner:
|
|
|
|
%j = phi i32 [ %add6, %for.inner ], [ 0, %for.outer ]
|
|
|
|
%sum = phi i32 [ %add, %for.inner ], [ 0, %for.outer ]
|
|
|
|
%arrayidx5 = getelementptr inbounds i32, i32* %B, i32 %j
|
|
|
|
%0 = load i32, i32* %arrayidx5, align 4
|
|
|
|
%mul = mul nsw i32 %0, %i
|
|
|
|
%add = add nsw i32 %mul, %sum
|
|
|
|
%add6 = add nuw nsw i32 %j, 1
|
|
|
|
%arrayidx = getelementptr inbounds i32, i32* %A, i32 %i
|
|
|
|
store i32 1, i32* %arrayidx, align 4
|
|
|
|
%exitcond = icmp eq i32 %add6, %N
|
|
|
|
br i1 %exitcond, label %for.latch, label %for.inner
|
|
|
|
|
|
|
|
for.latch:
|
|
|
|
%add7 = add nuw nsw i32 %i, 1
|
|
|
|
%add72 = add nuw nsw i32 %i, 1
|
|
|
|
%arrayidx8 = getelementptr inbounds i32, i32* %A, i32 %add72
|
|
|
|
store i32 %add, i32* %arrayidx8, align 4
|
|
|
|
%exitcond29 = icmp eq i32 %add7, %N
|
|
|
|
br i1 %exitcond29, label %cleanup, label %for.outer
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
; CHECK-LABEL: sub_sub_less
|
|
|
|
; CHECK: %j = phi
|
|
|
|
; CHECK-NOT: %j.1 = phi
|
|
|
|
define void @sub_sub_less(i32* noalias nocapture %A, i32 %N, i32* noalias nocapture readonly %B) {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp sgt i32 %N, 0
|
|
|
|
br i1 %cmp, label %for.outer, label %cleanup
|
|
|
|
|
|
|
|
for.outer:
|
|
|
|
%i = phi i32 [ %add7, %for.latch ], [ 0, %entry ]
|
|
|
|
br label %for.inner
|
|
|
|
|
|
|
|
for.inner:
|
|
|
|
%j = phi i32 [ %add6, %for.inner ], [ 0, %for.outer ]
|
|
|
|
%sum = phi i32 [ %add, %for.inner ], [ 0, %for.outer ]
|
|
|
|
%arrayidx5 = getelementptr inbounds i32, i32* %B, i32 %j
|
|
|
|
%0 = load i32, i32* %arrayidx5, align 4
|
|
|
|
%mul = mul nsw i32 %0, %i
|
|
|
|
%add = add nsw i32 %mul, %sum
|
|
|
|
%add6 = add nuw nsw i32 %j, 1
|
|
|
|
%arrayidx = getelementptr inbounds i32, i32* %A, i32 %i
|
|
|
|
store i32 1, i32* %arrayidx, align 4
|
|
|
|
%add72 = add nuw nsw i32 %i, -1
|
|
|
|
%arrayidx8 = getelementptr inbounds i32, i32* %A, i32 %add72
|
|
|
|
store i32 %add, i32* %arrayidx8, align 4
|
|
|
|
%exitcond = icmp eq i32 %add6, %N
|
|
|
|
br i1 %exitcond, label %for.latch, label %for.inner
|
|
|
|
|
|
|
|
for.latch:
|
|
|
|
%add7 = add nuw nsw i32 %i, 1
|
|
|
|
%exitcond29 = icmp eq i32 %add7, %N
|
|
|
|
br i1 %exitcond29, label %cleanup, label %for.outer
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
; CHECK-LABEL: sub_sub_eq
|
|
|
|
; CHECK: %j = phi
|
|
|
|
; CHECK: %j.1 = phi
|
[LoopUnrollAndJam] Changed safety checks to consider more than 2-levels
loop nest.
Summary: As discussed in https://reviews.llvm.org/D73129.
Example
Before unroll and jam:
for
A
for
B
for
C
D
E
After unroll and jam (currently):
for
A
A'
for
B
for
C
D
B'
for
C'
D'
E
E'
After unroll and jam (Ideal):
for
A
A'
for
B
B'
for
C
C'
D
D'
E
E'
This is the first patch to change unroll and jam to work in the ideal
way.
This patch change the safety checks needed to make sure is safe to
unroll and jam in the ideal way.
Reviewer: dmgreen, jdoerfert, Meinersbur, kbarton, bmahjour, etiotto
Reviewed By: Meinersbur
Subscribers: fhahn, hiraditya, zzheng, llvm-commits, anhtuyen, prithayan
Tag: LLVM
Differential Revision: https://reviews.llvm.org/D76132
2020-05-07 05:42:47 +08:00
|
|
|
; CHECK: %j.2 = phi
|
|
|
|
; CHECK: %j.3 = phi
|
2019-04-17 12:52:47 +08:00
|
|
|
define void @sub_sub_eq(i32* noalias nocapture %A, i32 %N, i32* noalias nocapture readonly %B) {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp sgt i32 %N, 0
|
|
|
|
br i1 %cmp, label %for.outer, label %cleanup
|
|
|
|
|
|
|
|
for.outer:
|
|
|
|
%i = phi i32 [ %add7, %for.latch ], [ 0, %entry ]
|
|
|
|
br label %for.inner
|
|
|
|
|
|
|
|
for.inner:
|
|
|
|
%j = phi i32 [ %add6, %for.inner ], [ 0, %for.outer ]
|
|
|
|
%sum = phi i32 [ %add, %for.inner ], [ 0, %for.outer ]
|
|
|
|
%arrayidx5 = getelementptr inbounds i32, i32* %B, i32 %j
|
|
|
|
%0 = load i32, i32* %arrayidx5, align 4
|
|
|
|
%mul = mul nsw i32 %0, %i
|
|
|
|
%add = add nsw i32 %mul, %sum
|
|
|
|
%add6 = add nuw nsw i32 %j, 1
|
|
|
|
%arrayidx = getelementptr inbounds i32, i32* %A, i32 %i
|
|
|
|
store i32 1, i32* %arrayidx, align 4
|
|
|
|
%add72 = add nuw nsw i32 %i, 0
|
|
|
|
%arrayidx8 = getelementptr inbounds i32, i32* %A, i32 %add72
|
|
|
|
store i32 %add, i32* %arrayidx8, align 4
|
|
|
|
%exitcond = icmp eq i32 %add6, %N
|
|
|
|
br i1 %exitcond, label %for.latch, label %for.inner
|
|
|
|
|
|
|
|
for.latch:
|
|
|
|
%add7 = add nuw nsw i32 %i, 1
|
|
|
|
%exitcond29 = icmp eq i32 %add7, %N
|
|
|
|
br i1 %exitcond29, label %cleanup, label %for.outer
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
; CHECK-LABEL: sub_sub_more
|
|
|
|
; CHECK: %j = phi
|
|
|
|
; CHECK-NOT: %j.1 = phi
|
|
|
|
define void @sub_sub_more(i32* noalias nocapture %A, i32 %N, i32* noalias nocapture readonly %B) {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp sgt i32 %N, 0
|
|
|
|
br i1 %cmp, label %for.outer, label %cleanup
|
|
|
|
|
|
|
|
for.outer:
|
|
|
|
%i = phi i32 [ %add7, %for.latch ], [ 0, %entry ]
|
|
|
|
br label %for.inner
|
|
|
|
|
|
|
|
for.inner:
|
|
|
|
%j = phi i32 [ %add6, %for.inner ], [ 0, %for.outer ]
|
|
|
|
%sum = phi i32 [ %add, %for.inner ], [ 0, %for.outer ]
|
|
|
|
%arrayidx5 = getelementptr inbounds i32, i32* %B, i32 %j
|
|
|
|
%0 = load i32, i32* %arrayidx5, align 4
|
|
|
|
%mul = mul nsw i32 %0, %i
|
|
|
|
%add = add nsw i32 %mul, %sum
|
|
|
|
%add6 = add nuw nsw i32 %j, 1
|
|
|
|
%arrayidx = getelementptr inbounds i32, i32* %A, i32 %i
|
|
|
|
store i32 1, i32* %arrayidx, align 4
|
|
|
|
%add72 = add nuw nsw i32 %i, 1
|
|
|
|
%arrayidx8 = getelementptr inbounds i32, i32* %A, i32 %add72
|
|
|
|
store i32 %add, i32* %arrayidx8, align 4
|
|
|
|
%exitcond = icmp eq i32 %add6, %N
|
|
|
|
br i1 %exitcond, label %for.latch, label %for.inner
|
|
|
|
|
|
|
|
for.latch:
|
|
|
|
%add7 = add nuw nsw i32 %i, 1
|
|
|
|
%exitcond29 = icmp eq i32 %add7, %N
|
|
|
|
br i1 %exitcond29, label %cleanup, label %for.outer
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
ret void
|
|
|
|
}
|