summaryrefslogtreecommitdiff
path: root/test/Transforms/LevelRaise/2002-05-02-BadCastElimination.ll
blob: 444d9d423648bd57bc130f19b431b3d154246fdc (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
; This test contains two cast instructions that cannot be eliminated.  If the
; input of the "test" function is negative, it should be correctly converted
; to a 32 bit version of the number with all upper 16 bits clear (ushort->uint
; involves no sign extension).  Optimizing this to a single cast is invalid!
;
; RUN: llvm-upgrade < %s | llvm-as | opt -raise -q | lli 
;
implementation

uint "test"(short %argc)
begin
	%cast223 = cast short %argc to ushort		; <ushort> [#uses=1]
	%cast114 = cast ushort %cast223 to uint		; <uint> [#uses=1]
	ret uint %cast114
end

int "main"()
begin
	%Ret = call uint %test(short -1)
	%test = cast uint %Ret to int
	%Res = seteq int %test, -1        ; If it returns -1 as int, it's a failure
	%Res = cast bool %Res to int
	ret int %Res
end