1; RUN: opt < %s -S -passes="default<O2>" -unroll-runtime=true -enable-unroll-and-jam -unroll-threshold-default=0 -unroll-threshold-aggressive=300 | FileCheck %s -check-prefix=O2 2; RUN: opt < %s -S -passes="default<O3>" -unroll-runtime=true -enable-unroll-and-jam -unroll-threshold-default=0 -unroll-threshold-aggressive=300 | FileCheck %s -check-prefix=O3 3; RUN: opt < %s -S -passes="default<Os>" -unroll-runtime=true -enable-unroll-and-jam -unroll-threshold-default=0 -unroll-threshold-aggressive=300 | FileCheck %s -check-prefix=Os 4; RUN: opt < %s -S -passes="default<Oz>" -unroll-runtime=true -enable-unroll-and-jam -unroll-threshold-default=0 -unroll-threshold-aggressive=300 | FileCheck %s -check-prefix=Oz 5 6; Check that Os and Oz are optimized like O2, not like O3. To easily highlight 7; the behavior, we artificially disable unrolling for anything but O3 by setting 8; the default threshold to 0. 9 10; O3: for.inner.1 11; O2-NOT: for.inner.1 12; Os-NOT: for.inner.1 13; Oz-NOT: for.inner.1 14 15target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" 16 17define void @test1(i32 %I, i32 %J, i32* noalias nocapture %A, i32* noalias nocapture readonly %B) #0 { 18entry: 19 %cmp = icmp ne i32 %J, 0 20 %cmpJ = icmp ne i32 %I, 0 21 %or.cond = and i1 %cmp, %cmpJ 22 br i1 %or.cond, label %for.outer.preheader, label %for.end 23 24for.outer.preheader: 25 br label %for.outer 26 27for.outer: 28 %i = phi i32 [ %add8, %for.latch ], [ 0, %for.outer.preheader ] 29 br label %for.inner 30 31for.inner: 32 %j = phi i32 [ 0, %for.outer ], [ %inc, %for.inner ] 33 %sum = phi i32 [ 0, %for.outer ], [ %add, %for.inner ] 34 %arrayidx = getelementptr inbounds i32, i32* %B, i32 %j 35 %0 = load i32, i32* %arrayidx, align 4, !tbaa !5 36 %add = add i32 %0, %sum 37 %inc = add nuw i32 %j, 1 38 %exitcond = icmp eq i32 %inc, %J 39 br i1 %exitcond, label %for.latch, label %for.inner 40 41for.latch: 42 %add.lcssa = phi i32 [ %add, %for.inner ] 43 %arrayidx6 = getelementptr inbounds i32, i32* %A, i32 %i 44 store i32 %add.lcssa, i32* %arrayidx6, align 4, !tbaa !5 45 %add8 = add nuw i32 %i, 1 46 %exitcond25 = icmp eq i32 %add8, %I 47 br i1 %exitcond25, label %for.end.loopexit, label %for.outer 48 49for.end.loopexit: 50 br label %for.end 51 52for.end: 53 ret void 54} 55 56 57 58!5 = !{!6, !6, i64 0} 59!6 = !{!"int", !7, i64 0} 60!7 = !{!"omnipotent char", !8, i64 0} 61!8 = !{!"Simple C/C++ TBAA"} 62