Add another case, which an implementation of test6 must be sure to handle
[oota-llvm.git] / test / Transforms / InstCombine / cast-set.ll
1 ; I'm not really sure if instcombine should do things like these.  LevelRaise 
2 ; already sufficiently takes care of these cases, but level raise is really
3 ; slow.  Might it be better to make there be an instcombine prepass before
4 ; level raise that takes care of the obvious stuff?
5
6 ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep cast
7
8 bool %test1(int %X) {
9         %A = cast int %X to uint
10         %c = setne uint %A, 12        ; Convert to setne int %X, 12
11         ret bool %c
12 }
13
14 bool %test2(int %X, int %Y) {
15         %A = cast int %X to uint
16         %B = cast int %Y to uint
17         %c = setne uint %A, %B       ; Convert to setne int %X, %Y
18         ret bool %c
19 }
20
21 bool %test3(int %A, int %B) {
22         %cond216 = setlt int %A, %B             ; <bool> [#uses=1]
23         %cst109 = cast bool %cond216 to uint           ; <uint> [#uses=1]
24         %cond219 = setgt int %A, %B             ; <bool> [#uses=1]
25         %cst111 = cast bool %cond219 to uint           ; <uint> [#uses=1]
26         %reg113 = and uint %cst109, %cst111           ; <uint> [#uses=1]
27         %cst222 = cast uint %reg113 to bool             ; <int> [#uses=1]
28         ret bool %cst222
29 }
30
31 int %test4(int %A) {
32         %B = cast int %A to uint
33         %C = shl uint %B, ubyte 2
34         %D = cast uint %C to int
35         ret int %D
36 }
37
38 short %test5(short %A) {
39         %B = cast short %A to uint
40         %C = and uint %B, 15
41         %D = cast uint %C to short
42         ret short %D
43 }
44
45 bool %test6(bool %A) {
46         %B = cast bool %A to int
47         %C = setne int %B, 0
48         ret bool %C
49 }
50
51 bool %test6a(bool %A) {
52         %B = cast bool %A to int
53         %C = setne int %B, -1    ; Always true!
54         ret bool %C
55 }
56
57 bool %test7(sbyte* %A) {
58         %B = cast sbyte* %A to int*
59         %C = seteq int* %B, null
60         ret bool %C
61 }