Post-ra LICM should take care not to hoist an instruction that would clobber a
[oota-llvm.git] / test / CodeGen / X86 / 2012-03-26-PostRALICMBug.ll
1 ; RUN: llc < %s -mtriple=x86_64-apple-darwin10 -stats |& \
2 ; RUN:   not grep {Number of machine instructions hoisted out of loops post regalloc}
3
4 ; rdar://11095580
5
6 %struct.ref_s = type { %union.color_sample, i16, i16 }
7 %union.color_sample = type { i64 }
8
9 @table = external global [3891 x i64]
10
11 declare i32 @foo()
12
13 define i32 @zarray(%struct.ref_s* nocapture %op) nounwind ssp {
14 entry:
15   %call = tail call i32 @foo()
16   %tmp = ashr i32 %call, 31
17   %0 = and i32 %tmp, 1396
18   %index9 = add i32 %0, 2397
19   indirectbr i8* undef, [label %return, label %if.end]
20
21 if.end:                                           ; preds = %entry
22   %size5 = getelementptr inbounds %struct.ref_s* %op, i64 0, i32 2
23   %tmp6 = load i16* %size5, align 2
24   %tobool1 = icmp eq i16 %tmp6, 0
25   %1 = select i1 %tobool1, i32 1396, i32 -1910
26   %index10 = add i32 %index9, %1
27   indirectbr i8* undef, [label %return, label %while.body.lr.ph]
28
29 while.body.lr.ph:                                 ; preds = %if.end
30   %refs = bitcast %struct.ref_s* %op to %struct.ref_s**
31   %tmp9 = load %struct.ref_s** %refs, align 8
32   %tmp4 = zext i16 %tmp6 to i64
33   %index13 = add i32 %index10, 1658
34   %2 = sext i32 %index13 to i64
35   %3 = getelementptr [3891 x i64]* @table, i64 0, i64 %2
36   %blockaddress14 = load i64* %3, align 8
37   %4 = inttoptr i64 %blockaddress14 to i8*
38   indirectbr i8* %4, [label %while.body]
39
40 while.body:                                       ; preds = %while.body, %while.body.lr.ph
41   %index7 = phi i32 [ %index15, %while.body ], [ %index13, %while.body.lr.ph ]
42   %indvar = phi i64 [ %indvar.next, %while.body ], [ 0, %while.body.lr.ph ]
43   %type_attrs = getelementptr %struct.ref_s* %tmp9, i64 %indvar, i32 1
44   store i16 32, i16* %type_attrs, align 2
45   %indvar.next = add i64 %indvar, 1
46   %exitcond5 = icmp eq i64 %indvar.next, %tmp4
47   %tmp7 = select i1 %exitcond5, i32 1648, i32 0
48   %index15 = add i32 %index7, %tmp7
49   %tmp8 = select i1 %exitcond5, i64 13, i64 0
50   %5 = sext i32 %index15 to i64
51   %6 = getelementptr [3891 x i64]* @table, i64 0, i64 %5
52   %blockaddress16 = load i64* %6, align 8
53   %7 = inttoptr i64 %blockaddress16 to i8*
54   indirectbr i8* %7, [label %return, label %while.body]
55
56 return:                                           ; preds = %while.body, %if.end, %entry
57   %retval.0 = phi i32 [ %call, %entry ], [ 0, %if.end ], [ 0, %while.body ]
58   ret i32 %retval.0
59 }