Fix InstCombine/2007-10-31-StringCrash.ll by removing an obvious
[oota-llvm.git] / test / Transforms / InstCombine / rem.ll
1 ; This test makes sure that these instructions are properly eliminated.
2 ;
3 ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | not grep rem
4 ; END.
5
6 implementation
7
8 int %test1(int %A) {
9         %B = rem int %A, 1    ; ISA constant 0
10         ret int %B
11 }
12
13 int %test2(int %A) {          ; 0 % X = 0, we don't need to preserve traps
14         %B = rem int 0, %A
15         ret int %B
16 }
17
18 uint %test3(uint %A) {
19         %B = rem uint %A, 8   ; & 7
20         ret uint %B
21 }
22
23 bool %test3a(int %A) {
24         %B = rem int %A, -8   ; & 7
25         %C = setne int %B, 0
26         ret bool %C
27 }
28
29 uint %test4(uint %X, bool %C) {
30         %V = select bool %C, uint 1, uint 8
31         %R = rem uint %X, %V
32         ret uint %R
33 }
34
35 uint %test5(uint %X, ubyte %B) {
36         %Amt = shl uint 32, ubyte %B
37         %V = rem uint %X, %Amt
38         ret uint %V
39 }
40
41 int %test6(int %A) {
42         %B = rem int %A, 0   ;; undef
43         ret int %B
44 }
45
46 int %test7(int %A) {
47         %B = mul int %A, 26
48         %C = rem int %B, 13
49         ret int %C
50 }
51
52 int %test8(int %A) {
53         %B = shl int %A, ubyte 4
54         %C = rem int %B, 8 
55         ret int %C
56 }
57
58 uint %test9(uint %A) {
59         %B = mul uint %A, 124
60         %C = rem uint %B, 62 
61         ret uint %C
62 }
63
64 int %test10(ubyte %c) {
65         %tmp.1 = cast ubyte %c to int
66         %tmp.2 = mul int %tmp.1, 3
67         %tmp.3 = cast int %tmp.2 to ulong
68         %tmp.5 = rem ulong %tmp.3, 3
69         %tmp.6 = cast ulong %tmp.5 to int
70         ret int %tmp.6
71 }
72
73 int %test11(int %i) {
74         %tmp.1 = and int %i, -2
75         %tmp.3 = mul int %tmp.1, 3
76         %tmp.5 = rem int %tmp.3, 6
77         ret int %tmp.5
78 }
79