Imported Upstream version 5.18.0.207

Former-commit-id: 3b152f462918d427ce18620a2cbe4f8b79650449
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-11-17 08:23:10 +00:00
parent 8e12397d70
commit eb85e2fc17
28480 changed files with 72 additions and 3866936 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,328 +0,0 @@
; RUN: opt < %s -loop-reroll -verify-scev -S | FileCheck %s
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; void goo32(float alpha, float *a, float *b) {
; for (int i = 0; i < 3200; i += 32) {
; a[i] += alpha * b[i];
; a[i + 1] += alpha * b[i + 1];
; a[i + 2] += alpha * b[i + 2];
; a[i + 3] += alpha * b[i + 3];
; a[i + 4] += alpha * b[i + 4];
; a[i + 5] += alpha * b[i + 5];
; a[i + 6] += alpha * b[i + 6];
; a[i + 7] += alpha * b[i + 7];
; a[i + 8] += alpha * b[i + 8];
; a[i + 9] += alpha * b[i + 9];
; a[i + 10] += alpha * b[i + 10];
; a[i + 11] += alpha * b[i + 11];
; a[i + 12] += alpha * b[i + 12];
; a[i + 13] += alpha * b[i + 13];
; a[i + 14] += alpha * b[i + 14];
; a[i + 15] += alpha * b[i + 15];
; a[i + 16] += alpha * b[i + 16];
; a[i + 17] += alpha * b[i + 17];
; a[i + 18] += alpha * b[i + 18];
; a[i + 19] += alpha * b[i + 19];
; a[i + 20] += alpha * b[i + 20];
; a[i + 21] += alpha * b[i + 21];
; a[i + 22] += alpha * b[i + 22];
; a[i + 23] += alpha * b[i + 23];
; a[i + 24] += alpha * b[i + 24];
; a[i + 25] += alpha * b[i + 25];
; a[i + 26] += alpha * b[i + 26];
; a[i + 27] += alpha * b[i + 27];
; a[i + 28] += alpha * b[i + 28];
; a[i + 29] += alpha * b[i + 29];
; a[i + 30] += alpha * b[i + 30];
; a[i + 31] += alpha * b[i + 31];
; }
; }
; Function Attrs: norecurse nounwind uwtable
define void @goo32(float %alpha, float* %a, float* readonly %b) #0 {
entry:
br label %for.body
for.body: ; preds = %entry, %for.body
%indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
%arrayidx = getelementptr inbounds float, float* %b, i64 %indvars.iv
%0 = load float, float* %arrayidx, align 4
%mul = fmul float %0, %alpha
%arrayidx2 = getelementptr inbounds float, float* %a, i64 %indvars.iv
%1 = load float, float* %arrayidx2, align 4
%add = fadd float %1, %mul
store float %add, float* %arrayidx2, align 4
%2 = or i64 %indvars.iv, 1
%arrayidx5 = getelementptr inbounds float, float* %b, i64 %2
%3 = load float, float* %arrayidx5, align 4
%mul6 = fmul float %3, %alpha
%arrayidx9 = getelementptr inbounds float, float* %a, i64 %2
%4 = load float, float* %arrayidx9, align 4
%add10 = fadd float %4, %mul6
store float %add10, float* %arrayidx9, align 4
%5 = or i64 %indvars.iv, 2
%arrayidx13 = getelementptr inbounds float, float* %b, i64 %5
%6 = load float, float* %arrayidx13, align 4
%mul14 = fmul float %6, %alpha
%arrayidx17 = getelementptr inbounds float, float* %a, i64 %5
%7 = load float, float* %arrayidx17, align 4
%add18 = fadd float %7, %mul14
store float %add18, float* %arrayidx17, align 4
%8 = or i64 %indvars.iv, 3
%arrayidx21 = getelementptr inbounds float, float* %b, i64 %8
%9 = load float, float* %arrayidx21, align 4
%mul22 = fmul float %9, %alpha
%arrayidx25 = getelementptr inbounds float, float* %a, i64 %8
%10 = load float, float* %arrayidx25, align 4
%add26 = fadd float %10, %mul22
store float %add26, float* %arrayidx25, align 4
%11 = or i64 %indvars.iv, 4
%arrayidx29 = getelementptr inbounds float, float* %b, i64 %11
%12 = load float, float* %arrayidx29, align 4
%mul30 = fmul float %12, %alpha
%arrayidx33 = getelementptr inbounds float, float* %a, i64 %11
%13 = load float, float* %arrayidx33, align 4
%add34 = fadd float %13, %mul30
store float %add34, float* %arrayidx33, align 4
%14 = or i64 %indvars.iv, 5
%arrayidx37 = getelementptr inbounds float, float* %b, i64 %14
%15 = load float, float* %arrayidx37, align 4
%mul38 = fmul float %15, %alpha
%arrayidx41 = getelementptr inbounds float, float* %a, i64 %14
%16 = load float, float* %arrayidx41, align 4
%add42 = fadd float %16, %mul38
store float %add42, float* %arrayidx41, align 4
%17 = or i64 %indvars.iv, 6
%arrayidx45 = getelementptr inbounds float, float* %b, i64 %17
%18 = load float, float* %arrayidx45, align 4
%mul46 = fmul float %18, %alpha
%arrayidx49 = getelementptr inbounds float, float* %a, i64 %17
%19 = load float, float* %arrayidx49, align 4
%add50 = fadd float %19, %mul46
store float %add50, float* %arrayidx49, align 4
%20 = or i64 %indvars.iv, 7
%arrayidx53 = getelementptr inbounds float, float* %b, i64 %20
%21 = load float, float* %arrayidx53, align 4
%mul54 = fmul float %21, %alpha
%arrayidx57 = getelementptr inbounds float, float* %a, i64 %20
%22 = load float, float* %arrayidx57, align 4
%add58 = fadd float %22, %mul54
store float %add58, float* %arrayidx57, align 4
%23 = or i64 %indvars.iv, 8
%arrayidx61 = getelementptr inbounds float, float* %b, i64 %23
%24 = load float, float* %arrayidx61, align 4
%mul62 = fmul float %24, %alpha
%arrayidx65 = getelementptr inbounds float, float* %a, i64 %23
%25 = load float, float* %arrayidx65, align 4
%add66 = fadd float %25, %mul62
store float %add66, float* %arrayidx65, align 4
%26 = or i64 %indvars.iv, 9
%arrayidx69 = getelementptr inbounds float, float* %b, i64 %26
%27 = load float, float* %arrayidx69, align 4
%mul70 = fmul float %27, %alpha
%arrayidx73 = getelementptr inbounds float, float* %a, i64 %26
%28 = load float, float* %arrayidx73, align 4
%add74 = fadd float %28, %mul70
store float %add74, float* %arrayidx73, align 4
%29 = or i64 %indvars.iv, 10
%arrayidx77 = getelementptr inbounds float, float* %b, i64 %29
%30 = load float, float* %arrayidx77, align 4
%mul78 = fmul float %30, %alpha
%arrayidx81 = getelementptr inbounds float, float* %a, i64 %29
%31 = load float, float* %arrayidx81, align 4
%add82 = fadd float %31, %mul78
store float %add82, float* %arrayidx81, align 4
%32 = or i64 %indvars.iv, 11
%arrayidx85 = getelementptr inbounds float, float* %b, i64 %32
%33 = load float, float* %arrayidx85, align 4
%mul86 = fmul float %33, %alpha
%arrayidx89 = getelementptr inbounds float, float* %a, i64 %32
%34 = load float, float* %arrayidx89, align 4
%add90 = fadd float %34, %mul86
store float %add90, float* %arrayidx89, align 4
%35 = or i64 %indvars.iv, 12
%arrayidx93 = getelementptr inbounds float, float* %b, i64 %35
%36 = load float, float* %arrayidx93, align 4
%mul94 = fmul float %36, %alpha
%arrayidx97 = getelementptr inbounds float, float* %a, i64 %35
%37 = load float, float* %arrayidx97, align 4
%add98 = fadd float %37, %mul94
store float %add98, float* %arrayidx97, align 4
%38 = or i64 %indvars.iv, 13
%arrayidx101 = getelementptr inbounds float, float* %b, i64 %38
%39 = load float, float* %arrayidx101, align 4
%mul102 = fmul float %39, %alpha
%arrayidx105 = getelementptr inbounds float, float* %a, i64 %38
%40 = load float, float* %arrayidx105, align 4
%add106 = fadd float %40, %mul102
store float %add106, float* %arrayidx105, align 4
%41 = or i64 %indvars.iv, 14
%arrayidx109 = getelementptr inbounds float, float* %b, i64 %41
%42 = load float, float* %arrayidx109, align 4
%mul110 = fmul float %42, %alpha
%arrayidx113 = getelementptr inbounds float, float* %a, i64 %41
%43 = load float, float* %arrayidx113, align 4
%add114 = fadd float %43, %mul110
store float %add114, float* %arrayidx113, align 4
%44 = or i64 %indvars.iv, 15
%arrayidx117 = getelementptr inbounds float, float* %b, i64 %44
%45 = load float, float* %arrayidx117, align 4
%mul118 = fmul float %45, %alpha
%arrayidx121 = getelementptr inbounds float, float* %a, i64 %44
%46 = load float, float* %arrayidx121, align 4
%add122 = fadd float %46, %mul118
store float %add122, float* %arrayidx121, align 4
%47 = or i64 %indvars.iv, 16
%arrayidx125 = getelementptr inbounds float, float* %b, i64 %47
%48 = load float, float* %arrayidx125, align 4
%mul126 = fmul float %48, %alpha
%arrayidx129 = getelementptr inbounds float, float* %a, i64 %47
%49 = load float, float* %arrayidx129, align 4
%add130 = fadd float %49, %mul126
store float %add130, float* %arrayidx129, align 4
%50 = or i64 %indvars.iv, 17
%arrayidx133 = getelementptr inbounds float, float* %b, i64 %50
%51 = load float, float* %arrayidx133, align 4
%mul134 = fmul float %51, %alpha
%arrayidx137 = getelementptr inbounds float, float* %a, i64 %50
%52 = load float, float* %arrayidx137, align 4
%add138 = fadd float %52, %mul134
store float %add138, float* %arrayidx137, align 4
%53 = or i64 %indvars.iv, 18
%arrayidx141 = getelementptr inbounds float, float* %b, i64 %53
%54 = load float, float* %arrayidx141, align 4
%mul142 = fmul float %54, %alpha
%arrayidx145 = getelementptr inbounds float, float* %a, i64 %53
%55 = load float, float* %arrayidx145, align 4
%add146 = fadd float %55, %mul142
store float %add146, float* %arrayidx145, align 4
%56 = or i64 %indvars.iv, 19
%arrayidx149 = getelementptr inbounds float, float* %b, i64 %56
%57 = load float, float* %arrayidx149, align 4
%mul150 = fmul float %57, %alpha
%arrayidx153 = getelementptr inbounds float, float* %a, i64 %56
%58 = load float, float* %arrayidx153, align 4
%add154 = fadd float %58, %mul150
store float %add154, float* %arrayidx153, align 4
%59 = or i64 %indvars.iv, 20
%arrayidx157 = getelementptr inbounds float, float* %b, i64 %59
%60 = load float, float* %arrayidx157, align 4
%mul158 = fmul float %60, %alpha
%arrayidx161 = getelementptr inbounds float, float* %a, i64 %59
%61 = load float, float* %arrayidx161, align 4
%add162 = fadd float %61, %mul158
store float %add162, float* %arrayidx161, align 4
%62 = or i64 %indvars.iv, 21
%arrayidx165 = getelementptr inbounds float, float* %b, i64 %62
%63 = load float, float* %arrayidx165, align 4
%mul166 = fmul float %63, %alpha
%arrayidx169 = getelementptr inbounds float, float* %a, i64 %62
%64 = load float, float* %arrayidx169, align 4
%add170 = fadd float %64, %mul166
store float %add170, float* %arrayidx169, align 4
%65 = or i64 %indvars.iv, 22
%arrayidx173 = getelementptr inbounds float, float* %b, i64 %65
%66 = load float, float* %arrayidx173, align 4
%mul174 = fmul float %66, %alpha
%arrayidx177 = getelementptr inbounds float, float* %a, i64 %65
%67 = load float, float* %arrayidx177, align 4
%add178 = fadd float %67, %mul174
store float %add178, float* %arrayidx177, align 4
%68 = or i64 %indvars.iv, 23
%arrayidx181 = getelementptr inbounds float, float* %b, i64 %68
%69 = load float, float* %arrayidx181, align 4
%mul182 = fmul float %69, %alpha
%arrayidx185 = getelementptr inbounds float, float* %a, i64 %68
%70 = load float, float* %arrayidx185, align 4
%add186 = fadd float %70, %mul182
store float %add186, float* %arrayidx185, align 4
%71 = or i64 %indvars.iv, 24
%arrayidx189 = getelementptr inbounds float, float* %b, i64 %71
%72 = load float, float* %arrayidx189, align 4
%mul190 = fmul float %72, %alpha
%arrayidx193 = getelementptr inbounds float, float* %a, i64 %71
%73 = load float, float* %arrayidx193, align 4
%add194 = fadd float %73, %mul190
store float %add194, float* %arrayidx193, align 4
%74 = or i64 %indvars.iv, 25
%arrayidx197 = getelementptr inbounds float, float* %b, i64 %74
%75 = load float, float* %arrayidx197, align 4
%mul198 = fmul float %75, %alpha
%arrayidx201 = getelementptr inbounds float, float* %a, i64 %74
%76 = load float, float* %arrayidx201, align 4
%add202 = fadd float %76, %mul198
store float %add202, float* %arrayidx201, align 4
%77 = or i64 %indvars.iv, 26
%arrayidx205 = getelementptr inbounds float, float* %b, i64 %77
%78 = load float, float* %arrayidx205, align 4
%mul206 = fmul float %78, %alpha
%arrayidx209 = getelementptr inbounds float, float* %a, i64 %77
%79 = load float, float* %arrayidx209, align 4
%add210 = fadd float %79, %mul206
store float %add210, float* %arrayidx209, align 4
%80 = or i64 %indvars.iv, 27
%arrayidx213 = getelementptr inbounds float, float* %b, i64 %80
%81 = load float, float* %arrayidx213, align 4
%mul214 = fmul float %81, %alpha
%arrayidx217 = getelementptr inbounds float, float* %a, i64 %80
%82 = load float, float* %arrayidx217, align 4
%add218 = fadd float %82, %mul214
store float %add218, float* %arrayidx217, align 4
%83 = or i64 %indvars.iv, 28
%arrayidx221 = getelementptr inbounds float, float* %b, i64 %83
%84 = load float, float* %arrayidx221, align 4
%mul222 = fmul float %84, %alpha
%arrayidx225 = getelementptr inbounds float, float* %a, i64 %83
%85 = load float, float* %arrayidx225, align 4
%add226 = fadd float %85, %mul222
store float %add226, float* %arrayidx225, align 4
%86 = or i64 %indvars.iv, 29
%arrayidx229 = getelementptr inbounds float, float* %b, i64 %86
%87 = load float, float* %arrayidx229, align 4
%mul230 = fmul float %87, %alpha
%arrayidx233 = getelementptr inbounds float, float* %a, i64 %86
%88 = load float, float* %arrayidx233, align 4
%add234 = fadd float %88, %mul230
store float %add234, float* %arrayidx233, align 4
%89 = or i64 %indvars.iv, 30
%arrayidx237 = getelementptr inbounds float, float* %b, i64 %89
%90 = load float, float* %arrayidx237, align 4
%mul238 = fmul float %90, %alpha
%arrayidx241 = getelementptr inbounds float, float* %a, i64 %89
%91 = load float, float* %arrayidx241, align 4
%add242 = fadd float %91, %mul238
store float %add242, float* %arrayidx241, align 4
%92 = or i64 %indvars.iv, 31
%arrayidx245 = getelementptr inbounds float, float* %b, i64 %92
%93 = load float, float* %arrayidx245, align 4
%mul246 = fmul float %93, %alpha
%arrayidx249 = getelementptr inbounds float, float* %a, i64 %92
%94 = load float, float* %arrayidx249, align 4
%add250 = fadd float %94, %mul246
store float %add250, float* %arrayidx249, align 4
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 32
%cmp = icmp slt i64 %indvars.iv.next, 3200
br i1 %cmp, label %for.body, label %for.end
; CHECK-LABEL: @goo32
; CHECK: for.body:
; CHECK: %indvar = phi i64 [ %indvar.next, %for.body ], [ 0, %entry ]
; CHECK: %arrayidx = getelementptr inbounds float, float* %b, i64 %indvar
; CHECK: %0 = load float, float* %arrayidx, align 4
; CHECK: %mul = fmul float %0, %alpha
; CHECK: %arrayidx2 = getelementptr inbounds float, float* %a, i64 %indvar
; CHECK: %1 = load float, float* %arrayidx2, align 4
; CHECK: %add = fadd float %1, %mul
; CHECK: store float %add, float* %arrayidx2, align 4
; CHECK: %indvar.next = add i64 %indvar, 1
; CHECK: %exitcond = icmp eq i64 %indvar, 3199
; CHECK: br i1 %exitcond, label %for.end, label %for.body
; CHECK: ret
for.end: ; preds = %for.body
ret void
}
attributes #0 = { nounwind uwtable }

View File

@ -1,134 +0,0 @@
; RUN: opt -S -loop-reroll %s | FileCheck %s
declare i32 @goo(i32, i32)
@buf = external global i8*
@aaa = global [16 x i8] c"\01\02\03\04\05\06\07\08\09\0A\0B\0C\0D\0E\0F\10", align 1
define i32 @test1(i32 %len) {
entry:
br label %while.body
while.body:
;CHECK-LABEL: while.body:
;CHECK-NEXT: %indvar = phi i32 [ %indvar.next, %while.body ], [ 0, %entry ]
;CHECK-NEXT: %buf.021 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @aaa, i64 0, i64 0), %entry ], [ %add.ptr, %while.body ]
;CHECK-NEXT: %sum44.020 = phi i64 [ 0, %entry ], [ %add, %while.body ]
;CHECK-NEXT: [[T2:%[0-9]+]] = load i8, i8* %buf.021, align 1
;CHECK-NEXT: %conv = zext i8 [[T2]] to i64
;CHECK-NEXT: %add = add i64 %conv, %sum44.020
;CHECK-NEXT: %add.ptr = getelementptr inbounds i8, i8* %buf.021, i64 1
;CHECK-NEXT: %indvar.next = add i32 %indvar, 1
;CHECK-NEXT: %exitcond = icmp eq i32 %indvar, 1
;CHECK-NEXT: br i1 %exitcond, label %while.end, label %while.body
%dec22 = phi i32 [ 4, %entry ], [ %dec, %while.body ]
%buf.021 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @aaa, i64 0, i64 0), %entry ], [ %add.ptr, %while.body ]
%sum44.020 = phi i64 [ 0, %entry ], [ %add9, %while.body ]
%0 = load i8, i8* %buf.021, align 1
%conv = zext i8 %0 to i64
%add = add i64 %conv, %sum44.020
%arrayidx1 = getelementptr inbounds i8, i8* %buf.021, i64 1
%1 = load i8, i8* %arrayidx1, align 1
%conv2 = zext i8 %1 to i64
%add3 = add i64 %add, %conv2
%arrayidx4 = getelementptr inbounds i8, i8* %buf.021, i64 2
%2 = load i8, i8* %arrayidx4, align 1
%conv5 = zext i8 %2 to i64
%add6 = add i64 %add3, %conv5
%arrayidx7 = getelementptr inbounds i8, i8* %buf.021, i64 3
%3 = load i8, i8* %arrayidx7, align 1
%conv8 = zext i8 %3 to i64
%add9 = add i64 %add6, %conv8
%add.ptr = getelementptr inbounds i8, i8* %buf.021, i64 4
%dec = add nsw i32 %dec22, -1
%tobool = icmp eq i32 %dec, 0
br i1 %tobool, label %while.end, label %while.body
while.end: ; preds = %while.body
%conv11 = trunc i64 %add9 to i32
%call = tail call i32 @goo(i32 0, i32 %conv11)
unreachable
}
define i32 @test2(i32 %N, i32* nocapture readonly %a, i32 %S) {
entry:
%cmp.9 = icmp sgt i32 %N, 0
br i1 %cmp.9, label %for.body.lr.ph, label %for.cond.cleanup
for.body.lr.ph:
br label %for.body
for.cond.for.cond.cleanup_crit_edge:
br label %for.cond.cleanup
for.cond.cleanup:
%S.addr.0.lcssa = phi i32 [ %add2, %for.cond.for.cond.cleanup_crit_edge ], [ %S, %entry ]
ret i32 %S.addr.0.lcssa
for.body:
;CHECK-LABEL: for.body:
;CHECK-NEXT: %indvar = phi i32 [ %indvar.next, %for.body ], [ 0, %for.body.lr.ph ]
;CHECK-NEXT: %S.addr.011 = phi i32 [ %S, %for.body.lr.ph ], [ %add, %for.body ]
;CHECK-NEXT: %a.addr.010 = phi i32* [ %a, %for.body.lr.ph ], [ %incdec.ptr1, %for.body ]
;CHECK-NEXT: %4 = load i32, i32* %a.addr.010, align 4
;CHECK-NEXT: %add = add nsw i32 %4, %S.addr.011
;CHECK-NEXT: %incdec.ptr1 = getelementptr inbounds i32, i32* %a.addr.010, i64 1
;CHECK-NEXT: %indvar.next = add i32 %indvar, 1
;CHECK-NEXT: %exitcond = icmp eq i32 %indvar, %3
;CHECK-NEXT: br i1 %exitcond, label %for.cond.for.cond.cleanup_crit_edge, label %for.body
%i.012 = phi i32 [ 0, %for.body.lr.ph ], [ %add3, %for.body ]
%S.addr.011 = phi i32 [ %S, %for.body.lr.ph ], [ %add2, %for.body ]
%a.addr.010 = phi i32* [ %a, %for.body.lr.ph ], [ %incdec.ptr1, %for.body ]
%incdec.ptr = getelementptr inbounds i32, i32* %a.addr.010, i64 1
%0 = load i32, i32* %a.addr.010, align 4
%add = add nsw i32 %0, %S.addr.011
%incdec.ptr1 = getelementptr inbounds i32, i32* %a.addr.010, i64 2
%1 = load i32, i32* %incdec.ptr, align 4
%add2 = add nsw i32 %add, %1
%add3 = add nsw i32 %i.012, 2
%cmp = icmp slt i32 %add3, %N
br i1 %cmp, label %for.body, label %for.cond.for.cond.cleanup_crit_edge
}
define i32 @test3(i32* nocapture readonly %buf, i32 %len) #0 {
entry:
%cmp10 = icmp sgt i32 %len, 1
br i1 %cmp10, label %while.body.preheader, label %while.end
while.body.preheader: ; preds = %entry
br label %while.body
while.body: ; preds = %while.body.preheader, %while.body
;CHECK-LABEL: while.body:
;CHECK-NEXT: %indvar = phi i32 [ %indvar.next, %while.body ], [ 0, %while.body.preheader ]
;CHECK-NEXT: %S.012 = phi i32 [ %add, %while.body ], [ undef, %while.body.preheader ]
;CHECK-NEXT: %buf.addr.011 = phi i32* [ %add.ptr, %while.body ], [ %buf, %while.body.preheader ]
;CHECK-NEXT: %4 = load i32, i32* %buf.addr.011, align 4
;CHECK-NEXT: %add = add nsw i32 %4, %S.012
;CHECK-NEXT: %add.ptr = getelementptr inbounds i32, i32* %buf.addr.011, i64 -1
;CHECK-NEXT: %indvar.next = add i32 %indvar, 1
;CHECK-NEXT: %exitcond = icmp eq i32 %indvar, %3
;CHECK-NEXT: br i1 %exitcond, label %while.end.loopexit, label %while.body
%i.013 = phi i32 [ %sub, %while.body ], [ %len, %while.body.preheader ]
%S.012 = phi i32 [ %add2, %while.body ], [ undef, %while.body.preheader ]
%buf.addr.011 = phi i32* [ %add.ptr, %while.body ], [ %buf, %while.body.preheader ]
%0 = load i32, i32* %buf.addr.011, align 4
%add = add nsw i32 %0, %S.012
%arrayidx1 = getelementptr inbounds i32, i32* %buf.addr.011, i64 -1
%1 = load i32, i32* %arrayidx1, align 4
%add2 = add nsw i32 %add, %1
%add.ptr = getelementptr inbounds i32, i32* %buf.addr.011, i64 -2
%sub = add nsw i32 %i.013, -2
%cmp = icmp sgt i32 %sub, 1
br i1 %cmp, label %while.body, label %while.end.loopexit
while.end.loopexit: ; preds = %while.body
br label %while.end
while.end: ; preds = %while.end.loopexit, %entry
%S.0.lcssa = phi i32 [ undef, %entry ], [ %add2, %while.end.loopexit ]
ret i32 %S.0.lcssa
}

View File

@ -1,186 +0,0 @@
; RUN: opt -S -loop-reroll %s | FileCheck %s
target triple = "aarch64--linux-gnu"
define void @test(i32 %n, float* %arrayidx200, float* %arrayidx164, float* %arrayidx172) {
entry:
%rem.i = srem i32 %n, 4
%t22 = load float, float* %arrayidx172, align 4
%cmp.9 = icmp eq i32 %n, 0
%t7 = sext i32 %n to i64
br i1 %cmp.9, label %while.end, label %while.body.preheader
while.body.preheader:
br label %while.body
while.body:
;CHECK-LABEL: while.body:
;CHECK-NEXT: %indvars.iv.i423 = phi i64 [ %indvars.iv.next.i424, %while.body ], [ 0, %while.body.preheader ]
;CHECK-NEXT: [[T1:%[0-9]+]] = trunc i64 %indvars.iv.i423 to i32
;CHECK-NEXT: %arrayidx62.i = getelementptr inbounds float, float* %arrayidx200, i64 %indvars.iv.i423
;CHECK-NEXT: %t1 = load float, float* %arrayidx62.i, align 4
;CHECK-NEXT: %arrayidx64.i = getelementptr inbounds float, float* %arrayidx164, i64 %indvars.iv.i423
;CHECK-NEXT: %t2 = load float, float* %arrayidx64.i, align 4
;CHECK-NEXT: %mul65.i = fmul fast float %t2, %t22
;CHECK-NEXT: %add66.i = fadd fast float %mul65.i, %t1
;CHECK-NEXT: store float %add66.i, float* %arrayidx62.i, align 4
;CHECK-NEXT: %indvars.iv.next.i424 = add i64 %indvars.iv.i423, 1
;CHECK-NEXT: [[T2:%[0-9]+]] = sext i32 [[T1]] to i64
;CHECK-NEXT: %exitcond = icmp eq i64 [[T2]], %{{[0-9]+}}
;CHECK-NEXT: br i1 %exitcond, label %while.end.loopexit, label %while.body
%indvars.iv.i423 = phi i64 [ %indvars.iv.next.i424, %while.body ], [ 0, %while.body.preheader ]
%i.22.i = phi i32 [ %add103.i, %while.body ], [ %rem.i, %while.body.preheader ]
%arrayidx62.i = getelementptr inbounds float, float* %arrayidx200, i64 %indvars.iv.i423
%t1 = load float, float* %arrayidx62.i, align 4
%arrayidx64.i = getelementptr inbounds float, float* %arrayidx164, i64 %indvars.iv.i423
%t2 = load float, float* %arrayidx64.i, align 4
%mul65.i = fmul fast float %t2, %t22
%add66.i = fadd fast float %mul65.i, %t1
store float %add66.i, float* %arrayidx62.i, align 4
%t3 = add nsw i64 %indvars.iv.i423, 1
%arrayidx71.i = getelementptr inbounds float, float* %arrayidx200, i64 %t3
%t4 = load float, float* %arrayidx71.i, align 4
%arrayidx74.i = getelementptr inbounds float, float* %arrayidx164, i64 %t3
%t5 = load float, float* %arrayidx74.i, align 4
%mul75.i = fmul fast float %t5, %t22
%add76.i = fadd fast float %mul75.i, %t4
store float %add76.i, float* %arrayidx71.i, align 4
%add103.i = add nsw i32 %i.22.i, 2
%t6 = sext i32 %add103.i to i64
%cmp58.i = icmp slt i64 %t6, %t7
%indvars.iv.next.i424 = add i64 %indvars.iv.i423, 2
br i1 %cmp58.i, label %while.body, label %while.end.loopexit
while.end.loopexit:
br label %while.end
while.end:
ret void
}
; Function Attrs: noinline norecurse nounwind
define i32 @test2(i64 %n, i32* nocapture %x, i32* nocapture readonly %y) {
entry:
%cmp18 = icmp sgt i64 %n, 0
br i1 %cmp18, label %for.body.preheader, label %for.end
for.body.preheader: ; preds = %entry
br label %for.body
for.body: ; preds = %for.body.preheader, %for.body
;CHECK: for.body:
;CHECK-NEXT: %indvar = phi i64 [ %indvar.next, %for.body ], [ 0, %for.body.preheader ]
;CHECK-NEXT: %arrayidx = getelementptr inbounds i32, i32* %y, i64 %indvar
;CHECK-NEXT: [[T1:%[0-9]+]] = load i32, i32* %arrayidx, align 4
;CHECK-NEXT: %arrayidx3 = getelementptr inbounds i32, i32* %x, i64 %indvar
;CHECK-NEXT: store i32 [[T1]], i32* %arrayidx3, align 4
;CHECK-NEXT: %indvar.next = add i64 %indvar, 1
;CHECK-NEXT: %exitcond = icmp eq i64 %indvar, %{{[0-9]+}}
;CHECK-NEXT: br i1 %exitcond, label %for.end.loopexit, label %for.body
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ]
%arrayidx = getelementptr inbounds i32, i32* %y, i64 %indvars.iv
%0 = load i32, i32* %arrayidx, align 4
%arrayidx3 = getelementptr inbounds i32, i32* %x, i64 %indvars.iv
store i32 %0, i32* %arrayidx3, align 4
%1 = or i64 %indvars.iv, 1
%arrayidx5 = getelementptr inbounds i32, i32* %y, i64 %1
%2 = load i32, i32* %arrayidx5, align 4
%arrayidx8 = getelementptr inbounds i32, i32* %x, i64 %1
store i32 %2, i32* %arrayidx8, align 4
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 2
%cmp = icmp slt i64 %indvars.iv.next, %n
br i1 %cmp, label %for.body, label %for.end.loopexit
for.end.loopexit: ; preds = %for.body
br label %for.end
for.end: ; preds = %for.end.loopexit, %entry
ret i32 0
}
; Function Attrs: noinline norecurse nounwind
define i32 @test3(i32 %n, i32* nocapture %x, i32* nocapture readonly %y) {
entry:
%cmp21 = icmp sgt i32 %n, 0
br i1 %cmp21, label %for.body.preheader, label %for.end
for.body.preheader: ; preds = %entry
br label %for.body
for.body: ; preds = %for.body.preheader, %for.body
;CHECK: for.body:
;CHECK: %add12 = add i8 %i.022, 2
;CHECK-NEXT: %conv = sext i8 %add12 to i32
;CHECK-NEXT: %cmp = icmp slt i32 %conv, %n
;CHECK-NEXT: br i1 %cmp, label %for.body, label %for.end.loopexit
%conv23 = phi i32 [ %conv, %for.body ], [ 0, %for.body.preheader ]
%i.022 = phi i8 [ %add12, %for.body ], [ 0, %for.body.preheader ]
%idxprom = sext i8 %i.022 to i64
%arrayidx = getelementptr inbounds i32, i32* %y, i64 %idxprom
%0 = load i32, i32* %arrayidx, align 4
%arrayidx3 = getelementptr inbounds i32, i32* %x, i64 %idxprom
store i32 %0, i32* %arrayidx3, align 4
%add = or i32 %conv23, 1
%idxprom5 = sext i32 %add to i64
%arrayidx6 = getelementptr inbounds i32, i32* %y, i64 %idxprom5
%1 = load i32, i32* %arrayidx6, align 4
%arrayidx10 = getelementptr inbounds i32, i32* %x, i64 %idxprom5
store i32 %1, i32* %arrayidx10, align 4
%add12 = add i8 %i.022, 2
%conv = sext i8 %add12 to i32
%cmp = icmp slt i32 %conv, %n
br i1 %cmp, label %for.body, label %for.end.loopexit
for.end.loopexit: ; preds = %for.body
br label %for.end
for.end: ; preds = %for.end.loopexit, %entry
ret i32 0
}
; Function Attrs: noinline norecurse nounwind
define i32 @test4(i64 %n, i32* nocapture %x, i32* nocapture readonly %y) {
entry:
%cmp18 = icmp eq i64 %n, 0
br i1 %cmp18, label %for.end, label %for.body.preheader
for.body.preheader: ; preds = %entry
br label %for.body
for.body: ; preds = %for.body.preheader, %for.body
;CHECK: for.body:
;CHECK-NEXT: %indvar = phi i64 [ %indvar.next, %for.body ], [ 0, %for.body.preheader ]
;CHECK-NEXT: %arrayidx = getelementptr inbounds i32, i32* %y, i64 %indvar
;CHECK-NEXT: [[T1:%[0-9]+]] = load i32, i32* %arrayidx, align 4
;CHECK-NEXT: %arrayidx3 = getelementptr inbounds i32, i32* %x, i64 %indvar
;CHECK-NEXT: store i32 [[T1]], i32* %arrayidx3, align 4
;CHECK-NEXT: %indvar.next = add i64 %indvar, 1
;CHECK-NEXT: %exitcond = icmp eq i64 %indvar, %{{[0-9]+}}
;CHECK-NEXT: br i1 %exitcond, label %for.end.loopexit, label %for.body
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ]
%arrayidx = getelementptr inbounds i32, i32* %y, i64 %indvars.iv
%0 = load i32, i32* %arrayidx, align 4
%arrayidx3 = getelementptr inbounds i32, i32* %x, i64 %indvars.iv
store i32 %0, i32* %arrayidx3, align 4
%1 = or i64 %indvars.iv, 1
%arrayidx5 = getelementptr inbounds i32, i32* %y, i64 %1
%2 = load i32, i32* %arrayidx5, align 4
%arrayidx8 = getelementptr inbounds i32, i32* %x, i64 %1
store i32 %2, i32* %arrayidx8, align 4
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 2
%cmp = icmp ult i64 %indvars.iv.next, %n
br i1 %cmp, label %for.body, label %for.end.loopexit
for.end.loopexit: ; preds = %for.body
br label %for.end
for.end: ; preds = %for.end.loopexit, %entry
ret i32 0
}

View File

@ -1,48 +0,0 @@
; RUN: opt -S -loop-reroll %s | FileCheck %s
target triple = "aarch64--linux-gnu"
@buf = global [16 x i8] c"\0A\0A\0A\0A\0A\0A\0A\0A\0A\0A\0A\0A\0A\0A\0A\0A", align 1
define i32 @test1(i32 %len, i8* nocapture readonly %buf) #0 {
entry:
%cmp.13 = icmp sgt i32 %len, 1
br i1 %cmp.13, label %while.body.lr.ph, label %while.end
while.body.lr.ph: ; preds = %entry
br label %while.body
while.body:
;CHECK-LABEL: while.body:
;CHECK-NEXT: %indvar = phi i32 [ %indvar.next, %while.body ], [ 0, %while.body.lr.ph ]
;CHECK-NEXT: %sum4.015 = phi i64 [ 0, %while.body.lr.ph ], [ %add, %while.body ]
;CHECK-NOT: %sub5 = add nsw i32 %len.addr.014, -1
;CHECK-NOT: %sub5 = add nsw i32 %len.addr.014, -2
;CHECK: br i1 %exitcond, label %while.cond.while.end_crit_edge, label %while.body
%sum4.015 = phi i64 [ 0, %while.body.lr.ph ], [ %add4, %while.body ]
%len.addr.014 = phi i32 [ %len, %while.body.lr.ph ], [ %sub5, %while.body ]
%idxprom = sext i32 %len.addr.014 to i64
%arrayidx = getelementptr inbounds i8, i8* %buf, i64 %idxprom
%0 = load i8, i8* %arrayidx, align 1
%conv = zext i8 %0 to i64
%add = add i64 %conv, %sum4.015
%sub = add nsw i32 %len.addr.014, -1
%idxprom1 = sext i32 %sub to i64
%arrayidx2 = getelementptr inbounds i8, i8* %buf, i64 %idxprom1
%1 = load i8, i8* %arrayidx2, align 1
%conv3 = zext i8 %1 to i64
%add4 = add i64 %add, %conv3
%sub5 = add nsw i32 %len.addr.014, -2
%cmp = icmp sgt i32 %sub5, 1
br i1 %cmp, label %while.body, label %while.cond.while.end_crit_edge
while.cond.while.end_crit_edge: ; preds = %while.body
%add4.lcssa = phi i64 [ %add4, %while.body ]
%phitmp = trunc i64 %add4.lcssa to i32
br label %while.end
while.end: ; preds = %while.cond.while.end_crit_edge, %entry
%sum4.0.lcssa = phi i32 [ %phitmp, %while.cond.while.end_crit_edge ], [ 0, %entry ]
ret i32 %sum4.0.lcssa
unreachable
}

View File

@ -1,152 +0,0 @@
; RUN: opt < %s -loop-reroll -S | FileCheck %s
target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:32:64-v128:32:128-a0:0:32-n32-S32"
target triple = "thumbv7-none-linux"
;void foo(int *A, int *B, int m, int n) {
; for (int i = m; i < n; i+=4) {
; A[i+0] = B[i+0] * 4;
; A[i+1] = B[i+1] * 4;
; A[i+2] = B[i+2] * 4;
; A[i+3] = B[i+3] * 4;
; }
;}
define void @foo(i32* nocapture %A, i32* nocapture readonly %B, i32 %m, i32 %n) {
entry:
%cmp34 = icmp slt i32 %m, %n
br i1 %cmp34, label %for.body, label %for.end
for.body: ; preds = %entry, %for.body
%i.035 = phi i32 [ %add18, %for.body ], [ %m, %entry ]
%arrayidx = getelementptr inbounds i32, i32* %B, i32 %i.035
%0 = load i32, i32* %arrayidx, align 4
%mul = shl nsw i32 %0, 2
%arrayidx2 = getelementptr inbounds i32, i32* %A, i32 %i.035
store i32 %mul, i32* %arrayidx2, align 4
%add3 = add nsw i32 %i.035, 1
%arrayidx4 = getelementptr inbounds i32, i32* %B, i32 %add3
%1 = load i32, i32* %arrayidx4, align 4
%mul5 = shl nsw i32 %1, 2
%arrayidx7 = getelementptr inbounds i32, i32* %A, i32 %add3
store i32 %mul5, i32* %arrayidx7, align 4
%add8 = add nsw i32 %i.035, 2
%arrayidx9 = getelementptr inbounds i32, i32* %B, i32 %add8
%2 = load i32, i32* %arrayidx9, align 4
%mul10 = shl nsw i32 %2, 2
%arrayidx12 = getelementptr inbounds i32, i32* %A, i32 %add8
store i32 %mul10, i32* %arrayidx12, align 4
%add13 = add nsw i32 %i.035, 3
%arrayidx14 = getelementptr inbounds i32, i32* %B, i32 %add13
%3 = load i32, i32* %arrayidx14, align 4
%mul15 = shl nsw i32 %3, 2
%arrayidx17 = getelementptr inbounds i32, i32* %A, i32 %add13
store i32 %mul15, i32* %arrayidx17, align 4
%add18 = add nsw i32 %i.035, 4
%cmp = icmp slt i32 %add18, %n
br i1 %cmp, label %for.body, label %for.end
for.end: ; preds = %for.body, %entry
ret void
}
; CHECK-LABEL: @foo
; CHECK: for.body.preheader: ; preds = %entry
; CHECK: %0 = add i32 %n, -1
; CHECK: %1 = sub i32 %0, %m
; CHECK: %2 = lshr i32 %1, 2
; CHECK: %3 = shl i32 %2, 2
; CHECK: %4 = add i32 %m, %3
; CHECK: %5 = add i32 %4, 3
; CHECK: br label %for.body
; CHECK: for.body: ; preds = %for.body, %for.body.preheader
; CHECK: %indvar = phi i32 [ 0, %for.body.preheader ], [ %indvar.next, %for.body ]
; CHECK: %6 = add i32 %m, %indvar
; CHECK: %arrayidx = getelementptr inbounds i32, i32* %B, i32 %6
; CHECK: %7 = load i32, i32* %arrayidx, align 4
; CHECK: %mul = shl nsw i32 %7, 2
; CHECK: %arrayidx2 = getelementptr inbounds i32, i32* %A, i32 %6
; CHECK: store i32 %mul, i32* %arrayidx2, align 4
; CHECK: %indvar.next = add i32 %indvar, 1
; CHECK: %exitcond = icmp eq i32 %6, %5
; CHECK: br i1 %exitcond, label %for.end.loopexit, label %for.body
;void daxpy_ur(int n,float da,float *dx,float *dy)
; {
; int m = n % 4;
; for (int i = m; i < n; i = i + 4)
; {
; dy[i] = dy[i] + da*dx[i];
; dy[i+1] = dy[i+1] + da*dx[i+1];
; dy[i+2] = dy[i+2] + da*dx[i+2];
; dy[i+3] = dy[i+3] + da*dx[i+3];
; }
; }
define void @daxpy_ur(i32 %n, float %da, float* nocapture readonly %dx, float* nocapture %dy) {
entry:
%rem = srem i32 %n, 4
%cmp55 = icmp slt i32 %rem, %n
br i1 %cmp55, label %for.body, label %for.end
for.body: ; preds = %entry, %for.body
%i.056 = phi i32 [ %add27, %for.body ], [ %rem, %entry ]
%arrayidx = getelementptr inbounds float, float* %dy, i32 %i.056
%0 = load float, float* %arrayidx, align 4
%arrayidx1 = getelementptr inbounds float, float* %dx, i32 %i.056
%1 = load float, float* %arrayidx1, align 4
%mul = fmul float %1, %da
%add = fadd float %0, %mul
store float %add, float* %arrayidx, align 4
%add3 = add nsw i32 %i.056, 1
%arrayidx4 = getelementptr inbounds float, float* %dy, i32 %add3
%2 = load float, float* %arrayidx4, align 4
%arrayidx6 = getelementptr inbounds float, float* %dx, i32 %add3
%3 = load float, float* %arrayidx6, align 4
%mul7 = fmul float %3, %da
%add8 = fadd float %2, %mul7
store float %add8, float* %arrayidx4, align 4
%add11 = add nsw i32 %i.056, 2
%arrayidx12 = getelementptr inbounds float, float* %dy, i32 %add11
%4 = load float, float* %arrayidx12, align 4
%arrayidx14 = getelementptr inbounds float, float* %dx, i32 %add11
%5 = load float, float* %arrayidx14, align 4
%mul15 = fmul float %5, %da
%add16 = fadd float %4, %mul15
store float %add16, float* %arrayidx12, align 4
%add19 = add nsw i32 %i.056, 3
%arrayidx20 = getelementptr inbounds float, float* %dy, i32 %add19
%6 = load float, float* %arrayidx20, align 4
%arrayidx22 = getelementptr inbounds float, float* %dx, i32 %add19
%7 = load float, float* %arrayidx22, align 4
%mul23 = fmul float %7, %da
%add24 = fadd float %6, %mul23
store float %add24, float* %arrayidx20, align 4
%add27 = add nsw i32 %i.056, 4
%cmp = icmp slt i32 %add27, %n
br i1 %cmp, label %for.body, label %for.end
for.end: ; preds = %for.body, %entry
ret void
}
; CHECK-LABEL: @daxpy_ur
; CHECK: for.body.preheader:
; CHECK: %0 = add i32 %n, -1
; CHECK: %1 = sub i32 %0, %rem
; CHECK: %2 = lshr i32 %1, 2
; CHECK: %3 = shl i32 %2, 2
; CHECK: %4 = add i32 %rem, %3
; CHECK: %5 = add i32 %4, 3
; CHECK: br label %for.body
; CHECK: for.body:
; CHECK: %indvar = phi i32 [ 0, %for.body.preheader ], [ %indvar.next, %for.body ]
; CHECK: %6 = add i32 %rem, %indvar
; CHECK: %arrayidx = getelementptr inbounds float, float* %dy, i32 %6
; CHECK: %7 = load float, float* %arrayidx, align 4
; CHECK: %arrayidx1 = getelementptr inbounds float, float* %dx, i32 %6
; CHECK: %8 = load float, float* %arrayidx1, align 4
; CHECK: %mul = fmul float %8, %da
; CHECK: %add = fadd float %7, %mul
; CHECK: store float %add, float* %arrayidx, align 4
; CHECK: %indvar.next = add i32 %indvar, 1
; CHECK: %exitcond = icmp eq i32 %6, %5
; CHECK: br i1 %exitcond, label %for.end.loopexit, label %for.body

View File

@ -1,81 +0,0 @@
; RUN: opt -S -loop-reroll %s | FileCheck %s
target triple = "aarch64--linux-gnu"
define i32 @test(i32* readonly %buf, i32* readnone %end) #0 {
entry:
%cmp.9 = icmp eq i32* %buf, %end
br i1 %cmp.9, label %while.end, label %while.body.preheader
while.body.preheader:
br label %while.body
while.body:
;CHECK-LABEL: while.body:
;CHECK-NEXT: %indvar = phi i64 [ %indvar.next, %while.body ], [ 0, %while.body.preheader ]
;CHECK-NEXT: %S.011 = phi i32 [ %add, %while.body ], [ undef, %while.body.preheader ]
;CHECK-NEXT: %scevgep = getelementptr i32, i32* %buf, i64 %indvar
;CHECK-NEXT: %4 = load i32, i32* %scevgep, align 4
;CHECK-NEXT: %add = add nsw i32 %4, %S.011
;CHECK-NEXT: %indvar.next = add i64 %indvar, 1
;CHECK-NEXT: %exitcond = icmp eq i32* %scevgep, %scevgep5
;CHECK-NEXT: br i1 %exitcond, label %while.end.loopexit, label %while.body
%S.011 = phi i32 [ %add2, %while.body ], [ undef, %while.body.preheader ]
%buf.addr.010 = phi i32* [ %add.ptr, %while.body ], [ %buf, %while.body.preheader ]
%0 = load i32, i32* %buf.addr.010, align 4
%add = add nsw i32 %0, %S.011
%arrayidx1 = getelementptr inbounds i32, i32* %buf.addr.010, i64 1
%1 = load i32, i32* %arrayidx1, align 4
%add2 = add nsw i32 %add, %1
%add.ptr = getelementptr inbounds i32, i32* %buf.addr.010, i64 2
%cmp = icmp eq i32* %add.ptr, %end
br i1 %cmp, label %while.end.loopexit, label %while.body
while.end.loopexit:
%add2.lcssa = phi i32 [ %add2, %while.body ]
br label %while.end
while.end:
%S.0.lcssa = phi i32 [ undef, %entry ], [ %add2.lcssa, %while.end.loopexit ]
ret i32 %S.0.lcssa
}
define i32 @test2(i32* readonly %buf, i32* readnone %end) #0 {
entry:
%cmp.9 = icmp eq i32* %buf, %end
br i1 %cmp.9, label %while.end, label %while.body.preheader
while.body.preheader:
br label %while.body
while.body:
;CHECK-LABEL: while.body:
;CHECK-NEXT: %indvar = phi i64 [ %indvar.next, %while.body ], [ 0, %while.body.preheader ]
;CHECK-NEXT: %S.011 = phi i32 [ %add, %while.body ], [ undef, %while.body.preheader ]
;CHECK-NEXT: %4 = mul i64 %indvar, -1
;CHECK-NEXT: %scevgep = getelementptr i32, i32* %buf, i64 %4
;CHECK-NEXT: %5 = load i32, i32* %scevgep, align 4
;CHECK-NEXT: %add = add nsw i32 %5, %S.011
;CHECK-NEXT: %indvar.next = add i64 %indvar, 1
;CHECK-NEXT: %exitcond = icmp eq i32* %scevgep, %scevgep5
;CHECK-NEXT: br i1 %exitcond, label %while.end.loopexit, label %while.body
%S.011 = phi i32 [ %add2, %while.body ], [ undef, %while.body.preheader ]
%buf.addr.010 = phi i32* [ %add.ptr, %while.body ], [ %buf, %while.body.preheader ]
%0 = load i32, i32* %buf.addr.010, align 4
%add = add nsw i32 %0, %S.011
%arrayidx1 = getelementptr inbounds i32, i32* %buf.addr.010, i64 -1
%1 = load i32, i32* %arrayidx1, align 4
%add2 = add nsw i32 %add, %1
%add.ptr = getelementptr inbounds i32, i32* %buf.addr.010, i64 -2
%cmp = icmp eq i32* %add.ptr, %end
br i1 %cmp, label %while.end.loopexit, label %while.body
while.end.loopexit:
%add2.lcssa = phi i32 [ %add2, %while.body ]
br label %while.end
while.end:
%S.0.lcssa = phi i32 [ undef, %entry ], [ %add2.lcssa, %while.end.loopexit ]
ret i32 %S.0.lcssa
}

View File

@ -1,132 +0,0 @@
; RUN: opt < %s -loop-reroll -S | FileCheck %s
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
define i32 @foo(i32* nocapture readonly %x) #0 {
entry:
br label %for.body
for.body: ; preds = %entry, %for.body
%indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
%r.029 = phi i32 [ 0, %entry ], [ %add12, %for.body ]
%arrayidx = getelementptr inbounds i32, i32* %x, i64 %indvars.iv
%0 = load i32, i32* %arrayidx, align 4
%add = add nsw i32 %0, %r.029
%1 = or i64 %indvars.iv, 1
%arrayidx3 = getelementptr inbounds i32, i32* %x, i64 %1
%2 = load i32, i32* %arrayidx3, align 4
%add4 = add nsw i32 %add, %2
%3 = or i64 %indvars.iv, 2
%arrayidx7 = getelementptr inbounds i32, i32* %x, i64 %3
%4 = load i32, i32* %arrayidx7, align 4
%add8 = add nsw i32 %add4, %4
%5 = or i64 %indvars.iv, 3
%arrayidx11 = getelementptr inbounds i32, i32* %x, i64 %5
%6 = load i32, i32* %arrayidx11, align 4
%add12 = add nsw i32 %add8, %6
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 4
%7 = trunc i64 %indvars.iv.next to i32
%cmp = icmp slt i32 %7, 400
br i1 %cmp, label %for.body, label %for.end
; CHECK-LABEL: @foo
; CHECK: for.body:
; CHECK: %indvar = phi i64 [ %indvar.next, %for.body ], [ 0, %entry ]
; CHECK: %r.029 = phi i32 [ 0, %entry ], [ %add, %for.body ]
; CHECK: %arrayidx = getelementptr inbounds i32, i32* %x, i64 %indvar
; CHECK: %0 = load i32, i32* %arrayidx, align 4
; CHECK: %add = add nsw i32 %0, %r.029
; CHECK: %indvar.next = add i64 %indvar, 1
; CHECK: %exitcond = icmp eq i64 %indvar, 399
; CHECK: br i1 %exitcond, label %for.end, label %for.body
; CHECK: ret
for.end: ; preds = %for.body
ret i32 %add12
}
define float @bar(float* nocapture readonly %x) #0 {
entry:
br label %for.body
for.body: ; preds = %entry, %for.body
%indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
%r.029 = phi float [ 0.0, %entry ], [ %add12, %for.body ]
%arrayidx = getelementptr inbounds float, float* %x, i64 %indvars.iv
%0 = load float, float* %arrayidx, align 4
%add = fadd float %0, %r.029
%1 = or i64 %indvars.iv, 1
%arrayidx3 = getelementptr inbounds float, float* %x, i64 %1
%2 = load float, float* %arrayidx3, align 4
%add4 = fadd float %add, %2
%3 = or i64 %indvars.iv, 2
%arrayidx7 = getelementptr inbounds float, float* %x, i64 %3
%4 = load float, float* %arrayidx7, align 4
%add8 = fadd float %add4, %4
%5 = or i64 %indvars.iv, 3
%arrayidx11 = getelementptr inbounds float, float* %x, i64 %5
%6 = load float, float* %arrayidx11, align 4
%add12 = fadd float %add8, %6
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 4
%7 = trunc i64 %indvars.iv.next to i32
%cmp = icmp slt i32 %7, 400
br i1 %cmp, label %for.body, label %for.end
; CHECK-LABEL: @bar
; CHECK: for.body:
; CHECK: %indvar = phi i64 [ %indvar.next, %for.body ], [ 0, %entry ]
; CHECK: %r.029 = phi float [ 0.000000e+00, %entry ], [ %add, %for.body ]
; CHECK: %arrayidx = getelementptr inbounds float, float* %x, i64 %indvar
; CHECK: %0 = load float, float* %arrayidx, align 4
; CHECK: %add = fadd float %0, %r.029
; CHECK: %indvar.next = add i64 %indvar, 1
; CHECK: %exitcond = icmp eq i64 %indvar, 399
; CHECK: br i1 %exitcond, label %for.end, label %for.body
; CHECK: ret
for.end: ; preds = %for.body
ret float %add12
}
define i32 @foo_unusedphi(i32* nocapture readonly %x) #0 {
entry:
br label %for.body
for.body: ; preds = %entry, %for.body
%indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
%r.029 = phi i32 [ 0, %entry ], [ %add12, %for.body ]
%arrayidx = getelementptr inbounds i32, i32* %x, i64 %indvars.iv
%0 = load i32, i32* %arrayidx, align 4
%add = add nsw i32 %0, %0
%1 = or i64 %indvars.iv, 1
%arrayidx3 = getelementptr inbounds i32, i32* %x, i64 %1
%2 = load i32, i32* %arrayidx3, align 4
%add4 = add nsw i32 %add, %2
%3 = or i64 %indvars.iv, 2
%arrayidx7 = getelementptr inbounds i32, i32* %x, i64 %3
%4 = load i32, i32* %arrayidx7, align 4
%add8 = add nsw i32 %add4, %4
%5 = or i64 %indvars.iv, 3
%arrayidx11 = getelementptr inbounds i32, i32* %x, i64 %5
%6 = load i32, i32* %arrayidx11, align 4
%add12 = add nsw i32 %add8, %6
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 4
%7 = trunc i64 %indvars.iv.next to i32
%cmp = icmp slt i32 %7, 400
br i1 %cmp, label %for.body, label %for.end
; CHECK-LABEL: @foo_unusedphi
; The above is just testing for a crash - no specific output expected.
; CHECK: ret
for.end: ; preds = %for.body
ret i32 %add12
}
attributes #0 = { nounwind readonly uwtable }

View File

@ -1,138 +0,0 @@
;RUN: opt < %s -loop-reroll -S | FileCheck %s
;void foo(float * restrict a, float * restrict b, int n) {
; for(int i = 0; i < n; i+=4) {
; a[i] = b[i];
; a[i+1] = b[i+1];
; a[i+2] = b[i+2];
; a[i+3] = b[i+3];
; }
;}
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
target triple = "armv4t--linux-gnueabi"
; Function Attrs: nounwind
define void @foo(float* noalias nocapture %a, float* noalias nocapture readonly %b, i32 %n) #0 !dbg !4 {
entry:
;CHECK-LABEL: @foo
tail call void @llvm.dbg.value(metadata float* %a, metadata !12, metadata !22), !dbg !23
tail call void @llvm.dbg.value(metadata float* %b, metadata !13, metadata !22), !dbg !24
tail call void @llvm.dbg.value(metadata i32 %n, metadata !14, metadata !22), !dbg !25
tail call void @llvm.dbg.value(metadata i32 0, metadata !15, metadata !22), !dbg !26
%cmp.30 = icmp sgt i32 %n, 0, !dbg !27
br i1 %cmp.30, label %for.body.preheader, label %for.cond.cleanup, !dbg !29
for.body.preheader: ; preds = %entry
br label %for.body, !dbg !30
for.cond.cleanup.loopexit: ; preds = %for.body
br label %for.cond.cleanup, !dbg !32
for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry
ret void, !dbg !32
for.body: ; preds = %for.body.preheader, %for.body
;CHECK: for.body:
;CHECK: %indvar = phi i32 [ %indvar.next, %for.body ], [ 0, {{.*}} ]
;CHECK: load
;CHECK: store
;CHECK-NOT: load
;CHECK-NOT: store
;CHECK: call void @llvm.dbg.value
;CHECK: %indvar.next = add i32 %indvar, 1
;CHECK: icmp eq i32 %indvar
%i.031 = phi i32 [ %add13, %for.body ], [ 0, %for.body.preheader ]
%arrayidx = getelementptr inbounds float, float* %b, i32 %i.031, !dbg !30
%0 = bitcast float* %arrayidx to i32*, !dbg !30
%1 = load i32, i32* %0, align 4, !dbg !30, !tbaa !33
%arrayidx1 = getelementptr inbounds float, float* %a, i32 %i.031, !dbg !37
%2 = bitcast float* %arrayidx1 to i32*, !dbg !38
store i32 %1, i32* %2, align 4, !dbg !38, !tbaa !33
%add = or i32 %i.031, 1, !dbg !39
%arrayidx2 = getelementptr inbounds float, float* %b, i32 %add, !dbg !40
%3 = bitcast float* %arrayidx2 to i32*, !dbg !40
%4 = load i32, i32* %3, align 4, !dbg !40, !tbaa !33
%arrayidx4 = getelementptr inbounds float, float* %a, i32 %add, !dbg !41
%5 = bitcast float* %arrayidx4 to i32*, !dbg !42
store i32 %4, i32* %5, align 4, !dbg !42, !tbaa !33
%add5 = or i32 %i.031, 2, !dbg !43
%arrayidx6 = getelementptr inbounds float, float* %b, i32 %add5, !dbg !44
%6 = bitcast float* %arrayidx6 to i32*, !dbg !44
%7 = load i32, i32* %6, align 4, !dbg !44, !tbaa !33
%arrayidx8 = getelementptr inbounds float, float* %a, i32 %add5, !dbg !45
%8 = bitcast float* %arrayidx8 to i32*, !dbg !46
store i32 %7, i32* %8, align 4, !dbg !46, !tbaa !33
%add9 = or i32 %i.031, 3, !dbg !47
%arrayidx10 = getelementptr inbounds float, float* %b, i32 %add9, !dbg !48
%9 = bitcast float* %arrayidx10 to i32*, !dbg !48
%10 = load i32, i32* %9, align 4, !dbg !48, !tbaa !33
%arrayidx12 = getelementptr inbounds float, float* %a, i32 %add9, !dbg !49
%11 = bitcast float* %arrayidx12 to i32*, !dbg !50
store i32 %10, i32* %11, align 4, !dbg !50, !tbaa !33
%add13 = add nuw nsw i32 %i.031, 4, !dbg !51
tail call void @llvm.dbg.value(metadata i32 %add13, metadata !15, metadata !22), !dbg !26
%cmp = icmp slt i32 %add13, %n, !dbg !27
br i1 %cmp, label %for.body, label %for.cond.cleanup.loopexit, !dbg !29
}
; Function Attrs: nounwind readnone
declare void @llvm.dbg.value(metadata, metadata, metadata) #1
attributes #0 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="arm7tdmi" "target-features"="+strict-align" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { nounwind readnone }
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!17, !18, !19, !20}
!llvm.ident = !{!21}
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.8.0 (http://llvm.org/git/clang.git b1fbc23058e7fa1cdd954ab97ba84f1c549c9879) (http://llvm.org/git/llvm.git 054da58c5398a721d4dab7af63d7de8d7a1e1a1c)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
!1 = !DIFile(filename: "test.c", directory: "/home/weimingz/llvm-build/release/community-tip")
!2 = !{}
!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !11)
!5 = !DISubroutineType(types: !6)
!6 = !{null, !7, !7, !10}
!7 = !DIDerivedType(tag: DW_TAG_restrict_type, baseType: !8)
!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 32, align: 32)
!9 = !DIBasicType(name: "float", size: 32, align: 32, encoding: DW_ATE_float)
!10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
!11 = !{!12, !13, !14, !15}
!12 = !DILocalVariable(name: "a", arg: 1, scope: !4, file: !1, line: 1, type: !7)
!13 = !DILocalVariable(name: "b", arg: 2, scope: !4, file: !1, line: 1, type: !7)
!14 = !DILocalVariable(name: "n", arg: 3, scope: !4, file: !1, line: 1, type: !10)
!15 = !DILocalVariable(name: "i", scope: !16, file: !1, line: 2, type: !10)
!16 = distinct !DILexicalBlock(scope: !4, file: !1, line: 2, column: 3)
!17 = !{i32 2, !"Dwarf Version", i32 4}
!18 = !{i32 2, !"Debug Info Version", i32 3}
!19 = !{i32 1, !"wchar_size", i32 4}
!20 = !{i32 1, !"min_enum_size", i32 4}
!21 = !{!"clang version 3.8.0 (http://llvm.org/git/clang.git b1fbc23058e7fa1cdd954ab97ba84f1c549c9879) (http://llvm.org/git/llvm.git 054da58c5398a721d4dab7af63d7de8d7a1e1a1c)"}
!22 = !DIExpression()
!23 = !DILocation(line: 1, column: 27, scope: !4)
!24 = !DILocation(line: 1, column: 47, scope: !4)
!25 = !DILocation(line: 1, column: 54, scope: !4)
!26 = !DILocation(line: 2, column: 11, scope: !16)
!27 = !DILocation(line: 2, column: 20, scope: !28)
!28 = distinct !DILexicalBlock(scope: !16, file: !1, line: 2, column: 3)
!29 = !DILocation(line: 2, column: 3, scope: !16)
!30 = !DILocation(line: 3, column: 12, scope: !31)
!31 = distinct !DILexicalBlock(scope: !28, file: !1, line: 2, column: 31)
!32 = !DILocation(line: 8, column: 1, scope: !4)
!33 = !{!34, !34, i64 0}
!34 = !{!"float", !35, i64 0}
!35 = !{!"omnipotent char", !36, i64 0}
!36 = !{!"Simple C/C++ TBAA"}
!37 = !DILocation(line: 3, column: 5, scope: !31)
!38 = !DILocation(line: 3, column: 10, scope: !31)
!39 = !DILocation(line: 4, column: 17, scope: !31)
!40 = !DILocation(line: 4, column: 14, scope: !31)
!41 = !DILocation(line: 4, column: 5, scope: !31)
!42 = !DILocation(line: 4, column: 12, scope: !31)
!43 = !DILocation(line: 5, column: 17, scope: !31)
!44 = !DILocation(line: 5, column: 14, scope: !31)
!45 = !DILocation(line: 5, column: 5, scope: !31)
!46 = !DILocation(line: 5, column: 12, scope: !31)
!47 = !DILocation(line: 6, column: 17, scope: !31)
!48 = !DILocation(line: 6, column: 14, scope: !31)
!49 = !DILocation(line: 6, column: 5, scope: !31)
!50 = !DILocation(line: 6, column: 12, scope: !31)
!51 = !DILocation(line: 2, column: 26, scope: !28)