1 ; RUN: opt -S -consthoist < %s | FileCheck %s 2 3 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 4 target triple = "x86_64-apple-macosx10.9.0" 5 6 ; PR18626 7 define i8* @test1(i1 %cmp, i64* %tmp) { 8 entry: 9 call void @foo(i8* inttoptr (i64 68719476735 to i8*)) 10 br i1 %cmp, label %if.end, label %return 11 12 if.end: ; preds = %bb1 13 call void @foo(i8* inttoptr (i64 68719476736 to i8*)) 14 br label %return 15 16 return: 17 %retval.0 = phi i8* [ null, %entry ], [ inttoptr (i64 68719476736 to i8*), %if.end ] 18 store i64 1172321806, i64* %tmp 19 ret i8* %retval.0 20 21 ; CHECK-LABEL: @test1 22 ; CHECK: if.end: 23 ; CHECK: %2 = inttoptr i64 %const to i8* 24 ; CHECK-NEXT: br 25 ; CHECK: return: 26 ; CHECK-NEXT: %retval.0 = phi i8* [ null, %entry ], [ %2, %if.end ] 27 } 28 29 define void @test2(i1 %cmp, i64** %tmp) { 30 entry: 31 call void @foo(i8* inttoptr (i64 68719476736 to i8*)) 32 br i1 %cmp, label %if.end, label %return 33 34 if.end: ; preds = %bb1 35 call void @foo(i8* inttoptr (i64 68719476736 to i8*)) 36 br label %return 37 38 return: 39 store i64* inttoptr (i64 68719476735 to i64*), i64** %tmp 40 ret void 41 42 ; CHECK-LABEL: @test2 43 ; CHECK: return: 44 ; CHECK-NEXT: %const_mat = add i64 %const, -1 45 ; CHECK-NEXT: inttoptr i64 %const_mat to i64* 46 } 47 48 declare void @foo(i8*) 49 50 ; PR18768 51 define i32 @test3(i1 %c) { 52 entry: 53 br i1 %c, label %if.then, label %if.end3 54 55 if.then: ; preds = %entry 56 br label %if.end3 57 58 if.end3: ; preds = %if.then, %entry 59 %d.0 = phi i32* [ inttoptr (i64 985162435264511 to i32*), %entry ], [ null, %if.then ] 60 %cmp4 = icmp eq i32* %d.0, inttoptr (i64 985162435264511 to i32*) 61 %cmp6 = icmp eq i32* %d.0, inttoptr (i64 985162418487296 to i32*) 62 %or = or i1 %cmp4, %cmp6 63 br i1 %or, label %if.then8, label %if.end9 64 65 if.then8: ; preds = %if.end3 66 ret i32 1 67 68 if.end9: ; preds = %if.then8, %if.end3 69 ret i32 undef 70 } 71 72 ; <rdar://problem/16394449> 73 define i64 @switch_test1(i64 %a) { 74 ; CHECK-LABEL: @switch_test1 75 ; CHECK: %0 = phi i64 [ %const, %case2 ], [ %const_mat, %Entry ], [ %const_mat, %Entry ] 76 Entry: 77 %sel = add i64 %a, 4519019440 78 switch i64 %sel, label %fail [ 79 i64 462, label %continuation 80 i64 449, label %case2 81 i64 443, label %continuation 82 ] 83 84 case2: 85 br label %continuation 86 87 continuation: 88 %0 = phi i64 [ 4519019440, %case2 ], [ 4519019460, %Entry ], [ 4519019460, %Entry ] 89 ret i64 0; 90 91 fail: 92 ret i64 -1; 93 } 94 95 define i64 @switch_test2(i64 %a) { 96 ; CHECK-LABEL: @switch_test2 97 ; CHECK: %2 = phi i64* [ %1, %case2 ], [ %0, %Entry ], [ %0, %Entry ] 98 Entry: 99 %sel = add i64 %a, 4519019440 100 switch i64 %sel, label %fail [ 101 i64 462, label %continuation 102 i64 449, label %case2 103 i64 443, label %continuation 104 ] 105 106 case2: 107 br label %continuation 108 109 continuation: 110 %0 = phi i64* [ inttoptr(i64 4519019440 to i64*), %case2 ], [ inttoptr(i64 4519019460 to i64*), %Entry ], [ inttoptr(i64 4519019460 to i64*), %Entry ] 111 ret i64 0; 112 113 fail: 114 ret i64 -1; 115 } 116 117