File: switch_switch_fold.ll

package info (click to toggle)
llvm-2.7 2.7-6
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 59,992 kB
  • ctags: 49,499
  • sloc: cpp: 373,792; ansic: 16,885; sh: 12,614; asm: 6,809; ada: 3,083; ml: 2,942; python: 2,671; perl: 2,404; makefile: 1,691; pascal: 1,235; exp: 399; objc: 291; lisp: 184; csh: 117; xml: 38; f90: 36
file content (47 lines) | stat: -rw-r--r-- 1,181 bytes parent folder | download | duplicates (11)
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
; RUN: opt < %s -simplifycfg -S | \
; RUN:   grep switch | count 1

; Test that a switch going to a switch on the same value can be merged.   All 
; three switches in this example can be merged into one big one.

declare void @foo1()

declare void @foo2()

declare void @foo3()

declare void @foo4()

define void @test1(i32 %V) {
        switch i32 %V, label %F [
                 i32 4, label %T
                 i32 17, label %T
                 i32 5, label %T
                 i32 1234, label %F
        ]
T:              ; preds = %0, %0, %0
        switch i32 %V, label %F [
                 i32 4, label %A
                 i32 17, label %B
                 i32 42, label %C
        ]
A:              ; preds = %T
        call void @foo1( )
        ret void
B:              ; preds = %F, %F, %T
        call void @foo2( )
        ret void
C:              ; preds = %T
        call void @foo3( )
        ret void
F:              ; preds = %F, %T, %0, %0
        switch i32 %V, label %F [
                 i32 4, label %B
                 i32 18, label %B
                 i32 42, label %D
        ]
D:              ; preds = %F
        call void @foo4( )
        ret void
}