• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
2;
3; This checks that the no-wraps checks will be computed fast as some example
4; already showed huge slowdowns even though the inbounds and nsw flags were
5; all in place.
6;
7;    // Inspired by itrans8x8 in transform8x8.c from the ldecode benchmark.
8;    void fast(char *A, char N, char M) {
9;      for (char i = 0; i < 8; i++) {
10;        char  index0 = i + N;
11;        char  index1 = index0 * 16;
12;        char  index2 = index1 + M;
13;        A[(short)index2]++;
14;      }
15;    }
16;
17;    void slow(char *A, char N, char M) {
18;      for (char i = 0; i < 8; i++) {
19;        char  index0 = i + N;
20;        char  index1 = index0 * 16;
21;        short index2 = ((short)index1) + ((short)M);
22;        A[index2]++;
23;      }
24;    }
25;
26; CHECK: Function: fast
27; CHECK: Function: slow
28;
29target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
30
31define void @fast(i8* %A, i8 %N, i8 %M) {
32entry:
33  br label %for.cond
34
35for.cond:                                         ; preds = %for.inc, %entry
36  %indvars.iv = phi i8 [ %indvars.iv.next, %for.inc ], [ 0, %entry ]
37  %exitcond = icmp ne i8 %indvars.iv, 8
38  br i1 %exitcond, label %for.body, label %for.end
39
40for.body:                                         ; preds = %for.cond
41  %tmp3 = add nsw i8 %indvars.iv, %N
42  %mul = mul nsw i8 %tmp3, 16
43  %add2 = add nsw i8 %mul, %M
44  %add2ext = sext i8 %add2 to i16
45  %arrayidx = getelementptr inbounds i8, i8* %A, i16 %add2ext
46  %tmp4 = load i8, i8* %arrayidx, align 4
47  %inc = add nsw i8 %tmp4, 1
48  store i8 %inc, i8* %arrayidx, align 4
49  br label %for.inc
50
51for.inc:                                          ; preds = %for.body
52  %indvars.iv.next = add nuw nsw i8 %indvars.iv, 1
53  br label %for.cond
54
55for.end:                                          ; preds = %for.cond
56  ret void
57}
58
59define void @slow(i8* %A, i8 %N, i8 %M) {
60entry:
61  br label %for.cond
62
63for.cond:                                         ; preds = %for.inc, %entry
64  %indvars.iv = phi i8 [ %indvars.iv.next, %for.inc ], [ 0, %entry ]
65  %exitcond = icmp ne i8 %indvars.iv, 8
66  br i1 %exitcond, label %for.body, label %for.end
67
68for.body:                                         ; preds = %for.cond
69  %tmp3 = add nsw i8 %indvars.iv, %N
70  %mul = mul nsw i8 %tmp3, 16
71  %mulext = sext i8 %mul to i16
72  %Mext = sext i8 %M to i16
73  %add2 = add nsw i16 %mulext, %Mext
74  %arrayidx = getelementptr inbounds i8, i8* %A, i16 %add2
75  %tmp4 = load i8, i8* %arrayidx, align 4
76  %inc = add nsw i8 %tmp4, 1
77  store i8 %inc, i8* %arrayidx, align 4
78  br label %for.inc
79
80for.inc:                                          ; preds = %for.body
81  %indvars.iv.next = add nuw nsw i8 %indvars.iv, 1
82  br label %for.cond
83
84for.end:                                          ; preds = %for.cond
85  ret void
86}
87