blob: 00705aa4750e462ed977ecce8aa0a66e56d895f6 [file] [log] [blame]
Chris Lattner74e95472002-05-06 05:43:36 +00001; This test makes sure that these instructions are properly eliminated.
2;
Reid Spencerd0e30dc2006-12-02 04:23:10 +00003; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine -disable-output &&
4; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | not grep rem
Chris Lattner74e95472002-05-06 05:43:36 +00005
6implementation
7
Chris Lattnerc5fccf32003-02-18 19:28:47 +00008int %test1(int %A) {
Chris Lattner74e95472002-05-06 05:43:36 +00009 %B = rem int %A, 1 ; ISA constant 0
10 ret int %B
11}
12
Chris Lattner626f9642006-02-28 05:30:48 +000013int %test2(int %A) { ; 0 % X = 0, we don't need to preserve traps
Chris Lattnerc5fccf32003-02-18 19:28:47 +000014 %B = rem int 0, %A
15 ret int %B
16}
17
18uint %test3(uint %A) {
19 %B = rem uint %A, 8 ; & 7
20 ret uint %B
21}
Chris Lattnereca92d32004-07-06 07:38:00 +000022
Reid Spenceraf6a4082007-01-30 16:16:01 +000023bool %test3a(int %A) {
Chris Lattnereca92d32004-07-06 07:38:00 +000024 %B = rem int %A, -8 ; & 7
25 %C = setne int %B, 0
26 ret bool %C
27}
Chris Lattner9803a0a2004-12-12 21:40:22 +000028
29uint %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}
Chris Lattnerb624bb52006-02-05 07:52:47 +000034
35uint %test5(uint %X, ubyte %B) {
36 %Amt = shl uint 32, ubyte %B
37 %V = rem uint %X, %Amt
38 ret uint %V
39}
40
Chris Lattner626f9642006-02-28 05:30:48 +000041int %test6(int %A) {
42 %B = rem int %A, 0 ;; undef
43 ret int %B
44}
Chris Lattner30591282006-02-28 05:48:56 +000045
46int %test7(int %A) {
47 %B = mul int %A, 26
48 %C = rem int %B, 13
49 ret int %C
50}
51
52int %test8(int %A) {
53 %B = shl int %A, ubyte 4
54 %C = rem int %B, 8
55 ret int %C
56}
57
58uint %test9(uint %A) {
59 %B = mul uint %A, 124
60 %C = rem uint %B, 62
61 ret uint %C
62}
Chris Lattnerdad25c72006-03-02 06:50:04 +000063
64int %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
73int %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