1 ; RUN: llc < %s -mtriple=x86_64-apple-macosx -disable-lsr -post-RA-scheduler=1 -break-anti-dependencies=critical | FileCheck %s
3 ; In PR20020, the critical anti-dependency breaker algorithm mistakenly
4 ; changes the register operands of an 'xorl %eax, %eax' to 'xorl %ecx, %ecx'
5 ; and then immediately reloads %rcx with a value based on the wrong %rax
7 ; CHECK-NOT: xorl %ecx, %ecx
8 ; CHECK: leaq 1(%rax), %rcx
11 %struct.planet = type { double, double, double }
13 ; Function Attrs: nounwind ssp uwtable
14 define void @advance(i32 %nbodies, ptr nocapture %bodies) #0 {
16 %cmp4 = icmp sgt i32 %nbodies, 0
17 br i1 %cmp4, label %for.body.preheader, label %for.end38
19 for.body.preheader: ; preds = %entry
20 %gep = getelementptr %struct.planet, ptr %bodies, i64 1, i32 1
21 %0 = add i32 %nbodies, -1
24 for.body: ; preds = %for.body.preheader, %for.inc20
25 %iv19 = phi i32 [ %0, %for.body.preheader ], [ %iv.next, %for.inc20 ]
26 %iv = phi ptr [ %gep, %for.body.preheader ], [ %gep14, %for.inc20 ]
27 %iv9 = phi i64 [ %iv.next10, %for.inc20 ], [ 0, %for.body.preheader ]
28 %iv.next10 = add nuw nsw i64 %iv9, 1
29 %1 = trunc i64 %iv.next10 to i32
30 %cmp22 = icmp slt i32 %1, %nbodies
31 br i1 %cmp22, label %for.body3.lr.ph, label %for.inc20
33 for.body3.lr.ph: ; preds = %for.body
34 %x = getelementptr inbounds %struct.planet, ptr %bodies, i64 %iv9, i32 0
35 %y = getelementptr inbounds %struct.planet, ptr %bodies, i64 %iv9, i32 1
36 %vx = getelementptr inbounds %struct.planet, ptr %bodies, i64 %iv9, i32 2
39 for.body3: ; preds = %for.body3, %for.body3.lr.ph
40 %iv20 = phi i32 [ %iv.next21, %for.body3 ], [ %iv19, %for.body3.lr.ph ]
41 %iv15 = phi ptr [ %gep16, %for.body3 ], [ %iv, %for.body3.lr.ph ]
42 %2 = load double, ptr %x, align 8
43 %gep18 = getelementptr double, ptr %iv15, i64 -1
44 %3 = load double, ptr %gep18, align 8
45 %sub = fsub double %2, %3
46 %4 = load double, ptr %y, align 8
47 %5 = load double, ptr %iv15, align 8
48 %sub8 = fsub double %4, %5
49 %add10 = fadd double %sub, %sub8
50 %call = tail call double @sqrt(double %sub8) #2
51 store double %add10, ptr %vx, align 8
52 %gep16 = getelementptr %struct.planet, ptr %iv15, i64 1
53 %iv.next21 = add i32 %iv20, -1
54 %exitcond = icmp eq i32 %iv.next21, 0
55 br i1 %exitcond, label %for.inc20, label %for.body3
57 for.inc20: ; preds = %for.body3, %for.body
58 %lftr.wideiv11 = trunc i64 %iv.next10 to i32
59 %gep14 = getelementptr %struct.planet, ptr %iv, i64 1
60 %iv.next = add i32 %iv19, -1
61 %exitcond12 = icmp eq i32 %lftr.wideiv11, %nbodies
62 br i1 %exitcond12, label %for.end38, label %for.body
64 for.end38: ; preds = %for.inc20, %entry
68 ; Function Attrs: nounwind
69 declare double @sqrt(double) #1
71 attributes #0 = { "frame-pointer"="non-leaf" }