1 ; RUN: llc -march=hexagon < %s
4 ; After a copy R20 = R29, RDF copy propagation attempted to replace R20 with
5 ; R29. R29 did not have a reaching def at that point (which isn't unusual),
6 ; but copy propagation tried to link the new use of R29 to the presumed
7 ; reaching def (which was null), causing a crash.
9 target triple = "hexagon"
11 @g0 = external unnamed_addr global i1, align 4
13 ; Function Attrs: nounwind
14 declare ptr @llvm.stacksave() #0
16 ; Function Attrs: nounwind
17 declare void @llvm.stackrestore(ptr) #0
19 ; Function Attrs: norecurse nounwind
20 declare fastcc void @f0(i16 signext, i16 signext, i16 signext, ptr nocapture readonly, i16 signext, ptr nocapture) unnamed_addr #1
22 ; Function Attrs: norecurse nounwind
23 declare fastcc signext i16 @f1(i16 signext, i16 signext) unnamed_addr #1
25 ; Function Attrs: norecurse nounwind
26 define fastcc i32 @f2(ptr nocapture readonly %a0, i16 signext %a1, i16 signext %a2, ptr nocapture readonly %a3, i16 signext %a4, ptr nocapture readonly %a51, ptr nocapture %a6) unnamed_addr #1 {
28 %v0 = tail call ptr @llvm.stacksave()
29 %v1 = tail call fastcc signext i16 @f1(i16 signext %a2, i16 signext %a1)
30 br i1 undef, label %b7, label %b1
33 br i1 undef, label %b3, label %b2
36 br i1 undef, label %b4, label %b8
39 br i1 undef, label %b5, label %b8
41 b4: ; preds = %b4, %b2
42 br i1 undef, label %b4, label %b6, !llvm.loop !2
44 b5: ; preds = %b5, %b3
45 %v2 = phi i16 [ %v3, %b5 ], [ 0, %b3 ]
47 %v4 = icmp sgt i32 0, -1073741825
48 br i1 %v4, label %b5, label %b6
50 b6: ; preds = %b5, %b4
51 %v5 = phi i16 [ %v3, %b5 ], [ undef, %b4 ]
54 b7: ; preds = %b6, %b0
55 %v6 = phi i16 [ %v5, %b6 ], [ 0, %b0 ]
56 br i1 undef, label %b9, label %b8
58 b8: ; preds = %b7, %b3, %b2
62 b9: ; preds = %b8, %b7
63 %v8 = phi i16 [ 0, %b8 ], [ %v6, %b7 ]
64 %v9 = phi i32 [ %v7, %b8 ], [ 0, %b7 ]
65 %v10 = load i16, ptr undef, align 2, !tbaa !4
66 %v11 = sext i16 %v10 to i32
67 %v12 = zext i16 %v10 to i32
68 br i1 undef, label %b10, label %b11
71 store i1 true, ptr @g0, align 4
74 b11: ; preds = %b10, %b9
75 %v13 = load i16, ptr undef, align 2, !tbaa !4
76 %v14 = sext i16 %v13 to i32
77 %v15 = shl nuw i32 %v12, 16
78 %v16 = and i32 %v9, 65535
79 %v17 = mul nsw i32 %v11, %v16
80 %v18 = sitofp i32 %v15 to double
81 %v19 = fsub double %v18, undef
82 %v20 = sub nsw i32 %v15, %v17
83 %v21 = fptosi double %v19 to i32
84 %v22 = select i1 undef, i32 %v21, i32 %v20
85 %v23 = mul nsw i32 %v14, %v16
86 %v24 = add nsw i32 %v23, %v22
87 %v25 = add nsw i32 %v24, 32768
88 %v26 = lshr i32 %v25, 16
89 %v27 = xor i1 undef, true
90 %v28 = and i1 %v27, undef
91 br i1 %v28, label %b12, label %b13
94 store i1 true, ptr @g0, align 4
97 b13: ; preds = %b12, %b11
98 br i1 undef, label %b14, label %b24
103 b15: ; preds = %b23, %b14
104 br i1 undef, label %b16, label %b17
110 %v29 = trunc i32 %v26 to i16
111 %v30 = icmp eq i16 %v29, -32768
112 %v31 = and i1 undef, %v30
113 br i1 %v31, label %b18, label %b19
116 store i1 true, ptr @g0, align 4
119 b19: ; preds = %b17, %b16
122 b20: ; preds = %b19, %b18
123 %v32 = phi i32 [ 2147483647, %b18 ], [ 0, %b19 ]
124 %v33 = icmp eq i16 %v8, 32767
125 br i1 %v33, label %b21, label %b22
128 store i1 true, ptr @g0, align 4
134 b23: ; preds = %b22, %b21
135 %v34 = add nsw i32 %v32, 32768
136 %v35 = lshr i32 %v34, 16
137 %v36 = trunc i32 %v35 to i16
138 store i16 %v36, ptr undef, align 2, !tbaa !4
139 br i1 undef, label %b24, label %b15
141 b24: ; preds = %b23, %b13
142 call fastcc void @f0(i16 signext undef, i16 signext %a1, i16 signext %a2, ptr %a3, i16 signext %a4, ptr %a6)
143 call void @llvm.stackrestore(ptr %v0)
147 attributes #0 = { nounwind }
148 attributes #1 = { norecurse nounwind "target-cpu"="hexagonv60" "target-features"="+hvx,+hvx-length64b" }
150 !llvm.module.flags = !{!0}
152 !0 = !{i32 6, !"Target Features", !1}
153 !1 = !{!"+hvx,+hvx-length64b"}
154 !2 = distinct !{!2, !3}
155 !3 = !{!"llvm.loop.threadify", i32 43789156}
156 !4 = !{!5, !5, i64 0}
157 !5 = !{!"short", !6, i64 0}
158 !6 = !{!"omnipotent char", !7, i64 0}
159 !7 = !{!"Simple C++ TBAA"}