1; RUN: opt < %s -basicaa -licm -S | FileCheck %s 2 3; Make sure we don't hoist a conditionally-executed store out of the loop; 4; it would violate the concurrency memory model 5 6@g = common global i32 0, align 4 7 8define void @bar(i32 %n, i32 %b) nounwind uwtable ssp { 9entry: 10 br label %for.cond 11 12for.cond: ; preds = %for.inc, %entry 13 %i.0 = phi i32 [ 0, %entry ], [ %inc5, %for.inc ] 14 %cmp = icmp slt i32 %i.0, %n 15 br i1 %cmp, label %for.body, label %for.end 16 17for.body: ; preds = %for.cond 18 %tobool = icmp eq i32 %b, 0 19 br i1 %tobool, label %for.inc, label %if.then 20 21if.then: ; preds = %for.body 22 %tmp3 = load i32* @g, align 4 23 %inc = add nsw i32 %tmp3, 1 24 store i32 %inc, i32* @g, align 4 25 br label %for.inc 26 27; CHECK: load i32* 28; CHECK-NEXT: add 29; CHECK-NEXT: store i32 30 31for.inc: ; preds = %for.body, %if.then 32 %inc5 = add nsw i32 %i.0, 1 33 br label %for.cond 34 35for.end: ; preds = %for.cond 36 ret void 37} 38