Update Polly tests to handle explicitly typed gep changes in LLVM
[polly-mirror.git] / test / CodePreparation / single_loop_trivial_phi.ll
blobd2473216f62cea5981305b4e163874344869bf52
1 ; RUN: opt %loadPolly -polly-detect-unprofitable -S -polly-prepare < %s | FileCheck %s
2 ; ModuleID = 'single_loop_trivial_phi.ll'
4 ; int f(int *A, int N) {
5 ;   int i, sum = 0;
6 ;   for (i = 0; i < N; i++)
7 ;     sum += A[i];
8 ;   return sum;
9 ; }
10 ; ModuleID = 'stack-slots.ll'
11 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
12 target triple = "x86_64-unknown-linux-gnu"
14 ; Function Attrs: nounwind uwtable
15 define i32 @f(i32* %A, i32 %N) #0 {
16 entry:
17   %cmp1 = icmp sgt i32 %N, 0
18   br i1 %cmp1, label %for.inc.lr.ph, label %for.end
20 for.inc.lr.ph:                                    ; preds = %entry
21   %0 = zext i32 %N to i64
22   br label %for.inc
24 for.inc:                                          ; preds = %for.inc.lr.ph, %for.inc
25   %sum.03 = phi i32 [ 0, %for.inc.lr.ph ], [ %add, %for.inc ]
26   %indvars.iv2 = phi i64 [ 0, %for.inc.lr.ph ], [ %indvars.iv.next, %for.inc ]
27   %arrayidx = getelementptr i32, i32* %A, i64 %indvars.iv2
28   %tmp1 = load i32* %arrayidx, align 4
29   %add = add nsw i32 %tmp1, %sum.03
30   %indvars.iv.next = add nuw nsw i64 %indvars.iv2, 1
31   %exitcond = icmp ne i64 %indvars.iv.next, %0
32   br i1 %exitcond, label %for.inc, label %for.cond.for.end_crit_edge
34 for.cond.for.end_crit_edge:                       ; preds = %for.inc
35   %add.lcssa = phi i32 [ %add, %for.inc ]
36   br label %for.end
38 for.end:                                          ; preds = %for.cond.for.end_crit_edge, %entry
39   %sum.0.lcssa = phi i32 [ %add.lcssa, %for.cond.for.end_crit_edge ], [ 0, %entry ]
40   ret i32 %sum.0.lcssa
43 attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
45 ; Verify that only two allocas are created.
46 ; Both are needed for the %sum.0 PHI node and none should be created for the
47 ; %sum.0.lcssa PHI node
48 ; CHECK: alloca
49 ; CHECK: alloca
50 ; CHECK-NOT: alloca