1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -simplifycfg < %s | FileCheck %s
4 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
5 target triple = "armv7a--none-eabi"
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.
10 ; CHECK-NOT: @switch.table
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
18 define i32* @test3(i32 %n) {
19 ; CHECK-LABEL: @test3(
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:%.*]]
27 ; CHECK-NEXT: br label [[RETURN]]
29 ; CHECK-NEXT: br label [[RETURN]]
31 ; CHECK-NEXT: br label [[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]]
37 switch i32 %n, label %sw.default [
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 ]