1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -instcombine -S | FileCheck %s
3
4@g = global i32 0
5
6; PR30486
7define i32 @single_case() {
8; CHECK-LABEL: @single_case(
9; CHECK-NEXT:    switch i32 ptrtoint (i32* @g to i32), label %x [
10; CHECK-NEXT:    ]
11; CHECK:       x:
12; CHECK-NEXT:    ret i32 0
13;
14  switch i32 add (i32 ptrtoint (i32* @g to i32), i32 -1), label %x []
15x:
16  ret i32 0
17}
18
19define i32 @multiple_cases() {
20; CHECK-LABEL: @multiple_cases(
21; CHECK-NEXT:    switch i32 ptrtoint (i32* @g to i32), label %x [
22; CHECK-NEXT:    i32 2, label %one
23; CHECK-NEXT:    i32 3, label %two
24; CHECK-NEXT:    ]
25; CHECK:       x:
26; CHECK-NEXT:    ret i32 0
27; CHECK:       one:
28; CHECK-NEXT:    ret i32 1
29; CHECK:       two:
30; CHECK-NEXT:    ret i32 2
31;
32  switch i32 add (i32 ptrtoint (i32* @g to i32), i32 -1), label %x [
33  i32 1, label %one
34  i32 2, label %two
35  ]
36x:
37  ret i32 0
38
39one:
40  ret i32 1
41
42two:
43  ret i32 2
44}
45