| Andrew Lenharth | 731f2d5 | 2006-09-19 18:23:39 +0000 | [diff] [blame] | 1 | ; Tests to make sure elimination of casts is working correctly |
| Reid Spencer | d0e30dc | 2006-12-02 04:23:10 +0000 | [diff] [blame] | 2 | ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine -disable-output && |
| Andrew Lenharth | f7a5332 | 2007-02-22 15:17:45 +0000 | [diff] [blame^] | 3 | ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | not grep '\([sz]ext\)\|\(trunc\)|\(ptrtoint\)' |
| Andrew Lenharth | 731f2d5 | 2006-09-19 18:23:39 +0000 | [diff] [blame] | 4 | |
| 5 | target pointersize = 32 |
| 6 | |
| 7 | implementation |
| 8 | |
| 9 | sbyte* %test1(sbyte* %t) { |
| 10 | %tmpc = cast sbyte* %t to uint |
| 11 | %tmpa = add uint %tmpc, 32 |
| 12 | %tv = cast uint %tmpa to sbyte* |
| 13 | ret sbyte* %tv |
| 14 | } |
| 15 | |
| Andrew Lenharth | f7a5332 | 2007-02-22 15:17:45 +0000 | [diff] [blame^] | 16 | bool %test2(sbyte* %a, sbyte* %b) { |
| 17 | %tmpa = cast sbyte* %a to uint |
| 18 | %tmpb = cast sbyte* %b to uint |
| 19 | %r = seteq uint %tmpa, %tmpb |
| 20 | ret bool %r |
| 21 | } |