Chris Lattner | 74e9547 | 2002-05-06 05:43:36 +0000 | [diff] [blame] | 1 | ; This test makes sure that these instructions are properly eliminated. |
| 2 | ; |
| 3 | |
Misha Brukman | edf4bab | 2003-09-16 15:29:54 +0000 | [diff] [blame] | 4 | ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep rem |
Chris Lattner | 74e9547 | 2002-05-06 05:43:36 +0000 | [diff] [blame] | 5 | |
| 6 | implementation |
| 7 | |
Chris Lattner | c5fccf3 | 2003-02-18 19:28:47 +0000 | [diff] [blame] | 8 | int %test1(int %A) { |
Chris Lattner | 74e9547 | 2002-05-06 05:43:36 +0000 | [diff] [blame] | 9 | %B = rem int %A, 1 ; ISA constant 0 |
| 10 | ret int %B |
| 11 | } |
| 12 | |
Chris Lattner | c5fccf3 | 2003-02-18 19:28:47 +0000 | [diff] [blame] | 13 | int %test2(int %A) { ; 0 % X = 0, we don't need ot 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 | } |
Chris Lattner | eca92d3 | 2004-07-06 07:38:00 +0000 | [diff] [blame] | 22 | |
| 23 | bool %test3(int %A) { |
| 24 | %B = rem int %A, -8 ; & 7 |
| 25 | %C = setne int %B, 0 |
| 26 | ret bool %C |
| 27 | } |
Chris Lattner | 9803a0a | 2004-12-12 21:40:22 +0000 | [diff] [blame] | 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 | } |
Chris Lattner | b624bb5 | 2006-02-05 07:52:47 +0000 | [diff] [blame^] | 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 | |