1 ; RUN: opt -loop-reduce -S < %s | FileCheck %s
3 ; PR11356: likely wrong code bug
4 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
5 target triple = "x86_64-apple-darwin"
7 @g_66 = global [1 x i32] zeroinitializer, align 4
8 @g_775 = global i32 0, align 4
9 @g_752 = global i32 0, align 4
10 @g_3 = global i32 0, align 4
12 ; Ensure that %div.i.i.us is not hoisted.
14 ; CHECK: for.body.i.i.us:
15 ; CHECK: %div.i.i.i.us
17 define i32 @main() nounwind uwtable ssp {
19 %l_2 = alloca [1 x i32], align 4
20 %arrayidx = getelementptr inbounds [1 x i32], [1 x i32]* %l_2, i64 0, i64 0
21 store i32 0, i32* %arrayidx, align 4
22 %tmp = load i32, i32* @g_3, align 4
23 %idxprom = sext i32 %tmp to i64
24 %arrayidx1 = getelementptr inbounds [1 x i32], [1 x i32]* %l_2, i64 0, i64 %idxprom
25 %tmp1 = load i32, i32* %arrayidx1, align 4
26 %conv.i.i = and i32 %tmp1, 65535
27 %tobool.i.i.i = icmp ne i32 %tmp, 0
30 codeRepl.loopexit.us-lcssa: ; preds = %for.body.i.i, %codeRepl5
31 br label %codeRepl.loopexit
33 codeRepl.loopexit: ; preds = %codeRepl.loopexit.us-lcssa.us, %codeRepl.loopexit.us-lcssa
36 codeRepl: ; preds = %codeRepl.loopexit, %entry
37 br i1 %tobool.i.i.i, label %codeRepl.split.us, label %codeRepl.codeRepl.split_crit_edge
39 codeRepl.codeRepl.split_crit_edge: ; preds = %codeRepl
40 br label %codeRepl.split
42 codeRepl.split.us: ; preds = %codeRepl
43 br label %for.cond.i.i.us
45 for.cond.i.i.us: ; preds = %for.inc.i.i.us, %codeRepl.split.us
46 %tmp2 = phi i32 [ 0, %codeRepl.split.us ], [ %add.i.i.us, %for.inc.i.i.us ]
47 br label %codeRepl5.us
49 for.inc.i.i.us: ; preds = %for.body.i.i.us
50 %add.i.i.us = add nsw i32 %tmp2, 1
51 store i32 %add.i.i.us, i32* @g_752, align 4
52 br label %for.cond.i.i.us
54 for.body.i.i.us: ; preds = %codeRepl5.us
55 %div.i.i.i.us = udiv i32 1, %conv.i.i
56 %cmp5.i.i.us = icmp eq i32 %div.i.i.i.us, %tmp2
57 br i1 %cmp5.i.i.us, label %codeRepl.loopexit.us-lcssa.us, label %for.inc.i.i.us
59 codeRepl5.us: ; preds = %for.cond.i.i.us
60 br i1 true, label %codeRepl.loopexit.us-lcssa.us, label %for.body.i.i.us
62 codeRepl.loopexit.us-lcssa.us: ; preds = %codeRepl5.us, %for.body.i.i.us
63 br label %codeRepl.loopexit
65 codeRepl.split: ; preds = %codeRepl.codeRepl.split_crit_edge
66 br label %for.cond.i.i
68 for.cond.i.i: ; preds = %for.inc.i.i, %codeRepl.split
69 %tmp3 = phi i32 [ 0, %codeRepl.split ], [ %add.i.i, %for.inc.i.i ]
72 codeRepl5: ; preds = %for.cond.i.i
73 br i1 true, label %codeRepl.loopexit.us-lcssa, label %for.body.i.i
75 for.body.i.i: ; preds = %codeRepl5
76 %cmp5.i.i = icmp eq i32 0, %tmp3
77 br i1 %cmp5.i.i, label %codeRepl.loopexit.us-lcssa, label %for.inc.i.i
79 for.inc.i.i: ; preds = %for.body.i.i
80 %add.i.i = add nsw i32 %tmp3, 1
81 store i32 %add.i.i, i32* @g_752, align 4
82 br label %for.cond.i.i
84 func_4.exit: ; No predecessors!