1 ; RUN: llc -march=hexagon -hexagon-initial-cfg-cleanup=0 < %s | FileCheck %s
3 ; After register allocation it is possible to have a spill of a register
4 ; that is only partially defined. That in itself it fine, but creates a
5 ; problem for double vector registers. Stores of such registers are pseudo
6 ; instructions that are expanded into pairs of individual vector stores,
7 ; and in case of a partially defined source, one of the stores may use
8 ; an entirely undefined register.
10 ; This testcase used to crash. Make sure we can handle it, and that we
11 ; do generate a store for the defined part of W0:
14 ; CHECK: v[[REG:[0-9]+]] = vsplat
15 ; CHECK: vmem(r29+#{{[0-9]+}}) = v[[REG]]
18 target triple = "hexagon"
20 declare void @danny() local_unnamed_addr #0
21 declare void @sammy() local_unnamed_addr #0
22 declare <32 x i32> @llvm.hexagon.V6.lo.128B(<64 x i32>) #1
23 declare <32 x i32> @llvm.hexagon.V6.lvsplatw.128B(i32) #1
24 declare <64 x i32> @llvm.hexagon.V6.vcombine.128B(<32 x i32>, <32 x i32>) #1
25 declare <32 x i32> @llvm.hexagon.V6.vshuffeb.128B(<32 x i32>, <32 x i32>) #1
26 declare <32 x i32> @llvm.hexagon.V6.vlsrh.128B(<32 x i32>, i32) #1
27 declare <64 x i32> @llvm.hexagon.V6.vaddh.dv.128B(<64 x i32>, <64 x i32>) #1
29 define hidden void @fred() #2 {
31 %v1 = load i32, ptr null, align 4
32 %v2 = icmp ult i64 0, 2147483648
33 br i1 %v2, label %b3, label %b5
36 %v4 = icmp sgt i32 0, -1
37 br i1 %v4, label %b6, label %b5
39 b5: ; preds = %b3, %b0
43 tail call void @danny()
46 b7: ; preds = %b21, %b6
47 %v8 = icmp sgt i32 %v1, 0
48 %v9 = select i1 %v8, i32 %v1, i32 0
49 %v10 = select i1 false, i32 0, i32 %v9
50 %v11 = icmp slt i32 %v10, 0
51 %v12 = select i1 %v11, i32 %v10, i32 0
52 %v13 = icmp slt i32 0, %v12
53 br i1 %v13, label %b14, label %b18
55 b14: ; preds = %b16, %b7
56 br i1 false, label %b15, label %b16
61 b16: ; preds = %b15, %b14
62 %v17 = icmp eq i32 0, %v12
63 br i1 %v17, label %b18, label %b14
65 b18: ; preds = %b16, %b7
66 tail call void @danny()
67 %v19 = tail call <32 x i32> @llvm.hexagon.V6.lvsplatw.128B(i32 524296) #0
68 %v20 = tail call <64 x i32> @llvm.hexagon.V6.vcombine.128B(<32 x i32> %v19, <32 x i32> %v19)
72 store volatile <64 x i32> %v20, ptr null
73 tail call void @sammy() #3
76 b22: ; preds = %b22, %b18
77 %v23 = tail call <64 x i32> @llvm.hexagon.V6.vaddh.dv.128B(<64 x i32> zeroinitializer, <64 x i32> %v20) #0
78 %v24 = tail call <32 x i32> @llvm.hexagon.V6.lo.128B(<64 x i32> %v23)
79 %v25 = tail call <32 x i32> @llvm.hexagon.V6.vlsrh.128B(<32 x i32> %v24, i32 4) #0
80 %v26 = tail call <64 x i32> @llvm.hexagon.V6.vcombine.128B(<32 x i32> zeroinitializer, <32 x i32> %v25)
81 %v27 = tail call <32 x i32> @llvm.hexagon.V6.vshuffeb.128B(<32 x i32> zeroinitializer, <32 x i32> zeroinitializer) #0
82 %v28 = tail call <32 x i32> @llvm.hexagon.V6.lo.128B(<64 x i32> %v26) #0
83 %v29 = tail call <32 x i32> @llvm.hexagon.V6.vshuffeb.128B(<32 x i32> zeroinitializer, <32 x i32> %v28) #0
84 store <32 x i32> %v27, ptr null, align 128
85 %v30 = add nsw i32 0, 128
86 %v31 = getelementptr inbounds i8, ptr null, i32 %v30
87 store <32 x i32> %v29, ptr %v31, align 128
88 %v33 = icmp eq i32 0, 0
89 br i1 %v33, label %b21, label %b22
92 attributes #0 = { nounwind }
93 attributes #1 = { nounwind readnone }
94 attributes #2 = { nounwind "reciprocal-estimates"="none" "target-cpu"="hexagonv60" "target-features"="+hvxv60,+hvx-length128b" }
95 attributes #3 = { nobuiltin nounwind }