Guozhi Wei | 433e8d3 | 2017-11-16 18:27:34 +0000 | [diff] [blame] | 1 | ; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr8 -verify-machineinstrs | FileCheck %s |
| 2 | |
| 3 | ; Test the same constant can be used by different stores. |
| 4 | |
| 5 | %struct.S = type { i64, i8, i16, i32 } |
| 6 | |
| 7 | define void @foo(%struct.S* %p) { |
| 8 | %l4 = bitcast %struct.S* %p to i64* |
| 9 | store i64 0, i64* %l4, align 8 |
| 10 | %c = getelementptr %struct.S, %struct.S* %p, i64 0, i32 1 |
| 11 | store i8 0, i8* %c, align 8 |
| 12 | %s = getelementptr %struct.S, %struct.S* %p, i64 0, i32 2 |
| 13 | store i16 0, i16* %s, align 2 |
| 14 | %i = getelementptr %struct.S, %struct.S* %p, i64 0, i32 3 |
| 15 | store i32 0, i32* %i, align 4 |
| 16 | ret void |
| 17 | |
| 18 | ; CHECK-LABEL: @foo |
| 19 | ; CHECK: li 4, 0 |
| 20 | ; CHECK: stb 4, 8(3) |
| 21 | ; CHECK: std 4, 0(3) |
| 22 | ; CHECK: sth 4, 10(3) |
| 23 | ; CHECK: stw 4, 12(3) |
| 24 | } |
| 25 | |
| 26 | define void @bar(%struct.S* %p) { |
| 27 | %i = getelementptr %struct.S, %struct.S* %p, i64 0, i32 3 |
| 28 | store i32 2, i32* %i, align 4 |
| 29 | %s = getelementptr %struct.S, %struct.S* %p, i64 0, i32 2 |
| 30 | store i16 2, i16* %s, align 2 |
| 31 | %c = getelementptr %struct.S, %struct.S* %p, i64 0, i32 1 |
| 32 | store i8 2, i8* %c, align 8 |
| 33 | %l4 = bitcast %struct.S* %p to i64* |
| 34 | store i64 2, i64* %l4, align 8 |
| 35 | ret void |
| 36 | |
| 37 | ; CHECK-LABEL: @bar |
| 38 | ; CHECK: li 4, 2 |
| 39 | ; CHECK: stw 4, 12(3) |
| 40 | ; CHECK: sth 4, 10(3) |
| 41 | ; CHECK: std 4, 0(3) |
| 42 | ; CHECK: stb 4, 8(3) |
| 43 | } |
| 44 | |