Chris Lattner | 5e488c9 | 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. |
Reid Spencer | 985e52f | 2007-01-13 05:06:52 +0000 | [diff] [blame] | 3 | ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \ |
Reid Spencer | 91948d4 | 2007-04-14 20:13:02 +0000 | [diff] [blame] | 4 | ; RUN: grep {ret i1 false} |
Chris Lattner | 5e488c9 | 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 | 6c38f0b | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 11 | %ELIM1 = zext bool %C1 to uint |
Chris Lattner | 5e488c9 | 2006-02-12 02:02:43 +0000 | [diff] [blame] | 12 | %C2 = setgt int %A, %B |
Reid Spencer | 6c38f0b | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 13 | %ELIM2 = zext bool %C2 to uint |
Chris Lattner | 5e488c9 | 2006-02-12 02:02:43 +0000 | [diff] [blame] | 14 | %C3 = and uint %ELIM1, %ELIM2 |
Reid Spencer | 6c38f0b | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 15 | %ELIM3 = trunc uint %C3 to bool |
Chris Lattner | 5e488c9 | 2006-02-12 02:02:43 +0000 | [diff] [blame] | 16 | ret bool %ELIM3 |
| 17 | } |