15c028081SMichael Kruse; RUN: opt %loadPolly -polly-flatten-schedule -polly-delicm-overapproximate-writes=true -polly-delicm-compute-known=true -polly-print-delicm -disable-output < %s | FileCheck %s 227c010a2SMichael Kruse; 327c010a2SMichael Kruse; Verify that delicm can cope with never taken PHI incoming edges. 427c010a2SMichael Kruse; The edge %body -> %body_phi is never taken, hence the access MemoryKind::PHI, 527c010a2SMichael Kruse; WRITE in %body for %phi is never used. 627c010a2SMichael Kruse; When mapping %phi, the write's access relation is the empty set. 727c010a2SMichael Kruse; 827c010a2SMichael Kruse; void func(double *A) { 927c010a2SMichael Kruse; for (int j = 0; j < 2; j += 1) { /* outer */ 1027c010a2SMichael Kruse; for (int i = 0; i < 4; i += 1) { /* reduction */ 1127c010a2SMichael Kruse; double phi = 21.0; 1227c010a2SMichael Kruse; if (j < 10) // Tautology, since 0<=j<2 1327c010a2SMichael Kruse; phi = 42.0; 1427c010a2SMichael Kruse; } 1527c010a2SMichael Kruse; A[j] = phi; 1627c010a2SMichael Kruse; } 1727c010a2SMichael Kruse; } 1827c010a2SMichael Kruse; 19*b332499aSNikita Popovdefine void @func(ptr noalias nonnull %A, ptr noalias nonnull %dummy) { 2027c010a2SMichael Kruseentry: 2127c010a2SMichael Kruse br label %outer.preheader 2227c010a2SMichael Kruse 2327c010a2SMichael Kruseouter.preheader: 2427c010a2SMichael Kruse br label %outer.for 2527c010a2SMichael Kruse 2627c010a2SMichael Kruseouter.for: 2727c010a2SMichael Kruse %j = phi i32 [0, %outer.preheader], [%j.inc, %outer.inc] 2827c010a2SMichael Kruse %j.cmp = icmp slt i32 %j, 2 2927c010a2SMichael Kruse br i1 %j.cmp, label %reduction.preheader, label %outer.exit 3027c010a2SMichael Kruse 3127c010a2SMichael Kruse 3227c010a2SMichael Kruse reduction.preheader: 33*b332499aSNikita Popov %A_idx = getelementptr inbounds double, ptr %A, i32 %j 3427c010a2SMichael Kruse br label %reduction.for 3527c010a2SMichael Kruse 3627c010a2SMichael Kruse reduction.for: 3727c010a2SMichael Kruse %i = phi i32 [0, %reduction.preheader], [%i.inc, %reduction.inc] 3827c010a2SMichael Kruse br label %body 3927c010a2SMichael Kruse 4027c010a2SMichael Kruse 4127c010a2SMichael Kruse 4227c010a2SMichael Kruse body: 4327c010a2SMichael Kruse %cond = icmp slt i32 %j, 10 4427c010a2SMichael Kruse br i1 %cond, label %alwaystaken, label %body_phi 4527c010a2SMichael Kruse 4627c010a2SMichael Kruse alwaystaken: 47*b332499aSNikita Popov store double 0.0, ptr %dummy 4827c010a2SMichael Kruse br label %body_phi 4927c010a2SMichael Kruse 5027c010a2SMichael Kruse body_phi: 5127c010a2SMichael Kruse %phi = phi double [21.0, %body], [42.0, %alwaystaken] 5227c010a2SMichael Kruse br label %reduction.inc 5327c010a2SMichael Kruse 5427c010a2SMichael Kruse 5527c010a2SMichael Kruse 5627c010a2SMichael Kruse reduction.inc: 5727c010a2SMichael Kruse %i.inc = add nuw nsw i32 %i, 1 5827c010a2SMichael Kruse %i.cmp = icmp slt i32 %i.inc, 4 5927c010a2SMichael Kruse br i1 %i.cmp, label %reduction.for, label %reduction.exit 6027c010a2SMichael Kruse 6127c010a2SMichael Kruse reduction.exit: 62*b332499aSNikita Popov store double %phi, ptr %A_idx 6327c010a2SMichael Kruse br label %outer.inc 6427c010a2SMichael Kruse 6527c010a2SMichael Kruse 6627c010a2SMichael Kruseouter.inc: 6727c010a2SMichael Kruse %j.inc = add nuw nsw i32 %j, 1 6827c010a2SMichael Kruse br label %outer.for 6927c010a2SMichael Kruse 7027c010a2SMichael Kruseouter.exit: 7127c010a2SMichael Kruse br label %return 7227c010a2SMichael Kruse 7327c010a2SMichael Krusereturn: 7427c010a2SMichael Kruse ret void 7527c010a2SMichael Kruse} 7627c010a2SMichael Kruse 7727c010a2SMichael Kruse 7827c010a2SMichael Kruse; CHECK: Statistics { 7927c010a2SMichael Kruse; CHECK: PHI scalars mapped: 1 8027c010a2SMichael Kruse; CHECK: } 81