aboutsummaryrefslogtreecommitdiffstats
path: root/test/Transforms/InstCombine/narrow-switch.ll
blob: 7646189b8540f93102c48e57457857ed359f757c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
; RUN: opt < %s -instcombine -S | FileCheck %s

target datalayout = "e-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"

; CHECK-LABEL: define i32 @positive1
; CHECK: switch i32
; CHECK: i32 10, label
; CHECK: i32 100, label
; CHECK: i32 1001, label

define i32 @positive1(i64 %a) {
entry:
  %and = and i64 %a, 4294967295
  switch i64 %and, label %sw.default [
    i64 10, label %return
    i64 100, label %sw.bb1
    i64 1001, label %sw.bb2
  ]

sw.bb1:
  br label %return

sw.bb2:
  br label %return

sw.default:
  br label %return

return:
  %retval.0 = phi i32 [ 24, %sw.default ], [ 123, %sw.bb2 ], [ 213, %sw.bb1 ], [ 231, %entry ]
  ret i32 %retval.0
}

; CHECK-LABEL: define i32 @negative1
; CHECK: switch i32
; CHECK: i32 -10, label
; CHECK: i32 -100, label
; CHECK: i32 -1001, label

define i32 @negative1(i64 %a) {
entry:
  %or = or i64 %a, -4294967296
  switch i64 %or, label %sw.default [
    i64 -10, label %return
    i64 -100, label %sw.bb1
    i64 -1001, label %sw.bb2
  ]

sw.bb1:
  br label %return

sw.bb2:
  br label %return

sw.default:
  br label %return

return:
  %retval.0 = phi i32 [ 24, %sw.default ], [ 123, %sw.bb2 ], [ 213, %sw.bb1 ], [ 231, %entry ]
  ret i32 %retval.0
}

; Make sure truncating a constant int larger than 64-bit doesn't trigger an
; assertion.

; CHECK-LABEL: define i32 @trunc72to68
; CHECK: switch i68
; CHECK: i68 10, label
; CHECK: i68 100, label
; CHECK: i68 1001, label

define i32 @trunc72to68(i72 %a) {
entry:
  %and = and i72 %a, 295147905179352825855
  switch i72 %and, label %sw.default [
    i72 10, label %return
    i72 100, label %sw.bb1
    i72 1001, label %sw.bb2
  ]

sw.bb1:
  br label %return

sw.bb2:
  br label %return

sw.default:
  br label %return

return:
  %retval.0 = phi i32 [ 24, %sw.default ], [ 123, %sw.bb2 ], [ 213, %sw.bb1 ], [ 231, %entry ]
  ret i32 %retval.0
}