SimplifyCFG: Track the number of used icmps when turning a icmp chain into a switch...
[oota-llvm.git] / test / Transforms / SimplifyCFG / switch-to-icmp.ll
1 ; RUN: opt -S -simplifycfg < %s | FileCheck %s
2
3 define zeroext i1 @test1(i32 %x) nounwind readnone ssp noredzone {
4 entry:
5  switch i32 %x, label %lor.rhs [
6    i32 2, label %lor.end
7    i32 1, label %lor.end
8    i32 3, label %lor.end
9  ]
10
11 lor.rhs:
12  br label %lor.end
13
14 lor.end:
15  %0 = phi i1 [ true, %entry ], [ false, %lor.rhs ], [ true, %entry ], [ true, %entry ]
16  ret i1 %0
17
18 ; CHECK: @test1
19 ; CHECK: %x.off = add i32 %x, -1
20 ; CHECK: %switch = icmp ult i32 %x.off, 3
21 }
22
23 define zeroext i1 @test2(i32 %x) nounwind readnone ssp noredzone {
24 entry:
25  switch i32 %x, label %lor.rhs [
26    i32 0, label %lor.end
27    i32 1, label %lor.end
28  ]
29
30 lor.rhs:
31  br label %lor.end
32
33 lor.end:
34  %0 = phi i1 [ true, %entry ], [ false, %lor.rhs ], [ true, %entry ]
35  ret i1 %0
36
37 ; CHECK: @test2
38 ; CHECK: %switch = icmp ult i32 %x, 2
39 }