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