Update Polly tests to handle explicitly typed gep changes in LLVM
[polly-mirror.git] / test / Isl / Ast / simple-run-time-condition.ll
blob7138f58d9ced7c2a12a10d1e25876aeb634cddc6
1 ; RUN: opt %loadPolly -polly-detect-unprofitable -polly-ast -analyze -polly-no-early-exit -polly-delinearize < %s | FileCheck %s
2 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"
3 target triple = "x86_64-unknown-linux-gnu"
5 ; void foo(long n, long m, int o, double A[n][m], long p, long q) {
7 ; if (o >= 0)
8 ;   for (long i = 0; i < n; i++)
9 ;     for (long j = 0; j < m; j++)
10 ;         A[i+p][j+q] = 1.0;
11 ; else
12 ;   for (long i = 0; i < n; i++)
13 ;     for (long j = 0; j < m; j++)
14 ;         A[i+p][j+q-100] = 1.0;
17 ; This test case is meant to verify that the run-time condition generated
18 ; for the delinearization is simplified such that conditions that would not
19 ; cause any code to be executed are not generated.
21 ; CHECK: if (
22 ; CHECK: ({{(q == 100 && o <= 0|o <= 0 && q == 100)}})
23 ; CHECK: ||
24 ; CHECK: ({{(q == 0 && o >= 1)|(o >= 1 && q == 0)}})
25 ; CHECK: )
27 ; CHECK:     if (o >= 1) {
28 ; CHECK:       for (int c1 = 0; c1 < n; c1 += 1)
29 ; CHECK:         for (int c2 = 0; c2 < m; c2 += 1)
30 ; CHECK:           Stmt_for_j(c1, c2);
31 ; CHECK:     } else
32 ; CHECK:       for (int c1 = 0; c1 < n; c1 += 1)
33 ; CHECK:         for (int c2 = 0; c2 < m; c2 += 1)
34 ; CHECK:           Stmt_for_j_1(c1, c2);
36 ; CHECK: else
37 ; CHECK:     {  /* original code */ }
39 define void @foo(i64 %n, i64 %m, i64 %o, double* %A, i64 %p, i64 %q) {
40 entry:
41   br label %cond
43 cond:
44   %cmp = icmp sgt i64 %o, 0
45   br i1 %cmp, label %for.i, label %for.i.1
47 for.i:
48   %i = phi i64 [ 0, %cond ], [ %i.inc, %for.i.inc ]
49   br label %for.j
51 for.j:
52   %j = phi i64 [ 0, %for.i ], [ %j.inc, %for.j.inc ]
53   %offset0 = add nsw i64 %i, %p
54   %subscript0 = mul i64 %offset0, %m
55   %offset1 = add nsw i64 %j, %q
56   %subscript1 = add i64 %offset1, %subscript0
57   %idx = getelementptr inbounds double, double* %A, i64 %subscript1
58   store double 1.0, double* %idx
59   br label %for.j.inc
61 for.j.inc:
62   %j.inc = add nsw i64 %j, 1
63   %j.exitcond = icmp eq i64 %j.inc, %m
64   br i1 %j.exitcond, label %for.i.inc, label %for.j
66 for.i.inc:
67   %i.inc = add nsw i64 %i, 1
68   %i.exitcond = icmp eq i64 %i.inc, %n
69   br i1 %i.exitcond, label %end, label %for.i
71 for.i.1:
72   %i.1 = phi i64 [ 0, %cond ], [ %i.inc.1, %for.i.inc.1 ]
73   br label %for.j.1
75 for.j.1:
76   %j.1 = phi i64 [ 0, %for.i.1 ], [ %j.inc.1, %for.j.inc.1 ]
77   %offset0.1 = add nsw i64 %i.1, %p
78   %subscript0.1 = mul i64 %offset0.1, %m
79   %offset1.1 = add nsw i64 %j.1, %q
80   %subscript1.1 = add i64 %offset1.1, %subscript0.1
81   %subscript1.2 = sub i64 %subscript1.1, 100
82   %idx.1 = getelementptr inbounds double, double* %A, i64 %subscript1.2
83   store double 1.0, double* %idx.1
84   br label %for.j.inc.1
86 for.j.inc.1:
87   %j.inc.1 = add nsw i64 %j.1, 1
88   %j.exitcond.1 = icmp eq i64 %j.inc.1, %m
89   br i1 %j.exitcond.1, label %for.i.inc.1, label %for.j.1
91 for.i.inc.1:
92   %i.inc.1 = add nsw i64 %i.1, 1
93   %i.exitcond.1 = icmp eq i64 %i.inc.1, %n
94   br i1 %i.exitcond.1, label %end, label %for.i.1
96 end:
97   ret void