Chris Lattner | ecd9653 | 2006-02-12 02:02:43 +0000 | [diff] [blame] | 1 | ; This file contains various testcases that check to see that instcombine |
| 2 | ; is narrowing computations when possible. |
| 3 | |
Chris Lattner | eaee5f5 | 2006-05-07 18:16:31 +0000 | [diff] [blame] | 4 | ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep 'ret bool false' |
Chris Lattner | ecd9653 | 2006-02-12 02:02:43 +0000 | [diff] [blame] | 5 | |
| 6 | ; test1 - Eliminating the casts in this testcase (by narrowing the AND |
| 7 | ; operation) allows instcombine to realize the function always returns false. |
| 8 | ; |
| 9 | bool %test1(int %A, int %B) { |
| 10 | %C1 = setlt int %A, %B |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 11 | %ELIM1 = zext bool %C1 to uint |
Chris Lattner | ecd9653 | 2006-02-12 02:02:43 +0000 | [diff] [blame] | 12 | %C2 = setgt int %A, %B |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 13 | %ELIM2 = zext bool %C2 to uint |
Chris Lattner | ecd9653 | 2006-02-12 02:02:43 +0000 | [diff] [blame] | 14 | %C3 = and uint %ELIM1, %ELIM2 |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 15 | %ELIM3 = trunc uint %C3 to bool |
Chris Lattner | ecd9653 | 2006-02-12 02:02:43 +0000 | [diff] [blame] | 16 | ret bool %ELIM3 |
| 17 | } |