blob: 801aa1bfc5086832f2e794dfa163dcf65cd0355c [file] [log] [blame]
Chris Lattnere600cec2003-11-03 05:30:34 +00001; This tests for various complex cast elimination cases instcombine should
2; handle.
Chris Lattner593a74a2002-08-12 19:18:49 +00003
Reid Spencerd0e30dc2006-12-02 04:23:10 +00004; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | notcast
Chris Lattner4b474fc562002-05-15 17:22:01 +00005
Chris Lattner4a161102002-08-15 19:38:03 +00006bool %test1(int %X) {
Chris Lattner4b474fc562002-05-15 17:22:01 +00007 %A = cast int %X to uint
Chris Lattner14f75222003-07-23 23:21:08 +00008 %c = setne uint %A, 12 ; Convert to setne int %X, 12
Chris Lattner4b474fc562002-05-15 17:22:01 +00009 ret bool %c
10}
11
Chris Lattner4a161102002-08-15 19:38:03 +000012bool %test2(int %X, int %Y) {
Chris Lattner4b474fc562002-05-15 17:22:01 +000013 %A = cast int %X to uint
14 %B = cast int %Y to uint
15 %c = setne uint %A, %B ; Convert to setne int %X, %Y
16 ret bool %c
17}
18
Chris Lattner1d485282003-03-05 22:50:55 +000019int %test4(int %A) {
20 %B = cast int %A to uint
Chris Lattner14f75222003-07-23 23:21:08 +000021 %C = shl uint %B, ubyte 2
Chris Lattner1d485282003-03-05 22:50:55 +000022 %D = cast uint %C to int
23 ret int %D
24}
25
Chris Lattner14f75222003-07-23 23:21:08 +000026short %test5(short %A) {
27 %B = cast short %A to uint
28 %C = and uint %B, 15
29 %D = cast uint %C to short
30 ret short %D
31}
Chris Lattnerc75cfac2003-11-03 03:51:26 +000032
33bool %test6(bool %A) {
34 %B = cast bool %A to int
35 %C = setne int %B, 0
36 ret bool %C
37}
Chris Lattnerefde7682003-11-03 03:52:34 +000038
Chris Lattner11bea4f2003-11-03 05:08:53 +000039bool %test6a(bool %A) {
40 %B = cast bool %A to int
41 %C = setne int %B, -1 ; Always true!
42 ret bool %C
43}
44
Chris Lattnerefde7682003-11-03 03:52:34 +000045bool %test7(sbyte* %A) {
46 %B = cast sbyte* %A to int*
47 %C = seteq int* %B, null
48 ret bool %C
49}