xref: /llvm-project/llvm/test/CodeGen/ARM/loopvectorize_pr33804.ll (revision 0b3912622ed4f3cdd311b02798f8689d52ed4602)
1; RUN: opt -passes=loop-vectorize -S < %s | FileCheck %s
2
3; These tests check that we don't crash if vectorizer decides to cast
4; a float value to be stored into a pointer type or vice-versa.
5
6; This test checks when a float value is stored into a pointer type.
7
8; ModuleID = 'bugpoint-reduced-simplified.bc'
9source_filename = "bugpoint-output-26dbd81.bc"
10target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
11target triple = "armv7-unknown-linux-gnueabihf"
12
13%struct.CvNode1D = type { float, ptr }
14
15; CHECK-LABEL: @cvCalcEMD2
16; CHECK: vector.body
17; CHECK: store <{{[0-9]+}} x ptr>
18define void @cvCalcEMD2(ptr %dst) {
19entry:
20  br label %for.body14.i.i
21
22for.body14.i.i:                                   ; preds = %for.body14.i.i, %entry
23  %i.1424.i.i = phi i32 [ %inc21.i.i, %for.body14.i.i ], [ 0, %entry ]
24  %arrayidx15.i.i1427 = getelementptr inbounds %struct.CvNode1D, ptr %dst, i32 %i.1424.i.i
25  store float 0xC415AF1D80000000, ptr %arrayidx15.i.i1427, align 4
26  %next19.i.i = getelementptr inbounds %struct.CvNode1D, ptr %dst, i32 %i.1424.i.i, i32 1
27  store ptr %dst, ptr %next19.i.i, align 4
28  %inc21.i.i = add nuw nsw i32 %i.1424.i.i, 1
29  %exitcond438.i.i = icmp eq i32 %inc21.i.i, 1024
30  br i1 %exitcond438.i.i, label %for.end22.i.i, label %for.body14.i.i
31
32for.end22.i.i:                                    ; preds = %for.body14.i.i
33  unreachable
34}
35
36; This test checks when a pointer value is stored into a float type.
37
38%struct.CvNode1D2 = type { ptr, float }
39
40; CHECK-LABEL: @cvCalcEMD2_2
41; CHECK: vector.body
42; CHECK: store <{{[0-9]+}} x float>
43define void @cvCalcEMD2_2(ptr %dst) {
44entry:
45  br label %for.body14.i.i
46
47for.body14.i.i:                                   ; preds = %for.body14.i.i, %entry
48  %i.1424.i.i = phi i32 [ %inc21.i.i, %for.body14.i.i ], [ 0, %entry ]
49  %next19.i.i = getelementptr inbounds %struct.CvNode1D2, ptr %dst, i32 %i.1424.i.i, i32 0
50  store ptr %dst, ptr %next19.i.i, align 4
51  %arrayidx15.i.i1427 = getelementptr inbounds %struct.CvNode1D2, ptr %dst, i32 %i.1424.i.i
52  %val.i.i = getelementptr inbounds %struct.CvNode1D2, ptr %arrayidx15.i.i1427, i32 0, i32 1
53  store float 0xC415AF1D80000000, ptr %val.i.i, align 4
54  %inc21.i.i = add nuw nsw i32 %i.1424.i.i, 1
55  %exitcond438.i.i = icmp eq i32 %inc21.i.i, 1024
56  br i1 %exitcond438.i.i, label %for.end22.i.i, label %for.body14.i.i
57
58for.end22.i.i:                                    ; preds = %for.body14.i.i
59  unreachable
60}
61
62; This test checks for the intoptr conversions with load instructions.
63
64; CHECK-LABEL: @cvCalcEMD3
65; CHECK: vector.body
66; CHECK: inttoptr <{{[0-9]+}} x i32>
67define void @cvCalcEMD3(ptr %src, ptr %dst) {
68entry:
69  br label %for.body14.i.i
70
71for.body14.i.i:                                   ; preds = %for.body14.i.i, %entry
72  %i.1424.i.i = phi i32 [ %inc21.i.i, %for.body14.i.i ], [ 0, %entry ]
73  %arrayidx15.i.i1427 = getelementptr inbounds %struct.CvNode1D, ptr %src, i32 %i.1424.i.i
74  %loadf = load float, ptr %arrayidx15.i.i1427, align 4
75  %next19.i.i = getelementptr inbounds %struct.CvNode1D, ptr %src, i32 %i.1424.i.i, i32 1
76  %loadp = load ptr, ptr %next19.i.i, align 4
77  %dst.ptr = getelementptr inbounds %struct.CvNode1D, ptr %dst, i32 %i.1424.i.i
78  %dst.ptr.1 = getelementptr inbounds %struct.CvNode1D, ptr %dst, i32 %i.1424.i.i, i32 1
79  store float %loadf, ptr %dst.ptr, align 4
80  store ptr %loadp, ptr %dst.ptr.1, align 4
81  %inc21.i.i = add nuw nsw i32 %i.1424.i.i, 1
82  %exitcond438.i.i = icmp eq i32 %inc21.i.i, 1024
83  br i1 %exitcond438.i.i, label %for.end22.i.i, label %for.body14.i.i
84
85for.end22.i.i:                                    ; preds = %for.body14.i.i
86  unreachable
87}
88
89; This test checks for ptrtoint conversions with load instructions.
90
91; CHECK-LABEL: @cvCalcEMD3_2
92; CHECK: vector.body
93; CHECK: ptrtoint <{{[0-9]+}} x ptr>
94define void @cvCalcEMD3_2(ptr %src, ptr %dst) {
95entry:
96  br label %for.body14.i.i
97
98for.body14.i.i:                                   ; preds = %for.body14.i.i, %entry
99  %i.1424.i.i = phi i32 [ %inc21.i.i, %for.body14.i.i ], [ 0, %entry ]
100  %next19.i.i = getelementptr inbounds %struct.CvNode1D2, ptr %src, i32 %i.1424.i.i, i32 0
101  %loadp = load ptr, ptr %next19.i.i, align 4
102  %arrayidx15.i.i1427 = getelementptr inbounds %struct.CvNode1D2, ptr %src, i32 %i.1424.i.i
103  %val.i.i = getelementptr inbounds %struct.CvNode1D2, ptr %arrayidx15.i.i1427, i32 0, i32 1
104  %loadf = load float, ptr %val.i.i, align 4
105  %dst.ptr = getelementptr inbounds %struct.CvNode1D, ptr %dst, i32 %i.1424.i.i
106  %dst.ptr.1 = getelementptr inbounds %struct.CvNode1D, ptr %dst, i32 %i.1424.i.i, i32 1
107  store float %loadf, ptr %dst.ptr, align 4
108  store ptr %loadp, ptr %dst.ptr.1, align 4
109  %inc21.i.i = add nuw nsw i32 %i.1424.i.i, 1
110  %exitcond438.i.i = icmp eq i32 %inc21.i.i, 1024
111  br i1 %exitcond438.i.i, label %for.end22.i.i, label %for.body14.i.i
112
113for.end22.i.i:                                    ; preds = %for.body14.i.i
114  unreachable
115}
116