xref: /llvm-project/polly/test/ScopInfo/zero_ext_of_truncate.ll (revision 5aafc6d58f3405662902cee006be11e599801b88)
1; RUN: opt %loadNPMPolly -polly-invariant-load-hoisting=true '-passes=print<polly-function-scops>' -disable-output < %s 2>&1 | FileCheck %s
2;
3;    void f(unsigned *restrict I, unsigned *restrict A, unsigned N, unsigned M) {
4;      for (unsigned i = 0; i < N; i++) {
5;        unsigned char V = *I;
6;        if (V < M)
7;          A[i]++;
8;      }
9;    }
10;
11; FIXME: The truncated value should be a parameter.
12; CHECK:         Assumed Context:
13; CHECK-NEXT:    [N, tmp, M] -> { : }
14; CHECK-NEXT:    Invalid Context:
15; CHECK-NEXT:    [N, tmp, M] -> { : N < 0 or (N > 0 and tmp >= 128) or (N > 0 and tmp < 0) or (N > 0 and M < 0) }
16;
17; CHECK:         Domain :=
18; CHECK-NEXT:    [N, tmp, M] -> { Stmt_if_then[i0] : tmp >= 0 and M > tmp and 0 <= i0 < N };
19;
20target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
21
22define void @f(ptr noalias %I, ptr noalias %A, i32 %N, i32 %M) {
23entry:
24  br label %for.cond
25
26for.cond:                                         ; preds = %for.inc, %entry
27  %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %entry ]
28  %lftr.wideiv = trunc i64 %indvars.iv to i32
29  %exitcond = icmp ne i32 %lftr.wideiv, %N
30  br i1 %exitcond, label %for.body, label %for.end
31
32for.body:                                         ; preds = %for.cond
33  %tmp = load i32, ptr %I, align 4
34  %conv1 = and i32 %tmp, 255
35  %cmp2 = icmp ult i32 %conv1, %M
36  br i1 %cmp2, label %if.then, label %if.end
37
38if.then:                                          ; preds = %for.body
39  %arrayidx = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
40  %tmp1 = load i32, ptr %arrayidx, align 4
41  %inc = add i32 %tmp1, 1
42  store i32 %inc, ptr %arrayidx, align 4
43  br label %if.end
44
45if.end:                                           ; preds = %if.then, %for.body
46  br label %for.inc
47
48for.inc:                                          ; preds = %if.end
49  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
50  br label %for.cond
51
52for.end:                                          ; preds = %for.cond
53  ret void
54}
55