1 ; RUN: opt -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, %struct.CvNode1D* }
15 ; CHECK-LABEL: @cvCalcEMD2
17 ; CHECK: store <{{[0-9]+}} x %struct.CvNode1D*>
18 define void @cvCalcEMD2() local_unnamed_addr #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
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, %struct.CvNode1D* undef, i32 %i.1424.i.i
25 %val.i.i = getelementptr inbounds %struct.CvNode1D, %struct.CvNode1D* %arrayidx15.i.i1427, i32 0, i32 0
26 store double 0xC415AF1D80000000, double* %val.i.i, align 4
27 %next19.i.i = getelementptr inbounds %struct.CvNode1D, %struct.CvNode1D* undef, i32 %i.1424.i.i, i32 1
28 store %struct.CvNode1D* undef, %struct.CvNode1D** %next19.i.i, align 4
29 %inc21.i.i = add nuw nsw i32 %i.1424.i.i, 1
30 %exitcond438.i.i = icmp eq i32 %inc21.i.i, 0
31 br i1 %exitcond438.i.i, label %for.end22.i.i, label %for.body14.i.i
33 for.end22.i.i: ; preds = %for.body14.i.i
37 ; This test checks when a pointer value is stored into a double type.
39 %struct.CvNode1D2 = type { %struct.CvNode1D2*, double }
41 ; CHECK-LABEL: @cvCalcEMD2_2
43 ; CHECK: store <{{[0-9]+}} x double>
44 define void @cvCalcEMD2_2() local_unnamed_addr #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
46 br label %for.body14.i.i
48 for.body14.i.i: ; preds = %for.body14.i.i, %entry
49 %i.1424.i.i = phi i32 [ %inc21.i.i, %for.body14.i.i ], [ 0, %entry ]
50 %next19.i.i = getelementptr inbounds %struct.CvNode1D2, %struct.CvNode1D2* undef, i32 %i.1424.i.i, i32 0
51 store %struct.CvNode1D2* undef, %struct.CvNode1D2** %next19.i.i, align 4
52 %arrayidx15.i.i1427 = getelementptr inbounds %struct.CvNode1D2, %struct.CvNode1D2* undef, i32 %i.1424.i.i
53 %val.i.i = getelementptr inbounds %struct.CvNode1D2, %struct.CvNode1D2* %arrayidx15.i.i1427, i32 0, i32 1
54 store double 0xC415AF1D80000000, double* %val.i.i, align 4
55 %inc21.i.i = add nuw nsw i32 %i.1424.i.i, 1
56 %exitcond438.i.i = icmp eq i32 %inc21.i.i, 0
57 br i1 %exitcond438.i.i, label %for.end22.i.i, label %for.body14.i.i
59 for.end22.i.i: ; preds = %for.body14.i.i
63 ; This test check for integer to pointer casting with load instructions.
65 ; CHECK-LABEL: @cvCalcEMD3
67 ; CHECK: inttoptr <{{[0-9]+}} x i64>
68 define void @cvCalcEMD3() local_unnamed_addr #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
70 br label %for.body14.i.i
72 for.body14.i.i: ; preds = %for.body14.i.i, %entry
73 %i.1424.i.i = phi i32 [ %inc21.i.i, %for.body14.i.i ], [ 0, %entry ]
74 %arrayidx15.i.i1427 = getelementptr inbounds %struct.CvNode1D, %struct.CvNode1D* undef, i32 %i.1424.i.i
75 %val.i.i = getelementptr inbounds %struct.CvNode1D, %struct.CvNode1D* %arrayidx15.i.i1427, i32 0, i32 0
76 %load_d = load double, double* %val.i.i, align 4
77 %next19.i.i = getelementptr inbounds %struct.CvNode1D, %struct.CvNode1D* undef, i32 %i.1424.i.i, i32 1
78 %load_p = load %struct.CvNode1D*, %struct.CvNode1D** %next19.i.i, align 4
79 %inc21.i.i = add nuw nsw i32 %i.1424.i.i, 1
80 %exitcond438.i.i = icmp eq i32 %inc21.i.i, 0
81 br i1 %exitcond438.i.i, label %for.end22.i.i, label %for.body14.i.i
83 for.end22.i.i: ; preds = %for.body14.i.i
87 ; This test check for pointer to integer casting with load instructions.
89 ; CHECK-LABEL: @cvCalcEMD3_2
91 ; CHECK: ptrtoint <{{[0-9]+}} x %struct.CvNode1D2*>
92 define void @cvCalcEMD3_2() local_unnamed_addr #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
94 br label %for.body14.i.i
96 for.body14.i.i: ; preds = %for.body14.i.i, %entry
97 %i.1424.i.i = phi i32 [ %inc21.i.i, %for.body14.i.i ], [ 0, %entry ]
98 %next19.i.i = getelementptr inbounds %struct.CvNode1D2, %struct.CvNode1D2* undef, i32 %i.1424.i.i, i32 0
99 %load_p = load %struct.CvNode1D2*, %struct.CvNode1D2** %next19.i.i, align 4
100 %arrayidx15.i.i1427 = getelementptr inbounds %struct.CvNode1D2, %struct.CvNode1D2* undef, i32 %i.1424.i.i
101 %val.i.i = getelementptr inbounds %struct.CvNode1D2, %struct.CvNode1D2* %arrayidx15.i.i1427, i32 0, i32 1
102 %load_d = load double, double* %val.i.i, align 4
103 %inc21.i.i = add nuw nsw i32 %i.1424.i.i, 1
104 %exitcond438.i.i = icmp eq i32 %inc21.i.i, 0
105 br i1 %exitcond438.i.i, label %for.end22.i.i, label %for.body14.i.i
107 for.end22.i.i: ; preds = %for.body14.i.i
111 declare i32 @__gxx_personality_v0(...)
113 attributes #0 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="generic" "unsafe-fp-math"="false" "use-soft-float"="false" }