For PR950:
[oota-llvm.git] / test / Transforms / LevelRaise / 2002-05-02-BadCastElimination.ll
1 ; This test contains two cast instructions that cannot be eliminated.  If the
2 ; input of the "test" function is negative, it should be correctly converted
3 ; to a 32 bit version of the number with all upper 16 bits clear (ushort->uint
4 ; involves no sign extension).  Optimizing this to a single cast is invalid!
5 ;
6 ; RUN: llvm-as < %s | opt -raise -q | lli 
7 ;
8 implementation
9
10 uint "test"(short %argc)
11 begin
12         %cast223 = cast short %argc to ushort           ; <ushort> [#uses=1]
13         %cast114 = cast ushort %cast223 to uint         ; <uint> [#uses=1]
14         ret uint %cast114
15 end
16
17 int "main"()
18 begin
19         %Ret = call uint %test(short -1)
20         %test = cast uint %Ret to int
21         %Res = seteq int %test, -1        ; If it returns -1 as int, it's a failure
22         %Res = cast bool %Res to int
23         ret int %Res
24 end