xref: /llvm-project/polly/test/CodeGen/MemAccess/multiple_types.ll (revision e1f056f692d869708c1898d9d65a69ac5584a0ed)
1; RUN: opt %loadNPMPolly -polly-stmt-granularity=bb '-passes=polly-import-jscop,polly-codegen' \
2; RUN: -polly-allow-differing-element-types \
3; RUN:   -S    < %s | FileCheck %s
4;
5;    // Check that accessing one array with different types works.
6;    void multiple_types(char *Short, char *Float, char *Double) {
7;      for (long i = 0; i < 100; i++) {
8;        Short[i] = *(short *)&Short[2 * i];
9;        Float[i] = *(float *)&Float[4 * i];
10;        Double[i] = *(double *)&Double[8 * i];
11;      }
12;    }
13
14; Short[0]
15; CHECK: %polly.access.Short10 = getelementptr i8, ptr %Short, i64 0
16; CHECK: %tmp5_p_scalar_ = load i16, ptr %polly.access.Short10
17
18; Float[8 * i]
19; CHECK: %24 = mul nsw i64 8, %polly.indvar
20; CHECK: %polly.access.Float11 = getelementptr i8, ptr %Float, i64 %24
21; CHECK: %tmp11_p_scalar_ = load float, ptr %polly.access.Float11
22
23; Double[8]
24; CHECK: %polly.access.Double13 = getelementptr i8, ptr %Double, i64 8
25; CHECK: %tmp17_p_scalar_ = load double, ptr %polly.access.Double13
26
27target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
28
29define void @multiple_types(ptr %Short, ptr %Float, ptr %Double) {
30bb:
31  br label %bb1
32
33bb1:                                              ; preds = %bb20, %bb
34  %i.0 = phi i64 [ 0, %bb ], [ %tmp21, %bb20 ]
35  %exitcond = icmp ne i64 %i.0, 100
36  br i1 %exitcond, label %bb2, label %bb22
37
38bb2:                                              ; preds = %bb1
39  %tmp = shl nsw i64 %i.0, 1
40  %tmp3 = getelementptr inbounds i8, ptr %Short, i64 %tmp
41  %tmp5 = load i16, ptr %tmp3, align 2
42  %tmp6 = trunc i16 %tmp5 to i8
43  %tmp7 = getelementptr inbounds i8, ptr %Short, i64 %i.0
44  store i8 %tmp6, ptr %tmp7, align 1
45  %tmp8 = shl nsw i64 %i.0, 2
46  %tmp9 = getelementptr inbounds i8, ptr %Float, i64 %tmp8
47  %tmp11 = load float, ptr %tmp9, align 4
48  %tmp12 = fptosi float %tmp11 to i8
49  %tmp13 = getelementptr inbounds i8, ptr %Float, i64 %i.0
50  store i8 %tmp12, ptr %tmp13, align 1
51  %tmp14 = shl nsw i64 %i.0, 3
52  %tmp15 = getelementptr inbounds i8, ptr %Double, i64 %tmp14
53  %tmp17 = load double, ptr %tmp15, align 8
54  %tmp18 = fptosi double %tmp17 to i8
55  %tmp19 = getelementptr inbounds i8, ptr %Double, i64 %i.0
56  store i8 %tmp18, ptr %tmp19, align 1
57  br label %bb20
58
59bb20:                                             ; preds = %bb2
60  %tmp21 = add nuw nsw i64 %i.0, 1
61  br label %bb1
62
63bb22:                                             ; preds = %bb1
64  ret void
65}
66