1; RUN: opt %loadPolly -polly-codegen -S < %s | FileCheck %s
2;
3; This caused the code generation to generate invalid code as the same operand
4; of the PHI node in the non-affine region was synthesized at the wrong place.
5; Check we do not generate wrong code.
6;
7; CHECK: polly.start
8;
9; ModuleID = 'bugpoint-reduced-simplified.bc'
10target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
11
12@connected_passed = external global [256 x i8], align 16
13
14; Function Attrs: norecurse nounwind uwtable
15define void @InitializeZeroMasks() {
16entry:
17  br label %for.end20
18
19for.end20:                                        ; preds = %entry
20  br label %for.body24
21
22for.body24:                                       ; preds = %for.body61.preheader, %for.end20
23  %indvars.iv = phi i64 [ 0, %for.end20 ], [ %indvars.iv.next, %for.body61.preheader ]
24  %arrayidx26 = getelementptr inbounds [256 x i8], [256 x i8]* @connected_passed, i64 0, i64 %indvars.iv
25  store i8 0, i8* %arrayidx26, align 1
26  %0 = trunc i64 %indvars.iv to i32
27  br i1 false, label %for.inc56.4, label %if.then51
28
29if.then51:                                        ; preds = %for.inc56.5, %for.body24
30  %j.342.lcssa = phi i8 [ 7, %for.body24 ], [ %.mux, %for.inc56.5 ]
31  br label %for.body61.preheader
32
33for.body61.preheader:                             ; preds = %for.inc56.5, %if.then51
34  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
35  %exitcond = icmp eq i64 %indvars.iv.next, 256
36  br i1 %exitcond, label %for.end79, label %for.body24
37
38for.end79:                                        ; preds = %for.body61.preheader
39  ret void
40
41for.inc56.4:                                      ; preds = %for.body24
42  br label %for.inc56.5
43
44for.inc56.5:                                      ; preds = %for.inc56.4
45  %and49.6 = and i32 %0, 64
46  %brmerge = or i1 undef, undef
47  %and49.6.lobit = lshr exact i32 %and49.6, 6
48  %.mux = trunc i32 %and49.6.lobit to i8
49  br i1 %brmerge, label %if.then51, label %for.body61.preheader
50}
51