blob: 1e4b537c25781d7ae6865e92ca4977708d8cdccd [file] [log] [blame]
Chris Lattner593a74a2002-08-12 19:18:49 +00001; 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
Misha Brukmanedf4bab2003-09-16 15:29:54 +00006; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep cast
Chris Lattner4b474fc562002-05-15 17:22:01 +00007
Chris Lattner4a161102002-08-15 19:38:03 +00008bool %test1(int %X) {
Chris Lattner4b474fc562002-05-15 17:22:01 +00009 %A = cast int %X to uint
Chris Lattner14f75222003-07-23 23:21:08 +000010 %c = setne uint %A, 12 ; Convert to setne int %X, 12
Chris Lattner4b474fc562002-05-15 17:22:01 +000011 ret bool %c
12}
13
Chris Lattner4a161102002-08-15 19:38:03 +000014bool %test2(int %X, int %Y) {
Chris Lattner4b474fc562002-05-15 17:22:01 +000015 %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
Chris Lattner4a161102002-08-15 19:38:03 +000021bool %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
Chris Lattner1d485282003-03-05 22:50:55 +000031int %test4(int %A) {
32 %B = cast int %A to uint
Chris Lattner14f75222003-07-23 23:21:08 +000033 %C = shl uint %B, ubyte 2
Chris Lattner1d485282003-03-05 22:50:55 +000034 %D = cast uint %C to int
35 ret int %D
36}
37
Chris Lattner14f75222003-07-23 23:21:08 +000038short %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}
Chris Lattnerc75cfac2003-11-03 03:51:26 +000044
45bool %test6(bool %A) {
46 %B = cast bool %A to int
47 %C = setne int %B, 0
48 ret bool %C
49}
Chris Lattnerefde7682003-11-03 03:52:34 +000050
Chris Lattner11bea4f2003-11-03 05:08:53 +000051bool %test6a(bool %A) {
52 %B = cast bool %A to int
53 %C = setne int %B, -1 ; Always true!
54 ret bool %C
55}
56
Chris Lattnerefde7682003-11-03 03:52:34 +000057bool %test7(sbyte* %A) {
58 %B = cast sbyte* %A to int*
59 %C = seteq int* %B, null
60 ret bool %C
61}