| 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. | 
|  | 3 |  | 
| Reid Spencer | 985e52f | 2007-01-13 05:06:52 +0000 | [diff] [blame] | 4 | ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \ | 
|  | 5 | ; RUN:    grep 'ret i1 false' | 
| Chris Lattner | 5e488c9 | 2006-02-12 02:02:43 +0000 | [diff] [blame] | 6 |  | 
|  | 7 | ; test1 - Eliminating the casts in this testcase (by narrowing the AND | 
|  | 8 | ; operation) allows instcombine to realize the function always returns false. | 
|  | 9 | ; | 
|  | 10 | bool %test1(int %A, int %B) { | 
|  | 11 | %C1 = setlt int %A, %B | 
| Reid Spencer | 6c38f0b | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 12 | %ELIM1 = zext bool %C1 to uint | 
| Chris Lattner | 5e488c9 | 2006-02-12 02:02:43 +0000 | [diff] [blame] | 13 | %C2 = setgt int %A, %B | 
| Reid Spencer | 6c38f0b | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 14 | %ELIM2 = zext bool %C2 to uint | 
| Chris Lattner | 5e488c9 | 2006-02-12 02:02:43 +0000 | [diff] [blame] | 15 | %C3 = and uint %ELIM1, %ELIM2 | 
| Reid Spencer | 6c38f0b | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 16 | %ELIM3 = trunc uint %C3 to bool | 
| Chris Lattner | 5e488c9 | 2006-02-12 02:02:43 +0000 | [diff] [blame] | 17 | ret bool %ELIM3 | 
|  | 18 | } |