1 ; RUN: opt -passes=mldst-motion -S < %s | FileCheck %s
2 ; RUN: opt -aa-pipeline=basic-aa -passes='require<memdep>',mldst-motion \
3 ; RUN: -S < %s | FileCheck %s
5 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
6 target triple = "x86_64-unknown-linux-gnu"
8 @r = common global i32 0, align 4
9 @s = common global i32 0, align 4
11 ; CHECK-LABEL: define void @test1(
12 define void @test1(i1 %cmp, ptr noalias %p) {
14 br i1 %cmp, label %if.then, label %if.else
16 if.then: ; preds = %entry
17 call void @may_exit() nounwind
18 %arrayidx = getelementptr inbounds i32, ptr %p, i64 1
19 %0 = load i32, ptr %arrayidx, align 4
20 store i32 %0, ptr @r, align 4
22 ; CHECK: call void @may_exit()
23 ; CHECK-NEXT: %[[gep:.*]] = getelementptr inbounds i32, ptr %p, i64 1
24 ; CHECK-NEXT: %[[load:.*]] = load i32, ptr %[[gep]], align 4
25 ; CHECK-NEXT: store i32 %[[load]], ptr @r, align 4
27 if.else: ; preds = %entry
28 %arrayidx1 = getelementptr inbounds i32, ptr %p, i64 1
29 %1 = load i32, ptr %arrayidx1, align 4
30 store i32 %1, ptr @s, align 4
33 if.end: ; preds = %if.else, %if.then
37 ; CHECK-LABEL: define void @test2(
38 define void @test2(i1 %cmp, ptr noalias %p) {
40 br i1 %cmp, label %if.then, label %if.else
42 if.then: ; preds = %entry
43 %arrayidx = getelementptr inbounds i32, ptr %p, i64 1
44 store i32 1, ptr %arrayidx, align 4
45 call void @may_throw()
46 ; CHECK: %[[gep:.*]] = getelementptr inbounds i32, ptr %p, i64 1
47 ; CHECK-NEXT: store i32 1, ptr %[[gep]], align 4
48 ; CHECK-NEXT: call void @may_throw()
51 if.else: ; preds = %entry
52 %arrayidx1 = getelementptr inbounds i32, ptr %p, i64 1
53 store i32 2, ptr %arrayidx1, align 4
56 if.end: ; preds = %if.else, %if.then
60 declare void @may_throw()
61 declare void @may_exit() nounwind