Fix Polly
[polly-mirror.git] / test / DependenceInfo / reduction_multiple_reductions.ll
blobb838d78ed05a480326df870a3f018e4f1ca421e3
1 ; RUN: opt %loadPolly -basicaa -polly-dependences -analyze < %s | FileCheck %s
3 ; Verify we do not have dependences between the if and the else clause
5 ; CHECK:      RAW dependences:
6 ; CHECK-NEXT:     {  }
7 ; CHECK-NEXT: WAR dependences:
8 ; CHECK-NEXT:     {  }
9 ; CHECK-NEXT: WAW dependences:
10 ; CHECK-NEXT:     {  }
11 ; CHECK-NEXT: Reduction dependences:
12 ; CHECK-NEXT:     { Stmt_if_then[i0] -> Stmt_if_then[1 + i0] : 0 <= i0 <= 510; Stmt_if_else[i0] -> Stmt_if_else[1 + i0] : 512 <= i0 <= 1022 }
14 ; void f(int *restrict sum, int *restrict prod) {
15 ;   for (int i = 0; i < 1024; i++)
16 ;     if (i < 512)
17 ;       *sum += i;
18 ;     else
19 ;       *prod *= i;
20 ; }
22 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-n32-S64"
24 define void @f(i32* noalias %sum, i32* noalias %prod)  {
25 entry:
26   br label %for.cond
28 for.cond:                                         ; preds = %for.inc, %entry
29   %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
30   %exitcond = icmp ne i32 %i.0, 1024
31   br i1 %exitcond, label %for.body, label %for.end
33 for.body:                                         ; preds = %for.cond
34   %cmp1 = icmp slt i32 %i.0, 512
35   br i1 %cmp1, label %if.then, label %if.else
37 if.then:                                          ; preds = %for.body
38   %tmp = load i32, i32* %sum, align 4
39   %add = add nsw i32 %tmp, %i.0
40   store i32 %add, i32* %sum, align 4
41   br label %if.end
43 if.else:                                          ; preds = %for.body
44   %tmp1 = load i32, i32* %prod, align 4
45   %mul = mul nsw i32 %tmp1, %i.0
46   store i32 %mul, i32* %prod, align 4
47   br label %if.end
49 if.end:                                           ; preds = %if.else, %if.then
50   br label %for.inc
52 for.inc:                                          ; preds = %if.end
53   %inc = add nsw i32 %i.0, 1
54   br label %for.cond
56 for.end:                                          ; preds = %for.cond
57   ret void