~pali/+junk/llvm-toolchain-3.7

« back to all changes in this revision

Viewing changes to test/Transforms/GVN/cond_br.ll

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2015-07-15 17:51:08 UTC
  • Revision ID: package-import@ubuntu.com-20150715175108-l8mynwovkx4zx697
Tags: upstream-3.7~+rc2
ImportĀ upstreamĀ versionĀ 3.7~+rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
; RUN: opt -basicaa -gvn -S < %s | FileCheck %s
 
2
@y = external global i32
 
3
@z = external global i32
 
4
 
 
5
; Function Attrs: nounwind ssp uwtable
 
6
define void @foo(i32 %x) {
 
7
; CHECK: @foo(i32 %x)
 
8
; CHECK: %.pre = load i32, i32* @y
 
9
; CHECK: call void @bar(i32 %.pre)
 
10
 
 
11
  %t = sub i32 %x, %x
 
12
  %.pre = load i32, i32* @y, align 4
 
13
  %cmp = icmp sgt i32 %t, 2
 
14
  br i1 %cmp, label %if.then, label %entry.if.end_crit_edge
 
15
 
 
16
entry.if.end_crit_edge:                           ; preds = %entry
 
17
  br label %if.end
 
18
 
 
19
if.then:                                          ; preds = %entry
 
20
  %add = add nsw i32 %x, 3
 
21
  store i32 %add, i32* @y, align 4
 
22
  br label %if.end
 
23
 
 
24
if.end:                                           ; preds = %entry.if.end_crit_edge, %if.then
 
25
  %1 = phi i32 [ %.pre, %entry.if.end_crit_edge ], [ %add, %if.then ]
 
26
  tail call void @bar(i32 %1)
 
27
  ret void
 
28
}
 
29
 
 
30
define void @foo2(i32 %x) {
 
31
; CHECK: @foo2(i32 %x)
 
32
; CHECK: %.pre = load i32, i32* @y
 
33
; CHECK: tail call void @bar(i32 %.pre)
 
34
entry:
 
35
  %t = sub i32 %x, %x
 
36
  %.pre = load i32, i32* @y, align 4
 
37
  %cmp = icmp sgt i32 %t, 2
 
38
  br i1 %cmp, label %if.then, label %if.else
 
39
 
 
40
if.then:                                          ; preds = %entry
 
41
  %add = add nsw i32 %x, 3
 
42
  store i32 %add, i32* @y, align 4
 
43
  br label %if.end
 
44
 
 
45
if.else:                                          ; preds = %entry
 
46
  store i32 1, i32* @z, align 4
 
47
  br label %if.end
 
48
 
 
49
if.end:                                           ; preds = %if.else, %if.then
 
50
  %0 = phi i32 [ %.pre, %if.else ], [ %add, %if.then ]
 
51
  tail call void @bar(i32 %0)
 
52
  ret void
 
53
}
 
54
 
 
55
declare void @bar(i32)