1; RUN: llc -march=hexagon -O3 -hexagon-small-data-threshold=0 < %s | FileCheck %s
2; This lit test validates that storetrunc for a 64bit value picks a store
3; absolute pattern instead of base + index store pattern. This will facilitate
4; the constant extender optimization pass to move the immediate value to a register
5; if there are more than two uses and replace all the uses of the constant.
6; Generation of absolute pattern for a 64 bit truncated value also aviods an
7; extra move.
8
9@g0 = external global i8, align 8
10@g1 = external global i16, align 8
11@g2 = external global i32, align 8
12
13; CHECK-LABEL: f0:
14; CHECK: memd(##441656) = r{{[0-9]+}}
15define void @f0(i64 %a0) #0 {
16b0:
17  store volatile i64 %a0, i64* inttoptr (i32 441656 to i64*)
18  ret void
19}
20
21; CHECK-LABEL: f1:
22; CHECK: memw(##441656) = r{{[0-9]+}}
23define void @f1(i64 %a0) #0 {
24b0:
25  %v0 = trunc i64 %a0 to i32
26  store volatile i32 %v0, i32* inttoptr (i32 441656 to i32*)
27  ret void
28}
29
30; CHECK-LABEL: f2:
31; CHECK: memh(##441656) = r{{[0-9]+}}
32define void @f2(i64 %a0) #0 {
33b0:
34  %v0 = trunc i64 %a0 to i16
35  store volatile i16 %v0, i16* inttoptr (i32 441656 to i16*)
36  ret void
37}
38
39; CHECK-LABEL: f3:
40; CHECK: memb(##441656) = r{{[0-9]+}}
41define void @f3(i64 %a0) #0 {
42b0:
43  %v0 = trunc i64 %a0 to i8
44  store volatile i8 %v0, i8* inttoptr (i32 441656 to i8*)
45  ret void
46}
47
48; CHECK-LABEL: f4:
49; CHECK: memw(##g2) = r{{[0-9]+}}
50define void @f4(i64 %a0) #0 {
51b0:
52  %v0 = trunc i64 %a0 to i32
53  store volatile i32 %v0, i32* @g2
54  ret void
55}
56
57; CHECK-LABEL: f5:
58; CHECK: memh(##g1) = r{{[0-9]+}}
59define void @f5(i64 %a0) #0 {
60b0:
61  %v0 = trunc i64 %a0 to i16
62  store volatile i16 %v0, i16* @g1
63  ret void
64}
65
66; CHECK-LABEL: f6:
67; CHECK: memb(##g0) = r{{[0-9]+}}
68define void @f6(i64 %a0) #0 {
69b0:
70  %v0 = trunc i64 %a0 to i8
71  store volatile i8 %v0, i8* @g0
72  ret void
73}
74
75attributes #0 = { nounwind }
76