blob: 36f55476fed23c13b526d6e516fad2f4e6024b7b [file] [log] [blame]
rahulana-quice1f056f2024-05-24 20:09:341; RUN: opt %loadNPMPolly -polly-allow-nonaffine '-passes=polly-dce,print<polly-ast>' -disable-output < %s | FileCheck %s
Tobias Grosser780ce0f2014-07-11 07:12:102;
3; void f(int *A) {
4; for (int i = 0; i < 1024; i++)
Tobias Grossera6085692015-06-23 20:55:055; S1: A[bar(i)] = i;
Tobias Grosser780ce0f2014-07-11 07:12:106; for (int i = 0; i < 1024; i++)
Tobias Grosserf4daf342014-08-16 09:08:557; S2: A[i2] = i;
Tobias Grosser780ce0f2014-07-11 07:12:108; }
9
Tobias Grosserc2920ff2014-07-14 08:32:0110; We unfortunately do need to execute all iterations of S1, as we do not know
11; the size of A and as a result S1 may write for example to A[1024], which
12; is not overwritten by S2.
Tobias Grosser780ce0f2014-07-11 07:12:1013
Tobias Grosser808cd692015-07-14 09:33:1314; CHECK: for (int c0 = 0; c0 <= 1023; c0 += 1)
15; CHECK: Stmt_S1(c0);
16; CHECK: for (int c0 = 0; c0 <= 1023; c0 += 1)
17; CHECK: Stmt_S2(c0);
Tobias Grosser780ce0f2014-07-11 07:12:1018
Tobias Grosserf4daf342014-08-16 09:08:5519target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-n32-S64"
Tobias Grosser780ce0f2014-07-11 07:12:1020
Tobias Grossera6085692015-06-23 20:55:0521declare i32 @bar(i32) #1
22
Nikita Popovb3324992023-01-17 09:12:0223define void @f(ptr %A) {
Tobias Grosser780ce0f2014-07-11 07:12:1024entry:
25 br label %for.cond
26
Tobias Grosserf4daf342014-08-16 09:08:5527for.cond:
Tobias Grosser780ce0f2014-07-11 07:12:1028 %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
Tobias Grosserf4daf342014-08-16 09:08:5529 %exitcond = icmp ne i32 %i.0, 1024
30 br i1 %exitcond, label %S1, label %next
Tobias Grosser780ce0f2014-07-11 07:12:1031
Tobias Grosserf4daf342014-08-16 09:08:5532S1:
Tobias Grossera6085692015-06-23 20:55:0533 %nonaff = call i32 @bar(i32 %i.0)
Nikita Popovb3324992023-01-17 09:12:0234 %arrayidx = getelementptr inbounds i32, ptr %A, i32 %nonaff
35 store i32 %i.0, ptr %arrayidx, align 4
Tobias Grosser780ce0f2014-07-11 07:12:1036 br label %for.inc
37
Tobias Grosserf4daf342014-08-16 09:08:5538for.inc:
Tobias Grosser780ce0f2014-07-11 07:12:1039 %inc = add nsw i32 %i.0, 1
40 br label %for.cond
41
Tobias Grosserf4daf342014-08-16 09:08:5542next:
43 br label %for.cond.2
Tobias Grosserc2920ff2014-07-14 08:32:0144
Tobias Grosserf4daf342014-08-16 09:08:5545for.cond.2:
46 %i.2 = phi i32 [ 0, %next ], [ %inc.2, %for.inc.2 ]
47 %exitcond.2 = icmp ne i32 %i.2, 1024
48 br i1 %exitcond.2, label %S2, label %for.end
Tobias Grosser780ce0f2014-07-11 07:12:1049
Tobias Grosserf4daf342014-08-16 09:08:5550S2:
Nikita Popovb3324992023-01-17 09:12:0251 %arrayidx.2 = getelementptr inbounds i32, ptr %A, i32 %i.2
52 store i32 %i.2, ptr %arrayidx.2, align 4
Tobias Grosserf4daf342014-08-16 09:08:5553 br label %for.inc.2
Tobias Grosser780ce0f2014-07-11 07:12:1054
Tobias Grosserf4daf342014-08-16 09:08:5555for.inc.2:
56 %inc.2 = add nsw i32 %i.2, 1
57 br label %for.cond.2
Tobias Grosser780ce0f2014-07-11 07:12:1058
Tobias Grosserf4daf342014-08-16 09:08:5559for.end:
Tobias Grosser780ce0f2014-07-11 07:12:1060 ret void
61}
Tobias Grosserf4daf342014-08-16 09:08:5562
Tobias Grossera6085692015-06-23 20:55:0563attributes #1 = { nounwind readnone }
64