1;RUN: opt < %s -loop-reroll -S | FileCheck %s 2;void foo(float * restrict a, float * restrict b, int n) { 3; for(int i = 0; i < n; i+=4) { 4; a[i] = b[i]; 5; a[i+1] = b[i+1]; 6; a[i+2] = b[i+2]; 7; a[i+3] = b[i+3]; 8; } 9;} 10target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" 11target triple = "armv4t--linux-gnueabi" 12 13; Function Attrs: nounwind 14define void @foo(float* noalias nocapture %a, float* noalias nocapture readonly %b, i32 %n) #0 !dbg !4 { 15entry: 16;CHECK-LABEL: @foo 17 18 tail call void @llvm.dbg.value(metadata float* %a, i64 0, metadata !12, metadata !22), !dbg !23 19 tail call void @llvm.dbg.value(metadata float* %b, i64 0, metadata !13, metadata !22), !dbg !24 20 tail call void @llvm.dbg.value(metadata i32 %n, i64 0, metadata !14, metadata !22), !dbg !25 21 tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !15, metadata !22), !dbg !26 22 %cmp.30 = icmp sgt i32 %n, 0, !dbg !27 23 br i1 %cmp.30, label %for.body.preheader, label %for.cond.cleanup, !dbg !29 24 25for.body.preheader: ; preds = %entry 26 br label %for.body, !dbg !30 27 28for.cond.cleanup.loopexit: ; preds = %for.body 29 br label %for.cond.cleanup, !dbg !32 30 31for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry 32 ret void, !dbg !32 33 34for.body: ; preds = %for.body.preheader, %for.body 35;CHECK: for.body: 36;CHECK: %indvar = phi i32 [ %indvar.next, %for.body ], [ 0, {{.*}} ] 37;CHECK: load 38;CHECK: store 39;CHECK-NOT: load 40;CHECK-NOT: store 41;CHECK: call void @llvm.dbg.value 42;CHECK: %indvar.next = add i32 %indvar, 1 43;CHECK: icmp eq i32 %indvar 44 %i.031 = phi i32 [ %add13, %for.body ], [ 0, %for.body.preheader ] 45 %arrayidx = getelementptr inbounds float, float* %b, i32 %i.031, !dbg !30 46 %0 = bitcast float* %arrayidx to i32*, !dbg !30 47 %1 = load i32, i32* %0, align 4, !dbg !30, !tbaa !33 48 %arrayidx1 = getelementptr inbounds float, float* %a, i32 %i.031, !dbg !37 49 %2 = bitcast float* %arrayidx1 to i32*, !dbg !38 50 store i32 %1, i32* %2, align 4, !dbg !38, !tbaa !33 51 %add = or i32 %i.031, 1, !dbg !39 52 %arrayidx2 = getelementptr inbounds float, float* %b, i32 %add, !dbg !40 53 %3 = bitcast float* %arrayidx2 to i32*, !dbg !40 54 %4 = load i32, i32* %3, align 4, !dbg !40, !tbaa !33 55 %arrayidx4 = getelementptr inbounds float, float* %a, i32 %add, !dbg !41 56 %5 = bitcast float* %arrayidx4 to i32*, !dbg !42 57 store i32 %4, i32* %5, align 4, !dbg !42, !tbaa !33 58 %add5 = or i32 %i.031, 2, !dbg !43 59 %arrayidx6 = getelementptr inbounds float, float* %b, i32 %add5, !dbg !44 60 %6 = bitcast float* %arrayidx6 to i32*, !dbg !44 61 %7 = load i32, i32* %6, align 4, !dbg !44, !tbaa !33 62 %arrayidx8 = getelementptr inbounds float, float* %a, i32 %add5, !dbg !45 63 %8 = bitcast float* %arrayidx8 to i32*, !dbg !46 64 store i32 %7, i32* %8, align 4, !dbg !46, !tbaa !33 65 %add9 = or i32 %i.031, 3, !dbg !47 66 %arrayidx10 = getelementptr inbounds float, float* %b, i32 %add9, !dbg !48 67 %9 = bitcast float* %arrayidx10 to i32*, !dbg !48 68 %10 = load i32, i32* %9, align 4, !dbg !48, !tbaa !33 69 %arrayidx12 = getelementptr inbounds float, float* %a, i32 %add9, !dbg !49 70 %11 = bitcast float* %arrayidx12 to i32*, !dbg !50 71 store i32 %10, i32* %11, align 4, !dbg !50, !tbaa !33 72 %add13 = add nuw nsw i32 %i.031, 4, !dbg !51 73 tail call void @llvm.dbg.value(metadata i32 %add13, i64 0, metadata !15, metadata !22), !dbg !26 74 %cmp = icmp slt i32 %add13, %n, !dbg !27 75 br i1 %cmp, label %for.body, label %for.cond.cleanup.loopexit, !dbg !29 76} 77 78; Function Attrs: nounwind readnone 79declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1 80 81attributes #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" } 82attributes #1 = { nounwind readnone } 83 84!llvm.dbg.cu = !{!0} 85!llvm.module.flags = !{!17, !18, !19, !20} 86!llvm.ident = !{!21} 87 88!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: 1, enums: !2, subprograms: !3) 89!1 = !DIFile(filename: "test.c", directory: "/home/weimingz/llvm-build/release/community-tip") 90!2 = !{} 91!3 = !{!4} 92!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, variables: !11) 93!5 = !DISubroutineType(types: !6) 94!6 = !{null, !7, !7, !10} 95!7 = !DIDerivedType(tag: DW_TAG_restrict_type, baseType: !8) 96!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 32, align: 32) 97!9 = !DIBasicType(name: "float", size: 32, align: 32, encoding: DW_ATE_float) 98!10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 99!11 = !{!12, !13, !14, !15} 100!12 = !DILocalVariable(name: "a", arg: 1, scope: !4, file: !1, line: 1, type: !7) 101!13 = !DILocalVariable(name: "b", arg: 2, scope: !4, file: !1, line: 1, type: !7) 102!14 = !DILocalVariable(name: "n", arg: 3, scope: !4, file: !1, line: 1, type: !10) 103!15 = !DILocalVariable(name: "i", scope: !16, file: !1, line: 2, type: !10) 104!16 = distinct !DILexicalBlock(scope: !4, file: !1, line: 2, column: 3) 105!17 = !{i32 2, !"Dwarf Version", i32 4} 106!18 = !{i32 2, !"Debug Info Version", i32 3} 107!19 = !{i32 1, !"wchar_size", i32 4} 108!20 = !{i32 1, !"min_enum_size", i32 4} 109!21 = !{!"clang version 3.8.0 (http://llvm.org/git/clang.git b1fbc23058e7fa1cdd954ab97ba84f1c549c9879) (http://llvm.org/git/llvm.git 054da58c5398a721d4dab7af63d7de8d7a1e1a1c)"} 110!22 = !DIExpression() 111!23 = !DILocation(line: 1, column: 27, scope: !4) 112!24 = !DILocation(line: 1, column: 47, scope: !4) 113!25 = !DILocation(line: 1, column: 54, scope: !4) 114!26 = !DILocation(line: 2, column: 11, scope: !16) 115!27 = !DILocation(line: 2, column: 20, scope: !28) 116!28 = distinct !DILexicalBlock(scope: !16, file: !1, line: 2, column: 3) 117!29 = !DILocation(line: 2, column: 3, scope: !16) 118!30 = !DILocation(line: 3, column: 12, scope: !31) 119!31 = distinct !DILexicalBlock(scope: !28, file: !1, line: 2, column: 31) 120!32 = !DILocation(line: 8, column: 1, scope: !4) 121!33 = !{!34, !34, i64 0} 122!34 = !{!"float", !35, i64 0} 123!35 = !{!"omnipotent char", !36, i64 0} 124!36 = !{!"Simple C/C++ TBAA"} 125!37 = !DILocation(line: 3, column: 5, scope: !31) 126!38 = !DILocation(line: 3, column: 10, scope: !31) 127!39 = !DILocation(line: 4, column: 17, scope: !31) 128!40 = !DILocation(line: 4, column: 14, scope: !31) 129!41 = !DILocation(line: 4, column: 5, scope: !31) 130!42 = !DILocation(line: 4, column: 12, scope: !31) 131!43 = !DILocation(line: 5, column: 17, scope: !31) 132!44 = !DILocation(line: 5, column: 14, scope: !31) 133!45 = !DILocation(line: 5, column: 5, scope: !31) 134!46 = !DILocation(line: 5, column: 12, scope: !31) 135!47 = !DILocation(line: 6, column: 17, scope: !31) 136!48 = !DILocation(line: 6, column: 14, scope: !31) 137!49 = !DILocation(line: 6, column: 5, scope: !31) 138!50 = !DILocation(line: 6, column: 12, scope: !31) 139!51 = !DILocation(line: 2, column: 26, scope: !28) 140