1 ; RUN: llc < %s -mtriple=i386-apple-macosx | FileCheck %s
2 ; PR11940: Do not optimize away movb %al, %ch
4 %struct.APInt = type { i64* }
6 declare noalias i8* @calloc(i32, i32) nounwind
8 define void @bug(%struct.APInt* noalias nocapture sret %agg.result, %struct.APInt* nocapture %this, i32 %rotateAmt) nounwind align 2 {
11 %call = tail call i8* @calloc(i32 1, i32 32)
12 %call.i = tail call i8* @calloc(i32 1, i32 32) nounwind
13 %0 = bitcast i8* %call.i to i64*
14 %rem.i = and i32 %rotateAmt, 63
15 %div.i = lshr i32 %rotateAmt, 6
16 %cmp.i = icmp eq i32 %rem.i, 0
17 br i1 %cmp.i, label %for.cond.preheader.i, label %if.end.i
19 for.cond.preheader.i: ; preds = %entry
20 %sub.i = sub i32 4, %div.i
21 %cmp23.i = icmp eq i32 %div.i, 4
22 br i1 %cmp23.i, label %for.body9.lr.ph.i, label %for.body.lr.ph.i
24 for.body.lr.ph.i: ; preds = %for.cond.preheader.i
25 %pVal.i = getelementptr inbounds %struct.APInt* %this, i32 0, i32 0
26 %.pre5.i = load i64** %pVal.i, align 4
29 for.body.i: ; preds = %for.body.i, %for.body.lr.ph.i
30 %i.04.i = phi i32 [ 0, %for.body.lr.ph.i ], [ %inc.i, %for.body.i ]
31 %add.i = add i32 %i.04.i, %div.i
32 %arrayidx.i = getelementptr inbounds i64* %.pre5.i, i32 %add.i
33 %1 = load i64* %arrayidx.i, align 4
34 %arrayidx3.i = getelementptr inbounds i64* %0, i32 %i.04.i
35 store i64 %1, i64* %arrayidx3.i, align 4
36 %inc.i = add i32 %i.04.i, 1
37 %cmp2.i = icmp ult i32 %inc.i, %sub.i
38 br i1 %cmp2.i, label %for.body.i, label %if.end.i
40 if.end.i: ; preds = %for.body.i, %entry
41 %cmp81.i = icmp eq i32 %div.i, 3
42 br i1 %cmp81.i, label %_ZNK5APInt4lshrEj.exit, label %for.body9.lr.ph.i
44 for.body9.lr.ph.i: ; preds = %if.end.i, %for.cond.preheader.i
45 %sub58.i = sub i32 3, %div.i
46 %pVal11.i = getelementptr inbounds %struct.APInt* %this, i32 0, i32 0
47 %sh_prom.i = zext i32 %rem.i to i64
48 %sub17.i = sub i32 64, %rem.i
49 %sh_prom18.i = zext i32 %sub17.i to i64
50 %.pre.i = load i64** %pVal11.i, align 4
53 for.body9.i: ; preds = %for.body9.i, %for.body9.lr.ph.i
55 ; CHECK: movb %al, %ch
56 %i6.02.i = phi i32 [ 0, %for.body9.lr.ph.i ], [ %inc21.i, %for.body9.i ]
57 %add10.i = add i32 %i6.02.i, %div.i
58 %arrayidx12.i = getelementptr inbounds i64* %.pre.i, i32 %add10.i
59 %2 = load i64* %arrayidx12.i, align 4
60 %shr.i = lshr i64 %2, %sh_prom.i
61 %add14.i = add i32 %add10.i, 1
62 %arrayidx16.i = getelementptr inbounds i64* %.pre.i, i32 %add14.i
63 %3 = load i64* %arrayidx16.i, align 4
64 %shl.i = shl i64 %3, %sh_prom18.i
65 %or.i = or i64 %shl.i, %shr.i
66 %arrayidx19.i = getelementptr inbounds i64* %0, i32 %i6.02.i
67 store i64 %or.i, i64* %arrayidx19.i, align 4
68 %inc21.i = add i32 %i6.02.i, 1
69 %cmp8.i = icmp ult i32 %inc21.i, %sub58.i
70 br i1 %cmp8.i, label %for.body9.i, label %_ZNK5APInt4lshrEj.exit
72 _ZNK5APInt4lshrEj.exit: ; preds = %for.body9.i, %if.end.i
73 %call.i1 = tail call i8* @calloc(i32 1, i32 32) nounwind
74 %4 = getelementptr inbounds %struct.APInt* %agg.result, i32 0, i32 0
75 store i64* %0, i64** %4, align 4