Joerg Sonnenberger | fa73674 | 2017-03-26 06:44:08 +0000 | [diff] [blame] | 1 | ; RUN: opt -S -latesimplifycfg -mtriple=arm -relocation-model=static < %s | FileCheck %s --check-prefix=CHECK --check-prefix=ENABLE |
| 2 | ; RUN: opt -S -latesimplifycfg -mtriple=arm -relocation-model=pic < %s | FileCheck %s --check-prefix=CHECK --check-prefix=ENABLE |
| 3 | ; RUN: opt -S -latesimplifycfg -mtriple=arm -relocation-model=ropi < %s | FileCheck %s --check-prefix=CHECK --check-prefix=DISABLE |
| 4 | ; RUN: opt -S -latesimplifycfg -mtriple=arm -relocation-model=rwpi < %s | FileCheck %s --check-prefix=CHECK --check-prefix=DISABLE |
| 5 | ; RUN: opt -S -latesimplifycfg -mtriple=arm -relocation-model=ropi-rwpi < %s | FileCheck %s --check-prefix=CHECK --check-prefix=DISABLE |
Oliver Stannard | 4df1cc0 | 2016-10-07 08:48:24 +0000 | [diff] [blame] | 6 | |
| 7 | ; CHECK: @{{.*}} = private unnamed_addr constant [3 x i32] [i32 1234, i32 5678, i32 15532] |
| 8 | ; ENABLE: @{{.*}} = private unnamed_addr constant [3 x i32*] [i32* @c1, i32* @c2, i32* @c3] |
| 9 | ; DISABLE-NOT: @{{.*}} = private unnamed_addr constant [3 x i32*] [i32* @c1, i32* @c2, i32* @c3] |
| 10 | ; ENABLE: @{{.*}} = private unnamed_addr constant [3 x i32*] [i32* @g1, i32* @g2, i32* @g3] |
| 11 | ; DISABLE-NOT: @{{.*}} = private unnamed_addr constant [3 x i32*] [i32* @g1, i32* @g2, i32* @g3] |
| 12 | ; ENABLE: @{{.*}} = private unnamed_addr constant [3 x i32 (i32, i32)*] [i32 (i32, i32)* @f1, i32 (i32, i32)* @f2, i32 (i32, i32)* @f3] |
| 13 | ; DISABLE-NOT: @{{.*}} = private unnamed_addr constant [3 x i32 (i32, i32)*] [i32 (i32, i32)* @f1, i32 (i32, i32)* @f2, i32 (i32, i32)* @f3] |
| 14 | |
| 15 | target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" |
| 16 | target triple = "armv7a--none-eabi" |
| 17 | |
| 18 | define i32 @test1(i32 %n) { |
| 19 | entry: |
| 20 | switch i32 %n, label %sw.default [ |
| 21 | i32 0, label %sw.bb |
| 22 | i32 1, label %sw.bb1 |
| 23 | i32 2, label %sw.bb2 |
| 24 | ] |
| 25 | |
| 26 | sw.bb: |
| 27 | br label %return |
| 28 | |
| 29 | sw.bb1: |
| 30 | br label %return |
| 31 | |
| 32 | sw.bb2: |
| 33 | br label %return |
| 34 | |
| 35 | sw.default: |
| 36 | br label %return |
| 37 | |
| 38 | return: |
| 39 | %retval.0 = phi i32 [ 15498, %sw.default ], [ 15532, %sw.bb2 ], [ 5678, %sw.bb1 ], [ 1234, %sw.bb ] |
| 40 | ret i32 %retval.0 |
| 41 | } |
| 42 | |
| 43 | @c1 = external constant i32, align 4 |
| 44 | @c2 = external constant i32, align 4 |
| 45 | @c3 = external constant i32, align 4 |
| 46 | @c4 = external constant i32, align 4 |
| 47 | |
| 48 | |
| 49 | define i32* @test2(i32 %n) { |
| 50 | entry: |
| 51 | switch i32 %n, label %sw.default [ |
| 52 | i32 0, label %sw.bb |
| 53 | i32 1, label %sw.bb1 |
| 54 | i32 2, label %sw.bb2 |
| 55 | ] |
| 56 | |
| 57 | sw.bb: |
| 58 | br label %return |
| 59 | |
| 60 | sw.bb1: |
| 61 | br label %return |
| 62 | |
| 63 | sw.bb2: |
| 64 | br label %return |
| 65 | |
| 66 | sw.default: |
| 67 | br label %return |
| 68 | |
| 69 | return: |
| 70 | %retval.0 = phi i32* [ @c4, %sw.default ], [ @c3, %sw.bb2 ], [ @c2, %sw.bb1 ], [ @c1, %sw.bb ] |
| 71 | ret i32* %retval.0 |
| 72 | } |
| 73 | |
| 74 | @g1 = external global i32, align 4 |
| 75 | @g2 = external global i32, align 4 |
| 76 | @g3 = external global i32, align 4 |
| 77 | @g4 = external global i32, align 4 |
| 78 | |
| 79 | define i32* @test3(i32 %n) { |
| 80 | entry: |
| 81 | switch i32 %n, label %sw.default [ |
| 82 | i32 0, label %sw.bb |
| 83 | i32 1, label %sw.bb1 |
| 84 | i32 2, label %sw.bb2 |
| 85 | ] |
| 86 | |
| 87 | sw.bb: |
| 88 | br label %return |
| 89 | |
| 90 | sw.bb1: |
| 91 | br label %return |
| 92 | |
| 93 | sw.bb2: |
| 94 | br label %return |
| 95 | |
| 96 | sw.default: |
| 97 | br label %return |
| 98 | |
| 99 | return: |
| 100 | %retval.0 = phi i32* [ @g4, %sw.default ], [ @g3, %sw.bb2 ], [ @g2, %sw.bb1 ], [ @g1, %sw.bb ] |
| 101 | ret i32* %retval.0 |
| 102 | } |
| 103 | |
| 104 | declare i32 @f1(i32, i32) |
| 105 | declare i32 @f2(i32, i32) |
| 106 | declare i32 @f3(i32, i32) |
| 107 | declare i32 @f4(i32, i32) |
| 108 | declare i32 @f5(i32, i32) |
| 109 | |
| 110 | define i32 @test4(i32 %a, i32 %b, i32 %c) { |
| 111 | entry: |
| 112 | %cmp = icmp eq i32 %a, 1 |
| 113 | br i1 %cmp, label %cond.end11, label %cond.false |
| 114 | |
| 115 | cond.false: |
| 116 | %cmp1 = icmp eq i32 %a, 2 |
| 117 | br i1 %cmp1, label %cond.end11, label %cond.false3 |
| 118 | |
| 119 | cond.false3: |
| 120 | %cmp4 = icmp eq i32 %a, 3 |
| 121 | br i1 %cmp4, label %cond.end11, label %cond.false6 |
| 122 | |
| 123 | cond.false6: |
| 124 | %cmp7 = icmp eq i32 %a, 4 |
| 125 | %cond = select i1 %cmp7, i32 (i32, i32)* @f4, i32 (i32, i32)* @f5 |
| 126 | br label %cond.end11 |
| 127 | |
| 128 | cond.end11: |
| 129 | %cond12 = phi i32 (i32, i32)* [ @f1, %entry ], [ @f2, %cond.false ], [ %cond, %cond.false6 ], [ @f3, %cond.false3 ] |
| 130 | %call = call i32 %cond12(i32 %b, i32 %c) #2 |
| 131 | ret i32 %call |
| 132 | } |