• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -simplifycfg -switch-to-lookup -S %s | FileCheck %s
3; RUN: opt -passes='simplify-cfg<switch-to-lookup>' -S %s | FileCheck %s
4; rdar://15268442
5
6target datalayout = "e-p:64:64:64-S128-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f16:16:16-f32:32:32-f64:64:64-f128:128:128-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
7target triple = "x86_64-apple-darwin12.0.0"
8
9define i3 @coveredswitch_test(i3 %input) {
10; CHECK-LABEL: @coveredswitch_test(
11; CHECK-NEXT:  entry:
12; CHECK-NEXT:    [[SWITCH_TABLEIDX:%.*]] = sub i3 [[INPUT:%.*]], -4
13; CHECK-NEXT:    [[SWITCH_CAST:%.*]] = zext i3 [[SWITCH_TABLEIDX]] to i24
14; CHECK-NEXT:    [[SWITCH_SHIFTAMT:%.*]] = mul i24 [[SWITCH_CAST]], 3
15; CHECK-NEXT:    [[SWITCH_DOWNSHIFT:%.*]] = lshr i24 7507338, [[SWITCH_SHIFTAMT]]
16; CHECK-NEXT:    [[SWITCH_MASKED:%.*]] = trunc i24 [[SWITCH_DOWNSHIFT]] to i3
17; CHECK-NEXT:    ret i3 [[SWITCH_MASKED]]
18;
19entry:
20  switch i3 %input, label %bb8 [
21  i3 0, label %bb7
22  i3 1, label %bb
23  i3 2, label %bb3
24  i3 3, label %bb4
25  i3 4, label %bb5
26  i3 5, label %bb6
27  ]
28
29bb:                                               ; preds = %entry
30  br label %bb8
31
32bb3:                                              ; preds = %entry
33  br label %bb8
34
35bb4:                                              ; preds = %entry
36  br label %bb8
37
38bb5:                                              ; preds = %entry
39  br label %bb8
40
41bb6:                                              ; preds = %entry
42  br label %bb8
43
44bb7:                                              ; preds = %entry
45  br label %bb8
46
47bb8:                                              ; preds = %bb7, %bb6, %bb5, %bb4, %bb3, %bb, %entry
48  %result = phi i3 [ 0, %bb7 ], [ 1, %bb6 ], [ 2, %bb5 ], [ 3, %bb4 ], [ 4, %bb3 ], [ 5, %bb ], [ 6, %entry ]
49  ret i3 %result
50}
51