1 ; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-linux-gnu -mattr=+altivec < %s | FileCheck %s
3 ;; This test ensures that MergeConsecutiveStores does not attempt to
4 ;; merge stores or loads when doing so would result in unaligned
5 ;; memory operations (unless the target supports those, e.g. X86).
7 ;; This issue happen in other situations for other targets, but PPC
8 ;; with Altivec extensions was chosen for the test because it does not
9 ;; support unaligned access with AltiVec instructions. If the 4
10 ;; load/stores get merged to an v4i32 vector type severely bad code
11 ;; gets generated: it painstakingly copies the values to a temporary
12 ;; location on the stack, with vector ops, in order to then use
13 ;; integer ops to load from the temporary stack location and store to
14 ;; the final location. Yuck!
16 %struct.X = type { i32, i32, i32, i32 }
18 @fx = common global %struct.X zeroinitializer, align 4
19 @fy = common global %struct.X zeroinitializer, align 4
21 ;; In this test case, lvx and stvx instructions should NOT be
22 ;; generated, as the alignment is not sufficient for it to be
37 %0 = load i32, ptr @fx, align 4
38 %1 = load i32, ptr getelementptr inbounds (%struct.X, ptr @fx, i32 0, i32 1), align 4
39 %2 = load i32, ptr getelementptr inbounds (%struct.X, ptr @fx, i32 0, i32 2), align 4
40 %3 = load i32, ptr getelementptr inbounds (%struct.X, ptr @fx, i32 0, i32 3), align 4
41 store i32 %0, ptr @fy, align 4
42 store i32 %1, ptr getelementptr inbounds (%struct.X, ptr @fy, i32 0, i32 1), align 4
43 store i32 %2, ptr getelementptr inbounds (%struct.X, ptr @fy, i32 0, i32 2), align 4
44 store i32 %3, ptr getelementptr inbounds (%struct.X, ptr @fy, i32 0, i32 3), align 4
48 @gx = common global %struct.X zeroinitializer, align 16
49 @gy = common global %struct.X zeroinitializer, align 16
51 ;; In this test, lvx and stvx instructions SHOULD be generated, as
52 ;; the 16-byte alignment of the new load/store is acceptable.
59 %0 = load i32, ptr @fx, align 16
60 %1 = load i32, ptr getelementptr inbounds (%struct.X, ptr @fx, i32 0, i32 1), align 4
61 %2 = load i32, ptr getelementptr inbounds (%struct.X, ptr @fx, i32 0, i32 2), align 4
62 %3 = load i32, ptr getelementptr inbounds (%struct.X, ptr @fx, i32 0, i32 3), align 4
63 store i32 %0, ptr @fy, align 16
64 store i32 %1, ptr getelementptr inbounds (%struct.X, ptr @fy, i32 0, i32 1), align 4
65 store i32 %2, ptr getelementptr inbounds (%struct.X, ptr @fy, i32 0, i32 2), align 4
66 store i32 %3, ptr getelementptr inbounds (%struct.X, ptr @fy, i32 0, i32 3), align 4