summaryrefslogtreecommitdiff
path: root/test/Transforms/InstCombine/set.ll
blob: 756ade495215d34d746590b31dddd5840215de71 (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
; This test makes sure that these instructions are properly eliminated.
;
; RUN: llvm-as < %s | opt -instcombine -disable-output &&
; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep set

%X = uninitialized global int

bool %test1(int %A) {
	%B = seteq int %A, %A
	%C = seteq int* %X, null   ; Never true
	%D = and bool %B, %C
	ret bool %D
}

bool %test2(int %A) {
	%B = setne int %A, %A
	%C = setne int* %X, null   ; Never false
	%D = or bool %B, %C
	ret bool %D
}

bool %test3(int %A) {
	%B = setlt int %A, %A
	ret bool %B
}

bool %test4(int %A) {
	%B = setgt int %A, %A
	ret bool %B
}

bool %test5(int %A) {
	%B = setle int %A, %A
	ret bool %B
}

bool %test6(int %A) {
	%B = setge int %A, %A
	ret bool %B
}

bool %test7(uint %A) {
	%B = setge uint %A, 0  ; true
	ret bool %B
}

bool %test8(uint %A) {
	%B = setlt uint %A, 0  ; false
	ret bool %B
}

;; test operations on boolean values these should all be eliminated$a
bool %test9(bool %A) {
	%B = setlt bool %A, false ; false
	ret bool %B
}
bool %test10(bool %A) {
	%B = setgt bool %A, true  ; false
	ret bool %B
}
bool %test11(bool %A) {
	%B = setle bool %A, true ; true
	ret bool %B
}
bool %test12(bool %A) {
	%B = setge bool %A, false  ; true
	ret bool %B
}
bool %test13(bool %A, bool %B) {
	%C = setge bool %A, %B       ; A | ~B
	ret bool %C
}
bool %test14(bool %A, bool %B) {
	%C = seteq bool %A, %B  ; ~(A ^ B)
	ret bool %C
}

bool %test16(uint %A) {
	%B = and uint %A, 5
	%C = seteq uint %B, 8    ; Is never true
	ret bool %C
}

bool %test17(ubyte %A) {
	%B = or ubyte %A, 1
	%C = seteq ubyte %B, 2   ; Always false
	ret bool %C
}

bool %test18(bool %C, int %a) {
entry:
        br bool %C, label %endif, label %else

else:
        br label %endif

endif:
        %b.0 = phi int [ 0, %entry ], [ 1, %else ]
        %tmp.4 = setlt int %b.0, 123
        ret bool %tmp.4
}

bool %test19(bool %A, bool %B) {
	%a = cast bool %A to int
	%b = cast bool %B to int
	%C = seteq int %a, %b
	ret bool %C
}

uint %test20(uint %A) {
        %B = and uint %A, 1
        %C = setne uint %B, 0
        %D = cast bool %C to uint
        ret uint %D
}

int %test21(int %a) {
        %tmp.6 = and int %a, 4
        %not.tmp.7 = setne int %tmp.6, 0
        %retval = cast bool %not.tmp.7 to int
        ret int %retval
}

bool %test22(uint %A, int %X) {
        %B = and uint %A, 100663295
        %C = setlt uint %B, 268435456
	%Y = and int %X, 7
	%Z = setgt int %Y, -1
	%R = or bool %C, %Z
	ret bool %R
}

int %test23(int %a) {
        %tmp.1 = and int %a, 1
        %tmp.2 = seteq int %tmp.1, 0
        %tmp.3 = cast bool %tmp.2 to int  ;; xor tmp1, 1
        ret int %tmp.3
}

int %test24(uint %a) {
        %tmp1 = and uint %a, 4
	%tmp.1 = shr uint %tmp1, ubyte 2
        %tmp.2 = seteq uint %tmp.1, 0
        %tmp.3 = cast bool %tmp.2 to int  ;; xor tmp1, 1
        ret int %tmp.3
}