1 ; RUN: opt -S -gvn-hoist < %s | FileCheck %s
3 ; Check that the stores are not hoisted: it is invalid to hoist stores if they
4 ; are not executed on all paths. In this testcase, there are paths in the loop
5 ; that do not execute the stores.
7 ; CHECK-LABEL: define i32 @main
12 @a = global i32 0, align 4
18 for.cond: ; preds = %for.inc5, %entry
19 %0 = load i32, i32* @a, align 4
20 %cmp = icmp slt i32 %0, 1
21 br i1 %cmp, label %for.cond1, label %for.end7
23 for.cond1: ; preds = %for.cond, %for.inc
24 %1 = load i32, i32* @a, align 4
25 %cmp2 = icmp slt i32 %1, 1
26 br i1 %cmp2, label %for.body3, label %for.inc5
28 for.body3: ; preds = %for.cond1
29 %tobool = icmp ne i32 %1, 0
30 br i1 %tobool, label %if.then, label %for.inc
32 if.then: ; preds = %for.body3
33 %inc = add nsw i32 %1, 1
34 store i32 %inc, i32* @a, align 4
37 for.inc: ; preds = %for.body3, %if.then
38 %2 = load i32, i32* @a, align 4
39 %inc4 = add nsw i32 %2, 1
40 store i32 %inc4, i32* @a, align 4
43 for.inc5: ; preds = %for.cond1
44 %inc6 = add nsw i32 %1, 1
45 store i32 %inc6, i32* @a, align 4
48 for.end7: ; preds = %for.cond