Reid Spencer | 6df4c45 | 2007-01-20 08:31:45 +0000 | [diff] [blame] | 1 | ; RUN: llvm-as %s -o - | llvm-dis > %t1.ll |
| 2 | ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll |
| 3 | ; RUN: diff %t1.ll %t2.ll |
Eli Bendersky | 5fcba11 | 2013-04-08 20:18:15 +0000 | [diff] [blame] | 4 | ; RUN: llvm-as < %s | lli --force-interpreter=true | FileCheck %s |
| 5 | ; CHECK: -255 |
Reid Spencer | 6df4c45 | 2007-01-20 08:31:45 +0000 | [diff] [blame] | 6 | |
Reid Spencer | e3ff5ad | 2007-01-26 08:25:06 +0000 | [diff] [blame] | 7 | @ARRAY = global [ 20 x i17 ] zeroinitializer |
| 8 | @FORMAT = constant [ 4 x i8 ] c"%d\0A\00" |
Reid Spencer | 6df4c45 | 2007-01-20 08:31:45 +0000 | [diff] [blame] | 9 | |
Reid Spencer | e3ff5ad | 2007-01-26 08:25:06 +0000 | [diff] [blame] | 10 | declare i32 @printf(i8* %format, ...) |
Reid Spencer | 6df4c45 | 2007-01-20 08:31:45 +0000 | [diff] [blame] | 11 | |
Reid Spencer | e3ff5ad | 2007-01-26 08:25:06 +0000 | [diff] [blame] | 12 | define void @multiply(i32 %index, i32 %X, i32 %Y) { |
Reid Spencer | 6df4c45 | 2007-01-20 08:31:45 +0000 | [diff] [blame] | 13 | %Z = mul i32 %X, %Y |
David Blaikie | 198d8ba | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 14 | %P = getelementptr [20 x i17], [20 x i17]* @ARRAY, i32 0, i32 %index |
Reid Spencer | 6df4c45 | 2007-01-20 08:31:45 +0000 | [diff] [blame] | 15 | %Result = trunc i32 %Z to i17 |
| 16 | store i17 %Result, i17* %P |
| 17 | ret void |
| 18 | } |
| 19 | |
Reid Spencer | 9085043 | 2007-01-30 16:16:01 +0000 | [diff] [blame] | 20 | define i32 @main(i32 %argc, i8** %argv) { |
Reid Spencer | 6df4c45 | 2007-01-20 08:31:45 +0000 | [diff] [blame] | 21 | %i = bitcast i32 0 to i32 |
Reid Spencer | e3ff5ad | 2007-01-26 08:25:06 +0000 | [diff] [blame] | 22 | call void @multiply(i32 %i, i32 -1, i32 255) |
David Blaikie | 198d8ba | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 23 | %P = getelementptr [20 x i17], [20 x i17]* @ARRAY, i32 0, i32 0 |
David Blaikie | 7c9c6ed | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 24 | %X = load i17, i17* %P |
Reid Spencer | 6df4c45 | 2007-01-20 08:31:45 +0000 | [diff] [blame] | 25 | %result = sext i17 %X to i32 |
David Blaikie | 198d8ba | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 26 | %fmt = getelementptr [4 x i8], [4 x i8]* @FORMAT, i32 0, i32 0 |
David Blaikie | 32b845d | 2015-04-16 23:24:18 +0000 | [diff] [blame] | 27 | call i32 (i8*,...) @printf(i8* %fmt, i32 %result) |
Reid Spencer | ff0f877 | 2007-04-14 16:48:55 +0000 | [diff] [blame] | 28 | ret i32 0 |
Reid Spencer | 6df4c45 | 2007-01-20 08:31:45 +0000 | [diff] [blame] | 29 | } |
| 30 | |