1 ; RUN: opt -S -consthoist < %s | FileCheck %s
2 ; RUN: opt -S -passes=consthoist < %s | FileCheck %s
4 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-apple-macosx10.9.0"
8 define i8* @test1(i1 %cmp, i64* %tmp) {
10 call void @foo(i8* inttoptr (i64 68719476735 to i8*))
11 br i1 %cmp, label %if.end, label %return
13 if.end: ; preds = %bb1
14 call void @foo(i8* inttoptr (i64 68719476736 to i8*))
18 %retval.0 = phi i8* [ null, %entry ], [ inttoptr (i64 68719476736 to i8*), %if.end ]
19 store i64 1172321806, i64* %tmp
24 ; CHECK: %2 = inttoptr i64 %const to i8*
27 ; CHECK-NEXT: %retval.0 = phi i8* [ null, %entry ], [ %2, %if.end ]
30 define void @test2(i1 %cmp, i64** %tmp) {
32 call void @foo(i8* inttoptr (i64 68719476736 to i8*))
33 br i1 %cmp, label %if.end, label %return
35 if.end: ; preds = %bb1
36 call void @foo(i8* inttoptr (i64 68719476736 to i8*))
40 store i64* inttoptr (i64 68719476735 to i64*), i64** %tmp
45 ; CHECK-NEXT: %const_mat = add i64 %const, -1
46 ; CHECK-NEXT: inttoptr i64 %const_mat to i64*
49 declare void @foo(i8*)
52 define i32 @test3(i1 %c) {
54 br i1 %c, label %if.then, label %if.end3
56 if.then: ; preds = %entry
59 if.end3: ; preds = %if.then, %entry
60 %d.0 = phi i32* [ inttoptr (i64 985162435264511 to i32*), %entry ], [ null, %if.then ]
61 %cmp4 = icmp eq i32* %d.0, inttoptr (i64 985162435264511 to i32*)
62 %cmp6 = icmp eq i32* %d.0, inttoptr (i64 985162418487296 to i32*)
63 %or = or i1 %cmp4, %cmp6
64 br i1 %or, label %if.then8, label %if.end9
66 if.then8: ; preds = %if.end3
69 if.end9: ; preds = %if.then8, %if.end3
73 ; <rdar://problem/16394449>
74 define i64 @switch_test1(i64 %a) {
75 ; CHECK-LABEL: @switch_test1
76 ; CHECK: %0 = phi i64 [ %const, %case2 ], [ %const_mat, %Entry ], [ %const_mat, %Entry ]
78 %sel = add i64 %a, 4519019440
79 switch i64 %sel, label %fail [
80 i64 462, label %continuation
82 i64 443, label %continuation
86 br label %continuation
89 %0 = phi i64 [ 4519019440, %case2 ], [ 4519019460, %Entry ], [ 4519019460, %Entry ]
96 define i64 @switch_test2(i64 %a) {
97 ; CHECK-LABEL: @switch_test2
98 ; CHECK: %2 = phi i64* [ %1, %case2 ], [ %0, %Entry ], [ %0, %Entry ]
100 %sel = add i64 %a, 4519019440
101 switch i64 %sel, label %fail [
102 i64 462, label %continuation
103 i64 449, label %case2
104 i64 443, label %continuation
108 br label %continuation
111 %0 = phi i64* [ inttoptr(i64 4519019440 to i64*), %case2 ], [ inttoptr(i64 4519019460 to i64*), %Entry ], [ inttoptr(i64 4519019460 to i64*), %Entry ]