aboutsummaryrefslogtreecommitdiffstats
path: root/test/Transforms/InstCombine/select.ll
blob: d3a880d607b67a14c52370ee5e1aa33fe0d90d38 (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
94
95
96
97
98
; This test makes sure that these instructions are properly eliminated.
;

; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep select

implementation

int %test1(int %A, int %B) {
	%C = select bool false, int %A, int %B
	ret int %C
}

int %test2(int %A, int %B) {
	%C = select bool true, int %A, int %B
	ret int %C
}

int %test3(bool %C, int %I) {
	%V = select bool %C, int %I, int %I         ; V = I
	ret int %V
}

bool %test4(bool %C) {
	%V = select bool %C, bool true, bool false  ; V = C
	ret bool %V
}

bool %test5(bool %C) {
	%V = select bool %C, bool false, bool true  ; V = !C
	ret bool %V
}

int %test6(bool %C) {
	%V = select bool %C, int 1, int 0         ; V = cast C to int
	ret int %V
}

bool %test7(bool %C, bool %X) {
        %R = select bool %C, bool true, bool %X    ; R = or C, X
        ret bool %R
}

bool %test8(bool %C, bool %X) {
        %R = select bool %C, bool %X, bool false   ; R = and C, X
        ret bool %R
}

bool %test9(bool %C, bool %X) {
        %R = select bool %C, bool false, bool %X    ; R = and !C, X
        ret bool %R
}

bool %test10(bool %C, bool %X) {
        %R = select bool %C, bool %X, bool true   ; R = or !C, X
        ret bool %R
}

int %test11(int %a) {
        %C = seteq int %a, 0
        %R = select bool %C, int 0, int 1
        ret int %R
}

int %test12(bool %cond, int %a) {
	%b = or int %a, 1
	%c = select bool %cond, int %b, int %a
	ret int %c
}

int %test12a(bool %cond, int %a) {
	%b = shr int %a, ubyte 1
	%c = select bool %cond, int %b, int %a
	ret int %c
}

int %test12b(bool %cond, int %a) {
	%b = shr int %a, ubyte 1
	%c = select bool %cond, int %a, int %b
	ret int %c
}

int %test13(int %a, int %b) {
	%C = seteq int %a, %b
	%V = select bool %C, int %a, int %b
	ret int %V
}

int %test13a(int %a, int %b) {
	%C = setne int %a, %b
	%V = select bool %C, int %a, int %b
	ret int %V
}

int %test13b(int %a, int %b) {
	%C = seteq int %a, %b
	%V = select bool %C, int %b, int %a
	ret int %V
}