• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -basicaa -memdep -mldst-motion -S < %s | FileCheck %s
2; RUN: opt -aa-pipeline=basic-aa -passes='require<memdep>',mldst-motion \
3; RUN:   -S < %s | FileCheck %s
4
5target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
6target triple = "x86_64-unknown-linux-gnu"
7
8@r = common global i32 0, align 4
9@s = common global i32 0, align 4
10
11; CHECK-LABEL: define void @test1(
12define void @test1(i1 %cmp, i32* noalias %p) {
13entry:
14  br i1 %cmp, label %if.then, label %if.else
15
16if.then:                                          ; preds = %entry
17  call void @may_exit() nounwind
18  %arrayidx = getelementptr inbounds i32, i32* %p, i64 1
19  %0 = load i32, i32* %arrayidx, align 4
20  store i32 %0, i32* @r, align 4
21  br label %if.end
22; CHECK:       call void @may_exit()
23; CHECK-NEXT:  %[[gep:.*]] = getelementptr inbounds i32, i32* %p, i64 1
24; CHECK-NEXT:  %[[load:.*]] = load i32, i32* %[[gep]], align 4
25; CHECK-NEXT:  store i32 %[[load]], i32* @r, align 4
26
27if.else:                                          ; preds = %entry
28  %arrayidx1 = getelementptr inbounds i32, i32* %p, i64 1
29  %1 = load i32, i32* %arrayidx1, align 4
30  store i32 %1, i32* @s, align 4
31  br label %if.end
32
33if.end:                                           ; preds = %if.else, %if.then
34  ret void
35}
36
37; CHECK-LABEL: define void @test2(
38define void @test2(i1 %cmp, i32* noalias %p) {
39entry:
40  br i1 %cmp, label %if.then, label %if.else
41
42if.then:                                          ; preds = %entry
43  %arrayidx = getelementptr inbounds i32, i32* %p, i64 1
44  store i32 1, i32* %arrayidx, align 4
45  call void @may_throw()
46; CHECK:       %[[gep:.*]] = getelementptr inbounds i32, i32* %p, i64 1
47; CHECK-NEXT:  store i32 1, i32* %[[gep]], align 4
48; CHECK-NEXT:  call void @may_throw()
49  br label %if.end
50
51if.else:                                          ; preds = %entry
52  %arrayidx1 = getelementptr inbounds i32, i32* %p, i64 1
53  store i32 2, i32* %arrayidx1, align 4
54  br label %if.end
55
56if.end:                                           ; preds = %if.else, %if.then
57  ret void
58}
59
60declare void @may_throw()
61declare void @may_exit() nounwind
62