62 lines · plain
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=O22; 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=O33; 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=Os4; 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=Oz5 6; Check that Os and Oz are optimized like O2, not like O3. To easily highlight7; the behavior, we artificially disable unrolling for anything but O3 by setting8; the default threshold to 0.9 10; O3: for.inner.111; O2-NOT: for.inner.112; Os-NOT: for.inner.113; Oz-NOT: for.inner.114 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, ptr noalias nocapture %A, ptr noalias nocapture readonly %B) #0 {18entry:19 %cmp = icmp ne i32 %J, 020 %cmpJ = icmp ne i32 %I, 021 %or.cond = and i1 %cmp, %cmpJ22 br i1 %or.cond, label %for.outer.preheader, label %for.end23 24for.outer.preheader:25 br label %for.outer26 27for.outer:28 %i = phi i32 [ %add8, %for.latch ], [ 0, %for.outer.preheader ]29 br label %for.inner30 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, ptr %B, i32 %j35 %0 = load i32, ptr %arrayidx, align 4, !tbaa !536 %add = add i32 %0, %sum37 %inc = add nuw i32 %j, 138 %exitcond = icmp eq i32 %inc, %J39 br i1 %exitcond, label %for.latch, label %for.inner40 41for.latch:42 %add.lcssa = phi i32 [ %add, %for.inner ]43 %arrayidx6 = getelementptr inbounds i32, ptr %A, i32 %i44 store i32 %add.lcssa, ptr %arrayidx6, align 4, !tbaa !545 %add8 = add nuw i32 %i, 146 %exitcond25 = icmp eq i32 %add8, %I47 br i1 %exitcond25, label %for.end.loopexit, label %for.outer48 49for.end.loopexit:50 br label %for.end51 52for.end:53 ret void54}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