1 ; RUN: opt -mtriple=hexagon-- -passes='loop(hexagon-vlcr),adce' -S %s | FileCheck %s
3 ; CHECK: %.hexagon.vlcr = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B
4 ; ModuleID = 'hexagon_vector_loop_carried_reuse.c'
5 source_filename = "hexagon_vector_loop_carried_reuse.c"
6 target datalayout = "e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048"
7 target triple = "hexagon"
9 @W = external local_unnamed_addr global i32, align 4
11 ; Function Attrs: nounwind
12 define void @foo(ptr noalias nocapture readonly %src, ptr noalias nocapture %dst, i32 %stride) local_unnamed_addr #0 {
14 %add.ptr = getelementptr inbounds i8, ptr %src, i32 %stride
15 %mul = mul nsw i32 %stride, 2
16 %add.ptr1 = getelementptr inbounds i8, ptr %src, i32 %mul
17 %0 = load i32, ptr @W, align 4, !tbaa !1
18 %cmp55 = icmp sgt i32 %0, 0
19 br i1 %cmp55, label %for.body.lr.ph, label %for.end
21 for.body.lr.ph: ; preds = %entry
22 %1 = load <32 x i32>, ptr %add.ptr1, align 128, !tbaa !5
23 %incdec.ptr4 = getelementptr inbounds i8, ptr %add.ptr1, i32 128
24 %2 = load <32 x i32>, ptr %add.ptr, align 128, !tbaa !5
25 %incdec.ptr2 = getelementptr inbounds i8, ptr %add.ptr, i32 128
26 %3 = load <32 x i32>, ptr %src, align 128, !tbaa !5
27 %incdec.ptr = getelementptr inbounds i8, ptr %src, i32 128
30 for.body: ; preds = %for.body.lr.ph, %for.body
31 %out.063 = phi ptr [ %dst, %for.body.lr.ph ], [ %incdec.ptr18, %for.body ]
32 %p2.062 = phi ptr [ %incdec.ptr4, %for.body.lr.ph ], [ %incdec.ptr10, %for.body ]
33 %p1.061 = phi ptr [ %incdec.ptr2, %for.body.lr.ph ], [ %incdec.ptr8, %for.body ]
34 %p0.060 = phi ptr [ %incdec.ptr, %for.body.lr.ph ], [ %incdec.ptr6, %for.body ]
35 %i.059 = phi i32 [ 0, %for.body.lr.ph ], [ %add, %for.body ]
36 %a.sroa.0.058 = phi <32 x i32> [ %3, %for.body.lr.ph ], [ %4, %for.body ]
37 %b.sroa.0.057 = phi <32 x i32> [ %2, %for.body.lr.ph ], [ %5, %for.body ]
38 %c.sroa.0.056 = phi <32 x i32> [ %1, %for.body.lr.ph ], [ %6, %for.body ]
39 %incdec.ptr6 = getelementptr inbounds <32 x i32>, ptr %p0.060, i32 1
40 %4 = load <32 x i32>, ptr %p0.060, align 128, !tbaa !5
41 %incdec.ptr8 = getelementptr inbounds <32 x i32>, ptr %p1.061, i32 1
42 %5 = load <32 x i32>, ptr %p1.061, align 128, !tbaa !5
43 %incdec.ptr10 = getelementptr inbounds <32 x i32>, ptr %p2.062, i32 1
44 %6 = load <32 x i32>, ptr %p2.062, align 128, !tbaa !5
45 %7 = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32> %a.sroa.0.058, <32 x i32> %b.sroa.0.057)
46 %8 = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32> %7, <32 x i32> %c.sroa.0.056)
47 %9 = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32> %4, <32 x i32> %5)
48 %10 = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32> %9, <32 x i32> %6)
49 %11 = tail call <32 x i32> @llvm.hexagon.V6.valignbi.128B(<32 x i32> %10, <32 x i32> %8, i32 1)
50 %incdec.ptr18 = getelementptr inbounds <32 x i32>, ptr %out.063, i32 1
51 store <32 x i32> %11, ptr %out.063, align 128, !tbaa !5
52 %add = add nuw nsw i32 %i.059, 128
53 %cmp = icmp slt i32 %add, %0
54 br i1 %cmp, label %for.body, label %for.end.loopexit
56 for.end.loopexit: ; preds = %for.body
59 for.end: ; preds = %for.end.loopexit, %entry
63 ; Function Attrs: nounwind readnone
64 declare <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32>, <32 x i32>) #1
66 ; Function Attrs: nounwind readnone
67 declare <32 x i32> @llvm.hexagon.V6.valignbi.128B(<32 x i32>, <32 x i32>, i32) #1
69 attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "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"="hexagonv60" "target-features"="+hvx,+hvx-length128b,-long-calls" "unsafe-fp-math"="false" "use-soft-float"="false" }
70 attributes #1 = { nounwind readnone }
74 !0 = !{!"QuIC LLVM Hexagon Clang version hexagon-clang-82-2622 (based on LLVM 5.0.0)"}
76 !2 = !{!"int", !3, i64 0}
77 !3 = !{!"omnipotent char", !4, i64 0}
78 !4 = !{!"Simple C/C++ TBAA"}