xref: /llvm-project/polly/test/DeLICM/reduction_looprotate.ll (revision b332499a94df11870dfc7598645c59656deb933d)
15c028081SMichael Kruse; RUN: opt %loadPolly -polly-flatten-schedule -polly-print-delicm -disable-output < %s | FileCheck %s
25ae08c0eSMichael Kruse;
35ae08c0eSMichael Kruse;    void func(double *A) {
45ae08c0eSMichael Kruse;      for (int j = 0; j < 2; j += 1) { /* outer */
55ae08c0eSMichael Kruse;        for (int i = 0; i < 4; i += 1) { /* reduction */
65ae08c0eSMichael Kruse;          double phi = A[j];
75ae08c0eSMichael Kruse;          phi += 4.2;
85ae08c0eSMichael Kruse;          A[j] = phi;
95ae08c0eSMichael Kruse;        }
105ae08c0eSMichael Kruse;      }
115ae08c0eSMichael Kruse;    }
125ae08c0eSMichael Kruse;
135ae08c0eSMichael Kruse; There is nothing to do in this case. All accesses are in %body.
145ae08c0eSMichael Kruse;
15*b332499aSNikita Popovdefine void @func(ptr noalias nonnull %A) {
165ae08c0eSMichael Kruseentry:
175ae08c0eSMichael Kruse  br label %outer.preheader
185ae08c0eSMichael Kruse
195ae08c0eSMichael Kruseouter.preheader:
205ae08c0eSMichael Kruse  br label %outer.for
215ae08c0eSMichael Kruse
225ae08c0eSMichael Kruseouter.for:
235ae08c0eSMichael Kruse  %j = phi i32 [0, %outer.preheader], [%j.inc, %outer.inc]
245ae08c0eSMichael Kruse  %j.cmp = icmp slt i32 %j, 2
255ae08c0eSMichael Kruse  br i1 %j.cmp, label %reduction.preheader, label %outer.exit
265ae08c0eSMichael Kruse
275ae08c0eSMichael Kruse
285ae08c0eSMichael Kruse    reduction.preheader:
295ae08c0eSMichael Kruse      br label %reduction.for
305ae08c0eSMichael Kruse
315ae08c0eSMichael Kruse    reduction.for:
325ae08c0eSMichael Kruse      %i = phi i32 [0, %reduction.preheader], [%i.inc, %reduction.inc]
335ae08c0eSMichael Kruse      br label %body
345ae08c0eSMichael Kruse
355ae08c0eSMichael Kruse
365ae08c0eSMichael Kruse
375ae08c0eSMichael Kruse        body:
38*b332499aSNikita Popov          %A_idx = getelementptr inbounds double, ptr %A, i32 %j
39*b332499aSNikita Popov          %val = load double, ptr %A_idx
405ae08c0eSMichael Kruse          %add = fadd double %val, 4.2
41*b332499aSNikita Popov          store double %add, ptr %A_idx
425ae08c0eSMichael Kruse          br label %reduction.inc
435ae08c0eSMichael Kruse
445ae08c0eSMichael Kruse
455ae08c0eSMichael Kruse
465ae08c0eSMichael Kruse    reduction.inc:
475ae08c0eSMichael Kruse      %i.inc = add nuw nsw i32 %i, 1
485ae08c0eSMichael Kruse      %i.cmp = icmp slt i32 %i.inc, 4
495ae08c0eSMichael Kruse      br i1 %i.cmp, label %reduction.for, label %reduction.exit
505ae08c0eSMichael Kruse
515ae08c0eSMichael Kruse    reduction.exit:
525ae08c0eSMichael Kruse      br label %outer.inc
535ae08c0eSMichael Kruse
545ae08c0eSMichael Kruse
555ae08c0eSMichael Kruse
565ae08c0eSMichael Kruseouter.inc:
575ae08c0eSMichael Kruse  %j.inc = add nuw nsw i32 %j, 1
585ae08c0eSMichael Kruse  br label %outer.for
595ae08c0eSMichael Kruse
605ae08c0eSMichael Kruseouter.exit:
615ae08c0eSMichael Kruse  br label %return
625ae08c0eSMichael Kruse
635ae08c0eSMichael Krusereturn:
645ae08c0eSMichael Kruse  ret void
655ae08c0eSMichael Kruse}
665ae08c0eSMichael Kruse
675ae08c0eSMichael Kruse
685ae08c0eSMichael Kruse; CHECK: No modification has been made
69