1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -S -simplifycfg < %s | FileCheck %s
3
4target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
5target triple = "armv7a--none-eabi"
6
7; One of the phi node's values is too complex to be represented by a global
8; variable, so we can't convert to a lookup table.
9
10; CHECK-NOT: @switch.table
11; CHECK-NOT: load
12
13@g1 = external global i32, align 4
14@g2 = external global i32, align 4
15@g3 = external global i32, align 4
16@g4 = external thread_local global i32, align 4
17
18define i32* @test3(i32 %n) {
19; CHECK-LABEL: @test3(
20; CHECK-NEXT:  entry:
21; CHECK-NEXT:    switch i32 [[N:%.*]], label [[SW_DEFAULT:%.*]] [
22; CHECK-NEXT:    i32 0, label [[RETURN:%.*]]
23; CHECK-NEXT:    i32 1, label [[SW_BB1:%.*]]
24; CHECK-NEXT:    i32 2, label [[SW_BB2:%.*]]
25; CHECK-NEXT:    ]
26; CHECK:       sw.bb1:
27; CHECK-NEXT:    br label [[RETURN]]
28; CHECK:       sw.bb2:
29; CHECK-NEXT:    br label [[RETURN]]
30; CHECK:       sw.default:
31; CHECK-NEXT:    br label [[RETURN]]
32; CHECK:       return:
33; CHECK-NEXT:    [[RETVAL_0:%.*]] = phi i32* [ @g4, [[SW_DEFAULT]] ], [ getelementptr inbounds (i32, i32* inttoptr (i32 mul (i32 ptrtoint (i32* @g3 to i32), i32 2) to i32*), i32 1), [[SW_BB2]] ], [ @g2, [[SW_BB1]] ], [ @g1, [[ENTRY:%.*]] ]
34; CHECK-NEXT:    ret i32* [[RETVAL_0]]
35;
36entry:
37  switch i32 %n, label %sw.default [
38  i32 0, label %sw.bb
39  i32 1, label %sw.bb1
40  i32 2, label %sw.bb2
41  ]
42
43sw.bb:
44  br label %return
45
46sw.bb1:
47  br label %return
48
49sw.bb2:
50  br label %return
51
52sw.default:
53  br label %return
54
55return:
56  %retval.0 = phi i32* [ @g4, %sw.default ], [ getelementptr inbounds (i32, i32* inttoptr (i32 mul (i32 ptrtoint (i32* @g3 to i32), i32 2) to i32*), i32 1), %sw.bb2 ], [ @g2, %sw.bb1 ], [ @g1, %sw.bb ]
57  ret i32* %retval.0
58}
59