xref: /llvm-project/polly/test/ForwardOpTree/noforward_synthesizable_unknownit.ll (revision e1f056f692d869708c1898d9d65a69ac5584a0ed)
1; RUN: opt %loadNPMPolly '-passes=print<polly-optree>' -disable-output < %s | FileCheck %s -match-full-lines
2;
3; Do not try to forward %i.trunc, it is not synthesizable in %body.
4;
5define void @func(i32 %n, ptr noalias nonnull %A) {
6entry:
7  br label %for
8
9for:
10  %j = phi i32 [0, %entry], [%j.inc, %inc]
11  %j.cmp = icmp slt i32 %j, %n
12  %zero = sext i32 0 to i64
13  br i1 %j.cmp, label %inner.for, label %exit
14
15
16    ; This loop has some unusual properties:
17    ; * It has a known iteration count (8), therefore SCoP-compatible.
18    ; * %i.trunc is synthesizable within the loop ({1,+,1}<%while.body>).
19    ; * %i.trunc is not synthesizable outside of the loop, because its value is
20    ;   unknown when exiting.
21    ;   (should be 8, but ScalarEvolution currently seems unable to derive that)
22    ;
23    ; ScalarEvolution currently seems to not able to handle the %zero.
24    ; If it becomes more intelligent, there might be other such loop constructs.
25    inner.for:
26      %i = phi i64 [%zero, %for], [%i.inc, %inner.for]
27      %i.inc = add nuw nsw i64 %i, 1
28      %i.trunc = trunc i64 %i.inc to i32
29      %i.and = and i32 %i.trunc, 7
30      %inner.cond = icmp eq i32 %i.and, 0
31      br i1 %inner.cond, label %body, label %inner.for
32
33    body:
34      store i32 %i.trunc, ptr %A
35      br label %inc
36
37
38inc:
39  %j.inc = add nuw nsw i32 %j, 1
40  br label %for
41
42exit:
43  br label %return
44
45return:
46  ret void
47}
48
49
50; CHECK: ForwardOpTree executed, but did not modify anything
51