1 ; RUN: opt %loadPolly -polly-codegen -polly-invariant-load-hoisting=true -S < %s | FileCheck %s
3 ; Verify the preloaded %tmp0 is stored and communicated in the same alloca.
4 ; In this case, we do not reload %ncol.load from the scalar stack slot, but
5 ; instead use directly the preloaded value stored in GlobalMap.
8 ; CHECK: %tmp0.preload.s2a = alloca i32
11 ; CHECK: %ncol.load = load i32, ptr @ncol
12 ; CHECK-NEXT: store i32 %ncol.load, ptr %tmp0.preload.s2a
14 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
16 @ncol = external global i32, align 4
18 define void @melt_data(ptr %data1, ptr %data2) {
22 entry.split: ; preds = %entry
23 %tmp0 = load i32, ptr @ncol, align 4
24 %tobool.2 = icmp eq i32 %tmp0, 0
25 br i1 %tobool.2, label %while.end, label %while.body.lr.ph
27 while.body.lr.ph: ; preds = %entry.split
30 while.body: ; preds = %while.body.lr.ph, %while.cond.backedge
31 %dec3.in = phi i32 [ %tmp0, %while.body.lr.ph ], [ %dec3, %while.cond.backedge ]
32 %dec3 = add nsw i32 %dec3.in, -1
33 %idxprom = sext i32 %dec3 to i64
34 %arrayidx = getelementptr inbounds i32, ptr %data1, i64 %idxprom
35 %tmp1 = load i32, ptr %arrayidx, align 4
36 %idxprom1 = sext i32 %dec3 to i64
37 %arrayidx2 = getelementptr inbounds i32, ptr %data2, i64 %idxprom1
38 %tmp2 = load i32, ptr %arrayidx2, align 4
39 %cmp = icmp sgt i32 %tmp1, %tmp2
40 br i1 %cmp, label %if.then, label %while.cond.backedge
42 if.then: ; preds = %while.body
43 %idxprom3 = sext i32 %dec3 to i64
44 %arrayidx4 = getelementptr inbounds i32, ptr %data2, i64 %idxprom3
45 %tmp3 = load i32, ptr %arrayidx4, align 4
46 %idxprom5 = sext i32 %dec3 to i64
47 %arrayidx6 = getelementptr inbounds i32, ptr %data1, i64 %idxprom5
48 store i32 %tmp3, ptr %arrayidx6, align 4
49 br label %while.cond.backedge
51 while.cond.backedge: ; preds = %if.then, %while.body
52 %tobool = icmp eq i32 %dec3, 0
53 br i1 %tobool, label %while.cond.while.end_crit_edge, label %while.body
55 while.cond.while.end_crit_edge: ; preds = %while.cond.backedge
58 while.end: ; preds = %while.cond.while.end_crit_edge, %entry.split