Reid Spencer | d7c2c2f | 2006-12-02 20:34:08 +0000 | [diff] [blame] | 1 | ; This test checks to make sure that constant exprs fold in some simple |
| 2 | ; situations |
Chris Lattner | 75d1412 | 2004-01-13 05:32:27 +0000 | [diff] [blame] | 3 | |
Reid Spencer | 43b4003 | 2007-04-16 15:31:49 +0000 | [diff] [blame^] | 4 | ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis | not grep {(} |
Chris Lattner | 75d1412 | 2004-01-13 05:32:27 +0000 | [diff] [blame] | 5 | |
| 6 | %A = global long 0 |
| 7 | |
| 8 | global long* cast (long add (long cast (long* %A to long), long 0) to long*) ; X + 0 == X |
| 9 | global long* cast (long sub (long cast (long* %A to long), long 0) to long*) ; X - 0 == X |
| 10 | global long* cast (long mul (long cast (long* %A to long), long 0) to long*) ; X * 0 == 0 |
| 11 | global long* cast (long div (long cast (long* %A to long), long 1) to long*) ; X / 1 == X |
| 12 | global long* cast (long rem (long cast (long* %A to long), long 1) to long*) ; X % 1 == 0 |
| 13 | global long* cast (long and (long cast (long* %A to long), long 0) to long*) ; X & 0 == 0 |
| 14 | global long* cast (long and (long cast (long* %A to long), long -1) to long*) ; X & -1 == X |
| 15 | global long or (long cast (long* %A to long), long -1) ; X | -1 == -1 |
| 16 | global long* cast (long xor (long cast (long* %A to long), long 0) to long*) ; X ^ 0 == X |
| 17 | |
| 18 | %Ty = type { int, int } |
| 19 | %B = external global %Ty |
| 20 | |
| 21 | global bool setlt (long* %A, long* getelementptr (long* %A, long 1)) ; true |
| 22 | global bool setlt (long* %A, long* getelementptr (long* %A, long 0)) ; false |
Reid Spencer | e5d4efa | 2006-11-23 15:14:52 +0000 | [diff] [blame] | 23 | global bool setlt (int* getelementptr (%Ty* %B, long 0, uint 0), |
| 24 | int* getelementptr (%Ty* %B, long 0, uint 1)) ; true |
Chris Lattner | 28d85f1 | 2004-07-08 15:38:23 +0000 | [diff] [blame] | 25 | ;global bool setne (long* %A, long* cast (%Ty* %B to long*)) ; true |
Chris Lattner | 75d1412 | 2004-01-13 05:32:27 +0000 | [diff] [blame] | 26 | |
Chris Lattner | 63540f5 | 2006-01-05 07:46:46 +0000 | [diff] [blame] | 27 | global bool seteq ({ short }* cast (int 1 to { short }*), { short }* null) |
| 28 | global bool setlt ({ short }* cast (int 1 to { short }*), { short }* cast (int 2 to { short }*)) |
| 29 | |