1 ; RUN: opt -passes=loop-vectorize -S < %s | FileCheck %s
3 ; These tests check that we don't crash if vectorizer decides to cast
4 ; a double value to be stored into a pointer type or vice-versa.
6 ; This test checks when a double value is stored into a pointer type.
8 ; ModuleID = 'bugpoint-reduced-simplified.bc'
9 source_filename = "bugpoint-output-26dbd81.bc"
10 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
11 target triple = "aarch64-unknown-linux-gnu"
13 %struct.CvNode1D = type { double, ptr }
15 ; CHECK-LABEL: @cvCalcEMD2
17 ; CHECK: store <{{[0-9]+}} x ptr>
18 define void @cvCalcEMD2(ptr %dst) {
20 br label %for.body14.i.i
22 for.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 double 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, 0
30 br i1 %exitcond438.i.i, label %for.end22.i.i, label %for.body14.i.i
32 for.end22.i.i: ; preds = %for.body14.i.i
36 ; This test checks when a pointer value is stored into a double type.
38 %struct.CvNode1D2 = type { ptr, double }
40 ; CHECK-LABEL: @cvCalcEMD2_2
42 ; CHECK: store <{{[0-9]+}} x double>
43 define void @cvCalcEMD2_2(ptr %dst) {
45 br label %for.body14.i.i
47 for.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 double 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, 0
56 br i1 %exitcond438.i.i, label %for.end22.i.i, label %for.body14.i.i
58 for.end22.i.i: ; preds = %for.body14.i.i
62 ; This test check for integer to pointer casting with load instructions.
64 ; CHECK-LABEL: @cvCalcEMD3
66 ; CHECK: inttoptr <{{[0-9]+}} x i64>
67 define void @cvCalcEMD3(ptr %src, ptr %dst) {
69 br label %for.body14.i.i
71 for.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 %load_d = load double, ptr %arrayidx15.i.i1427, align 4
75 %next19.i.i = getelementptr inbounds %struct.CvNode1D, ptr %src, i32 %i.1424.i.i, i32 1
76 %load_p = 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 double %load_d, ptr %dst.ptr, align 4
80 store ptr %load_p, 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, 0
83 br i1 %exitcond438.i.i, label %for.end22.i.i, label %for.body14.i.i
85 for.end22.i.i: ; preds = %for.body14.i.i
89 ; This test check for pointer to integer casting with load instructions.
91 ; CHECK-LABEL: @cvCalcEMD3_2
93 ; CHECK: ptrtoint <{{[0-9]+}} x ptr>
94 define void @cvCalcEMD3_2(ptr %src, ptr %dst) {
96 br label %for.body14.i.i
98 for.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 %load_p = 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 %load_d = load double, 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 double %load_d, ptr %dst.ptr, align 4
108 store ptr %load_p, 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, 0
111 br i1 %exitcond438.i.i, label %for.end22.i.i, label %for.body14.i.i
113 for.end22.i.i: ; preds = %for.body14.i.i