Tanya Lattner | 2393a24 | 2004-11-06 23:08:26 +0000 | [diff] [blame^] | 1 | ; RUN: llvm-as -f %s -o - | llc |
| 2 | |
Vikram S. Adve | 6781cd2 | 2003-07-10 19:31:26 +0000 | [diff] [blame] | 3 | ;; Date: Jul 8, 2003. |
| 4 | ;; From: test/Programs/MultiSource/Olden-perimeter |
| 5 | ;; Function: int %adj(uint %d.1, uint %ct.1) |
| 6 | ;; |
| 7 | ;; Errors: (1) cast-int-to-bool was being treated as a NOP (i.e., the int |
| 8 | ;; register was treated as effectively true if non-zero). |
| 9 | ;; This cannot be used for later boolean operations. |
| 10 | ;; (2) (A or NOT(B)) was being folded into A orn B, which is ok |
| 11 | ;; for bitwise operations but not booleans! For booleans, |
| 12 | ;; the result has to be compared with 0. |
| 13 | ;; |
| 14 | ;; LLC Output for the basic block (LLVM assembly is shown below): |
| 15 | ;; |
| 16 | ;; .L_adj_7_LL_4: |
| 17 | ;; sethi 0, %i0 |
| 18 | ;; subcc %i1, 2, %g0 |
| 19 | ;; move %icc, 1, %i0 |
| 20 | ;; orn %i0, %i1, %i0 |
| 21 | ;; ba .L_adj_7_LL_5 |
| 22 | ;; nop |
| 23 | ;; |
| 24 | |
| 25 | |
Vikram S. Adve | f2e343b | 2003-07-08 15:39:02 +0000 | [diff] [blame] | 26 | target endian = big |
| 27 | target pointersize = 64 |
| 28 | |
| 29 | %.str_1 = internal constant [30 x sbyte] c"d = %d, ct = %d, d ^ ct = %d\0A\00" |
| 30 | |
| 31 | |
| 32 | implementation ; Functions: |
| 33 | |
| 34 | declare int %printf(sbyte*, ...) |
| 35 | |
| 36 | int %adj(uint %d.1, uint %ct.1) { |
| 37 | entry: |
| 38 | %tmp.19 = seteq uint %ct.1, 2 |
| 39 | %tmp.22.not = cast uint %ct.1 to bool |
| 40 | %tmp.221 = xor bool %tmp.22.not, true |
| 41 | %tmp.26 = or bool %tmp.19, %tmp.221 |
| 42 | %tmp.27 = cast bool %tmp.26 to int |
| 43 | ret int %tmp.27 |
| 44 | } |
| 45 | |
| 46 | int %main() { |
| 47 | entry: |
| 48 | %result = call int %adj(uint 3, uint 2) |
| 49 | %tmp.0 = call int (sbyte*, ...)* %printf( sbyte* getelementptr ([30 x sbyte]* %.str_1, long 0, long 0), uint 3, uint 2, int %result) |
| 50 | ret int 0 |
| 51 | } |