1; RUN: opt -S -loop-rotate -verify-memoryssa < %s | FileCheck %s 2; RUN: opt -S -passes='require<targetir>,require<assumptions>,loop(loop-rotate)' < %s | FileCheck %s 3; RUN: opt -S -passes='require<targetir>,require<assumptions>,loop(loop-rotate)' -verify-memoryssa < %s | FileCheck %s 4 5target 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" 6target triple = "x86_64-unknown-linux-gnu" 7 8declare void @g(i32*) 9 10define void @test_02(i32* nocapture %_pA) nounwind ssp { 11; CHECK-LABEL: @test_02( 12; CHECK: entry: 13; CHECK: tail call void @llvm.experimental.noalias.scope.decl(metadata !2) 14; CHECK: store i32 42, i32* %_pA, align 16, !alias.scope !2 15; CHECK: for.body: 16; CHECK: tail call void @llvm.experimental.noalias.scope.decl(metadata !5) 17; CHECK: store i32 0, i32* %arrayidx, align 16, !noalias !5 18; CHECK: tail call void @llvm.experimental.noalias.scope.decl(metadata !7) 19; CHECK: store i32 42, i32* %_pA, align 16, !alias.scope !7 20; CHECK: for.end: 21 22entry: 23 %array = alloca [20 x i32], align 16 24 br label %for.cond 25 26for.cond: ; preds = %for.body, %entry 27 %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ] 28 tail call void @llvm.experimental.noalias.scope.decl(metadata !2) 29 store i32 42, i32* %_pA, align 16, !alias.scope !2 30 %cmp = icmp slt i32 %i.0, 100 31 %arrayidx = getelementptr inbounds [20 x i32], [20 x i32]* %array, i64 0, i64 0 32 br i1 %cmp, label %for.body, label %for.end 33 34for.body: ; preds = %for.cond 35 store i32 0, i32* %arrayidx, align 16, !noalias !2 36 %inc = add nsw i32 %i.0, 1 37 br label %for.cond 38 39for.end: ; preds = %for.cond 40 %arrayidx.lcssa = phi i32* [ %arrayidx, %for.cond ] 41 call void @g(i32* %arrayidx.lcssa) nounwind 42 ret void 43} 44 45define void @test_03(i32* nocapture %_pA) nounwind ssp { 46; CHECK-LABEL: @test_03( 47; CHECK: entry: 48; CHECK: for.body: 49; CHECK: tail call void @llvm.experimental.noalias.scope.decl(metadata !5) 50; CHECK: store i32 42, i32* %_pA, align 16, !alias.scope !5 51; CHECK: store i32 0, i32* %arrayidx, align 16, !noalias !5 52; CHECK: for.end: 53 54entry: 55 %array = alloca [20 x i32], align 16 56 br label %for.cond 57 58for.cond: ; preds = %for.body, %entry 59 %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ] 60 %cmp = icmp slt i32 %i.0, 100 61 %arrayidx = getelementptr inbounds [20 x i32], [20 x i32]* %array, i64 0, i64 0 62 br i1 %cmp, label %for.body, label %for.end 63 64for.body: ; preds = %for.cond 65 tail call void @llvm.experimental.noalias.scope.decl(metadata !2) 66 store i32 42, i32* %_pA, align 16, !alias.scope !2 67 store i32 0, i32* %arrayidx, align 16, !noalias !2 68 %inc = add nsw i32 %i.0, 1 69 br label %for.cond 70 71for.end: ; preds = %for.cond 72 %arrayidx.lcssa = phi i32* [ %arrayidx, %for.cond ] 73 call void @g(i32* %arrayidx.lcssa) nounwind 74 ret void 75} 76 77define void @test_04(i32* nocapture %_pA) nounwind ssp { 78; CHECK-LABEL: @test_04( 79; CHECK: entry: 80; CHECK: tail call void @llvm.experimental.noalias.scope.decl(metadata !9) 81; CHECK: store i32 42, i32* %_pA, align 16, !alias.scope !9 82; CHECK: for.body: 83; CHECK: tail call void @llvm.experimental.noalias.scope.decl(metadata !5) 84; CHECK: store i32 0, i32* %arrayidx, align 16, !noalias !5 85; CHECK: store i32 43, i32* %_pA, align 16, !alias.scope !5 86; CHECK: tail call void @llvm.experimental.noalias.scope.decl(metadata !11) 87; CHECK: store i32 42, i32* %_pA, align 16, !alias.scope !11 88; CHECK: for.end: 89entry: 90 %array = alloca [20 x i32], align 16 91 br label %for.cond 92 93for.cond: ; preds = %for.body, %entry 94 %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ] 95 tail call void @llvm.experimental.noalias.scope.decl(metadata !2) 96 store i32 42, i32* %_pA, align 16, !alias.scope !2 97 %cmp = icmp slt i32 %i.0, 100 98 %arrayidx = getelementptr inbounds [20 x i32], [20 x i32]* %array, i64 0, i64 0 99 br i1 %cmp, label %for.body, label %for.end 100 101for.body: ; preds = %for.cond 102 store i32 0, i32* %arrayidx, align 16, !noalias !2 103 store i32 43, i32* %_pA, align 16, !alias.scope !2 104 %inc = add nsw i32 %i.0, 1 105 br label %for.cond 106 107for.end: ; preds = %for.cond 108 %arrayidx.lcssa = phi i32* [ %arrayidx, %for.cond ] 109 call void @g(i32* %arrayidx.lcssa) nounwind 110 ret void 111} 112 113define void @test_05(i32* nocapture %_pA) nounwind ssp { 114; CHECK-LABEL: @test_05( 115; CHECK: entry: 116; CHECK: tail call void @llvm.experimental.noalias.scope.decl(metadata !13) 117; CHECK: store i32 42, i32* %_pA, align 16, !alias.scope !13 118; CHECK: for.body: 119; CHECK: tail call void @llvm.experimental.noalias.scope.decl(metadata !5) 120; CHECK: store i32 0, i32* %arrayidx, align 16, !noalias !5 121; CHECK: store i32 43, i32* %_pA, align 16, !alias.scope !5 122; CHECK: tail call void @llvm.experimental.noalias.scope.decl(metadata !15) 123; CHECK: store i32 42, i32* %_pA, align 16, !alias.scope !15 124; CHECK: for.end: 125; CHECK: store i32 44, i32* %_pA, align 16, !alias.scope !5 126 127entry: 128 %array = alloca [20 x i32], align 16 129 br label %for.cond 130 131for.cond: ; preds = %for.body, %entry 132 %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ] 133 tail call void @llvm.experimental.noalias.scope.decl(metadata !2) 134 store i32 42, i32* %_pA, align 16, !alias.scope !2 135 %cmp = icmp slt i32 %i.0, 100 136 %arrayidx = getelementptr inbounds [20 x i32], [20 x i32]* %array, i64 0, i64 0 137 br i1 %cmp, label %for.body, label %for.end 138 139for.body: ; preds = %for.cond 140 store i32 0, i32* %arrayidx, align 16, !noalias !2 141 store i32 43, i32* %_pA, align 16, !alias.scope !2 142 %inc = add nsw i32 %i.0, 1 143 br label %for.cond 144 145for.end: ; preds = %for.cond 146 %arrayidx.lcssa = phi i32* [ %arrayidx, %for.cond ] 147 store i32 44, i32* %_pA, align 16, !alias.scope !2 148 call void @g(i32* %arrayidx.lcssa) nounwind 149 ret void 150} 151 152; Function Attrs: inaccessiblememonly nounwind 153declare void @llvm.experimental.noalias.scope.decl(metadata) #1 154 155attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } 156attributes #1 = { inaccessiblememonly nounwind } 157attributes #2 = { nounwind readnone speculatable } 158 159!llvm.module.flags = !{!0} 160!llvm.ident = !{!1} 161 162!0 = !{i32 1, !"wchar_size", i32 4} 163!1 = !{!"clang"} 164!2 = !{!3} 165!3 = distinct !{!3, !4, !"test_loop_rotate_XX: pA"} 166!4 = distinct !{!4, !"test_loop_rotate_XX"} 167 168; CHECK: !0 = !{i32 1, !"wchar_size", i32 4} 169; CHECK: !1 = !{!"clang"} 170; CHECK: !2 = !{!3} 171; CHECK: !3 = distinct !{!3, !4, !"test_loop_rotate_XX: pA:pre.rot"} 172; CHECK: !4 = distinct !{!4, !"test_loop_rotate_XX"} 173; CHECK: !5 = !{!6} 174; CHECK: !6 = distinct !{!6, !4, !"test_loop_rotate_XX: pA"} 175; CHECK: !7 = !{!8} 176; CHECK: !8 = distinct !{!8, !4, !"test_loop_rotate_XX: pA:h.rot"} 177; CHECK: !9 = !{!10} 178; CHECK: !10 = distinct !{!10, !4, !"test_loop_rotate_XX: pA:pre.rot"} 179; CHECK: !11 = !{!12} 180; CHECK: !12 = distinct !{!12, !4, !"test_loop_rotate_XX: pA:h.rot"} 181; CHECK: !13 = !{!14} 182; CHECK: !14 = distinct !{!14, !4, !"test_loop_rotate_XX: pA:pre.rot"} 183; CHECK: !15 = !{!16} 184; CHECK: !16 = distinct !{!16, !4, !"test_loop_rotate_XX: pA:h.rot"} 185