Home | History | Annotate | Download | only in LoopReroll
      1 ; RUN: opt -S  -loop-reroll   %s | FileCheck %s
      2 target triple = "aarch64--linux-gnu"
      3 @buf = global [16 x i8] c"\0A\0A\0A\0A\0A\0A\0A\0A\0A\0A\0A\0A\0A\0A\0A\0A", align 1
      4 
      5 define i32 @test1(i32 %len, i8* nocapture readonly %buf) #0 {
      6 entry:
      7   %cmp.13 = icmp sgt i32 %len, 1
      8   br i1 %cmp.13, label %while.body.lr.ph, label %while.end
      9 
     10 while.body.lr.ph:                                 ; preds = %entry
     11   br label %while.body
     12 
     13 while.body:
     14 ;CHECK-LABEL: while.body:
     15 ;CHECK-NEXT:    %indvar = phi i32 [ %indvar.next, %while.body ], [ 0, %while.body.lr.ph ]
     16 ;CHECK-NEXT:    %sum4.015 = phi i64 [ 0, %while.body.lr.ph ], [ %add, %while.body ]
     17 ;CHECK-NOT:     %sub5 = add nsw i32 %len.addr.014, -1
     18 ;CHECK-NOT:     %sub5 = add nsw i32 %len.addr.014, -2
     19 ;CHECK:    br i1 %exitcond, label %while.cond.while.end_crit_edge, label %while.body
     20 
     21   %sum4.015 = phi i64 [ 0, %while.body.lr.ph ], [ %add4, %while.body ]
     22   %len.addr.014 = phi i32 [ %len, %while.body.lr.ph ], [ %sub5, %while.body ]
     23   %idxprom = sext i32 %len.addr.014 to i64
     24   %arrayidx = getelementptr inbounds i8, i8* %buf, i64 %idxprom
     25   %0 = load i8, i8* %arrayidx, align 1
     26   %conv = zext i8 %0 to i64
     27   %add = add i64 %conv, %sum4.015
     28   %sub = add nsw i32 %len.addr.014, -1
     29   %idxprom1 = sext i32 %sub to i64
     30   %arrayidx2 = getelementptr inbounds i8, i8* %buf, i64 %idxprom1
     31   %1 = load i8, i8* %arrayidx2, align 1
     32   %conv3 = zext i8 %1 to i64
     33   %add4 = add i64 %add, %conv3
     34   %sub5 = add nsw i32 %len.addr.014, -2
     35   %cmp = icmp sgt i32 %sub5, 1
     36   br i1 %cmp, label %while.body, label %while.cond.while.end_crit_edge
     37 
     38 while.cond.while.end_crit_edge:                   ; preds = %while.body
     39   %add4.lcssa = phi i64 [ %add4, %while.body ]
     40   %phitmp = trunc i64 %add4.lcssa to i32
     41   br label %while.end
     42 
     43 while.end:                                        ; preds = %while.cond.while.end_crit_edge, %entry
     44   %sum4.0.lcssa = phi i32 [ %phitmp, %while.cond.while.end_crit_edge ], [ 0, %entry ]
     45   ret i32 %sum4.0.lcssa
     46   unreachable
     47 }
     48 
     49