Home | History | Annotate | Download | only in ScalarEvolution
      1 ; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s
      2 
      3 target 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"
      4 target triple = "x86_64-unknown-linux-gnu"
      5 
      6 @foo.a = internal constant [8 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7], align 16
      7 
      8 define i32 @foo() nounwind uwtable noinline {
      9 entry:
     10   br label %for.cond
     11 
     12 for.cond:                                         ; preds = %for.inc, %entry
     13   %sum.0 = phi i32 [ 0, %entry ], [ %add, %for.inc ]
     14 ; CHECK: --> %sum.0 Exits: 28
     15   %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
     16   %cmp = icmp ult i32 %i.0, 8
     17   br i1 %cmp, label %for.inc, label %for.end
     18 
     19 for.inc:                                          ; preds = %for.cond
     20   %idxprom = sext i32 %i.0 to i64
     21   %arrayidx = getelementptr inbounds [8 x i32]* @foo.a, i64 0, i64 %idxprom
     22   %0 = load i32* %arrayidx, align 4
     23   %add = add nsw i32 %sum.0, %0
     24   %inc = add nsw i32 %i.0, 1
     25   br label %for.cond
     26 
     27 for.end:                                          ; preds = %for.cond
     28   ret i32 %sum.0
     29 }
     30