2003-11-03 06:30:34 +01:00
|
|
|
; This tests for various complex cast elimination cases instcombine should
|
|
|
|
; handle.
|
2002-08-12 21:18:49 +02:00
|
|
|
|
2006-12-02 05:23:10 +01:00
|
|
|
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | notcast
|
2002-05-15 19:22:01 +02:00
|
|
|
|
2002-08-15 21:38:03 +02:00
|
|
|
bool %test1(int %X) {
|
2002-05-15 19:22:01 +02:00
|
|
|
%A = cast int %X to uint
|
2003-07-24 01:21:08 +02:00
|
|
|
%c = setne uint %A, 12 ; Convert to setne int %X, 12
|
2002-05-15 19:22:01 +02:00
|
|
|
ret bool %c
|
|
|
|
}
|
|
|
|
|
2002-08-15 21:38:03 +02:00
|
|
|
bool %test2(int %X, int %Y) {
|
2002-05-15 19:22:01 +02:00
|
|
|
%A = cast int %X to uint
|
|
|
|
%B = cast int %Y to uint
|
|
|
|
%c = setne uint %A, %B ; Convert to setne int %X, %Y
|
|
|
|
ret bool %c
|
|
|
|
}
|
|
|
|
|
2003-03-05 23:50:55 +01:00
|
|
|
int %test4(int %A) {
|
|
|
|
%B = cast int %A to uint
|
2003-07-24 01:21:08 +02:00
|
|
|
%C = shl uint %B, ubyte 2
|
2003-03-05 23:50:55 +01:00
|
|
|
%D = cast uint %C to int
|
|
|
|
ret int %D
|
|
|
|
}
|
|
|
|
|
2003-07-24 01:21:08 +02:00
|
|
|
short %test5(short %A) {
|
|
|
|
%B = cast short %A to uint
|
|
|
|
%C = and uint %B, 15
|
|
|
|
%D = cast uint %C to short
|
|
|
|
ret short %D
|
|
|
|
}
|
2003-11-03 04:51:26 +01:00
|
|
|
|
|
|
|
bool %test6(bool %A) {
|
|
|
|
%B = cast bool %A to int
|
|
|
|
%C = setne int %B, 0
|
|
|
|
ret bool %C
|
|
|
|
}
|
2003-11-03 04:52:34 +01:00
|
|
|
|
2003-11-03 06:08:53 +01:00
|
|
|
bool %test6a(bool %A) {
|
|
|
|
%B = cast bool %A to int
|
|
|
|
%C = setne int %B, -1 ; Always true!
|
|
|
|
ret bool %C
|
|
|
|
}
|
|
|
|
|
2003-11-03 04:52:34 +01:00
|
|
|
bool %test7(sbyte* %A) {
|
|
|
|
%B = cast sbyte* %A to int*
|
|
|
|
%C = seteq int* %B, null
|
|
|
|
ret bool %C
|
|
|
|
}
|