1 ; RUN: opt -S -basicaa -licm < %s | FileCheck %s
2 ; RUN: opt -aa-pipeline=basic-aa -passes='require<opt-remark-emit>,loop(licm)' -S %s | FileCheck %s
3 ; RUN: opt -S -basicaa -licm -enable-mssa-loop-dependency=true -verify-memoryssa < %s | FileCheck %s
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
7 declare void @f() nounwind
9 ; Don't hoist load past nounwind call.
10 define i32 @test1(i32* noalias nocapture readonly %a) nounwind uwtable {
11 ; CHECK-LABEL: @test1(
15 ; CHECK: tail call void @f()
16 ; CHECK-NEXT: load i32
18 %i.06 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
19 %x.05 = phi i32 [ 0, %entry ], [ %add, %for.body ]
20 tail call void @f() nounwind
21 %i1 = load i32, i32* %a, align 4
22 %add = add nsw i32 %i1, %x.05
23 %inc = add nuw nsw i32 %i.06, 1
24 %exitcond = icmp eq i32 %inc, 1000
25 br i1 %exitcond, label %for.cond.cleanup, label %for.body
31 ; Don't hoist division past nounwind call.
32 define i32 @test2(i32 %N, i32 %c) nounwind uwtable {
33 ; CHECK-LABEL: @test2(
35 %cmp4 = icmp sgt i32 %N, 0
36 br i1 %cmp4, label %for.body, label %for.cond.cleanup
38 ; CHECK: tail call void @f()
39 ; CHECK-NEXT: sdiv i32
41 %i.05 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
42 tail call void @f() nounwind
44 %add = add i32 %i.05, 1
45 %inc = add i32 %add, %div
46 %cmp = icmp slt i32 %inc, %N
47 br i1 %cmp, label %for.body, label %for.cond.cleanup
53 ; Hoist a non-volatile load past volatile load.
54 define i32 @test3(i32* noalias nocapture readonly %a, i32* %v) nounwind uwtable {
55 ; CHECK-LABEL: @test3(
61 ; CHECK: load volatile i32
64 %i.06 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
65 %x.05 = phi i32 [ 0, %entry ], [ %add, %for.body ]
66 %xxx = load volatile i32, i32* %v, align 4
67 %i1 = load i32, i32* %a, align 4
68 %add = add nsw i32 %i1, %x.05
69 %inc = add nuw nsw i32 %i.06, 1
70 %exitcond = icmp eq i32 %inc, 1000
71 br i1 %exitcond, label %for.cond.cleanup, label %for.body
77 ; Don't a volatile load past volatile load.
78 define i32 @test4(i32* noalias nocapture readonly %a, i32* %v) nounwind uwtable {
79 ; CHECK-LABEL: @test4(
84 ; CHECK: load volatile i32
85 ; CHECK-NEXT: load volatile i32
87 %i.06 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
88 %x.05 = phi i32 [ 0, %entry ], [ %add, %for.body ]
89 %xxx = load volatile i32, i32* %v, align 4
90 %i1 = load volatile i32, i32* %a, align 4
91 %add = add nsw i32 %i1, %x.05
92 %inc = add nuw nsw i32 %i.06, 1
93 %exitcond = icmp eq i32 %inc, 1000
94 br i1 %exitcond, label %for.cond.cleanup, label %for.body