1; RUN: opt %loadPolly -S -polly-codegen \
2; RUN: -polly-invariant-load-hoisting=false < %s | FileCheck %s
3; RUN: opt %loadPolly -S -polly-codegen \
4; RUN: -polly-invariant-load-hoisting=true < %s | FileCheck %s
5;
6; Check that we generate valid code even if the load of cont_STACKPOINTER is
7; hoisted in one SCoP and used (through the phi node %tmp2).
8;
9; CHECK: polly.start
10; CHECK: polly.start
11;
12target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
13
14%struct1 = type { i32, %union1, %struct.2*, i32, i32 }
15%union1 = type { %struct.2* }
16%struct.2 = type { %struct.2*, i8* }
17
18@cont_STACKPOINTER = external global i32, align 4
19@cont_STACK = external global [1000 x i32], align 16
20
21define fastcc void @subs_InternIdcEq() {
22entry:
23  br label %if.else.i.i
24
25if.else.i.i:                                      ; preds = %entry
26  %tmp = load %struct1*, %struct1** undef, align 8
27  br label %while.body.i99.i.i
28
29while.body.i99.i.i:                               ; preds = %while.body.i99.i.i, %if.else.i.i
30  br i1 false, label %while.body.i99.i.i, label %while.end.i103.i.i
31
32while.end.i103.i.i:                               ; preds = %while.body.i99.i.i
33  %tmp1 = load i32, i32* @cont_STACKPOINTER, align 4
34  %dec.i.i102.i.i = add nsw i32 %tmp1, -1
35  br i1 false, label %cont_BackTrack.exit107.i.i, label %if.then.i106.i.i
36
37if.then.i106.i.i:                                 ; preds = %while.end.i103.i.i
38  br label %cont_BackTrack.exit107.i.i
39
40cont_BackTrack.exit107.i.i:                       ; preds = %if.then.i106.i.i, %while.end.i103.i.i
41  %tmp2 = phi i32 [ %dec.i.i102.i.i, %if.then.i106.i.i ], [ 0, %while.end.i103.i.i ]
42  %symbol.i.i.i = getelementptr inbounds %struct1, %struct1* %tmp, i64 0, i32 0
43  br i1 undef, label %land.lhs.true23.i.i, label %for.inc.i.i
44
45land.lhs.true23.i.i:                              ; preds = %cont_BackTrack.exit107.i.i
46  %idxprom.i.i57.i.i = sext i32 %tmp2 to i64
47  %arrayidx.i.i58.i.i = getelementptr inbounds [1000 x i32], [1000 x i32]* @cont_STACK, i64 0, i64 %idxprom.i.i57.i.i
48  store i32 undef, i32* %arrayidx.i.i58.i.i, align 4
49  br i1 false, label %if.then.i45.i.i, label %fol_Atom.exit47.i.i
50
51if.then.i45.i.i:                                  ; preds = %land.lhs.true23.i.i
52  br label %fol_Atom.exit47.i.i
53
54fol_Atom.exit47.i.i:                              ; preds = %if.then.i45.i.i, %land.lhs.true23.i.i
55  unreachable
56
57for.inc.i.i:                                      ; preds = %cont_BackTrack.exit107.i.i
58  br label %for.end.i.i
59
60for.end.i.i:                                      ; preds = %for.inc.i.i
61  ret void
62}
63