1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-01 08:23:21 +01:00
llvm-mirror/test/Transforms/InstCombine/signext.ll
Reid Spencer 591bfa1e0b Changes to support making the shift instructions be true BinaryOperators.
This feature is needed in order to support shifts of more than 255 bits
on large integer types.  This changes the syntax for llvm assembly to
make shl, ashr and lshr instructions look like a binary operator:
   shl i32 %X, 1
instead of
   shl i32 %X, i8 1
Additionally, this should help a few passes perform additional optimizations.

llvm-svn: 33776
2007-02-02 02:16:23 +00:00

45 lines
1.5 KiB
LLVM

; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine -disable-output &&
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \
; RUN: not grep '(and\|xor\|add\|shl\|shr)'
int %test1(int %x) {
%tmp.1 = and int %x, 65535 ; <int> [#uses=1]
%tmp.2 = xor int %tmp.1, -32768 ; <int> [#uses=1]
%tmp.3 = add int %tmp.2, 32768 ; <int> [#uses=1]
ret int %tmp.3
}
int %test2(int %x) {
%tmp.1 = and int %x, 65535 ; <int> [#uses=1]
%tmp.2 = xor int %tmp.1, 32768 ; <int> [#uses=1]
%tmp.3 = add int %tmp.2, -32768 ; <int> [#uses=1]
ret int %tmp.3
}
int %test3(ushort %P) {
%tmp.1 = cast ushort %P to int ; <int> [#uses=1]
%tmp.4 = xor int %tmp.1, 32768 ; <int> [#uses=1]
%tmp.5 = add int %tmp.4, -32768 ; <int> [#uses=1]
ret int %tmp.5
}
uint %test4(ushort %P) {
%tmp.1 = cast ushort %P to uint ; <uint> [#uses=1]
%tmp.4 = xor uint %tmp.1, 32768 ; <uint> [#uses=1]
%tmp.5 = add uint %tmp.4, 4294934528 ; <uint> [#uses=1]
ret uint %tmp.5
}
int %test5(int %x) {
%tmp.1 = and int %x, 254
%tmp.2 = xor int %tmp.1, 128
%tmp.3 = add int %tmp.2, -128
ret int %tmp.3
}
int %test6(int %x) {
%tmp.2 = shl int %x, ubyte 16 ; <int> [#uses=1]
%tmp.4 = shr int %tmp.2, ubyte 16 ; <int> [#uses=1]
ret int %tmp.4
}