1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -hexagon-vc -S -mtriple=hexagon < %s | FileCheck %s
4 ; A safety check was accidentally modified, allowing moving memory
5 ; instructions over other aliased memory instructions. In this case
6 ; a load was moved over a memset.
8 ; This testcase should be left untouched by the vector alignment code.
10 define internal fastcc i32 @f0(ptr noalias nocapture align 64 %a0, ptr noalias nocapture readonly align 64 %a1, ptr noalias nocapture readonly align 64 %a2) unnamed_addr #0 {
11 ; CHECK-LABEL: define internal fastcc i32 @f0
12 ; CHECK-SAME: (ptr noalias nocapture align 64 [[A0:%.*]], ptr noalias nocapture readonly align 64 [[A1:%.*]], ptr noalias nocapture readonly align 64 [[A2:%.*]]) unnamed_addr #[[ATTR0:[0-9]+]] {
14 ; CHECK-NEXT: [[V0:%.*]] = load <32 x i32>, ptr [[A2]], align 64, !tbaa [[TBAA0:![0-9]+]]
15 ; CHECK-NEXT: br label [[B1:%.*]]
17 ; CHECK-NEXT: [[V1:%.*]] = phi i32 [ [[V13:%.*]], [[B1]] ], [ 1024, [[B0:%.*]] ]
18 ; CHECK-NEXT: [[V2:%.*]] = phi ptr [ [[A0]], [[B0]] ], [ [[V9:%.*]], [[B1]] ]
19 ; CHECK-NEXT: [[V3:%.*]] = phi ptr [ [[A1]], [[B0]] ], [ [[V8:%.*]], [[B1]] ]
20 ; CHECK-NEXT: tail call void @llvm.memset.p0.i32(ptr noundef nonnull align 4 dereferenceable(128) [[V2]], i8 0, i32 128, i1 false), !tbaa [[TBAA7:![0-9]+]]
21 ; CHECK-NEXT: [[V4:%.*]] = getelementptr i8, ptr [[V2]], i32 0
22 ; CHECK-NEXT: [[V5:%.*]] = load <32 x i32>, ptr [[V4]], align 64, !tbaa [[TBAA7]]
23 ; CHECK-NEXT: [[V6:%.*]] = load <32 x i32>, ptr [[V3]], align 64, !tbaa [[TBAA9:![0-9]+]]
24 ; CHECK-NEXT: [[V7:%.*]] = tail call <32 x i32> @llvm.hexagon.V6.vrmpyubv.acc.128B(<32 x i32> [[V5]], <32 x i32> [[V6]], <32 x i32> [[V0]])
25 ; CHECK-NEXT: store <32 x i32> [[V7]], ptr [[V2]], align 64, !tbaa [[TBAA7]]
26 ; CHECK-NEXT: [[V8]] = getelementptr i8, ptr [[V3]], i32 128
27 ; CHECK-NEXT: [[V9]] = getelementptr i8, ptr [[V2]], i32 128
28 ; CHECK-NEXT: tail call void @llvm.memset.p0.i32(ptr noundef nonnull align 4 dereferenceable(128) [[V9]], i8 0, i32 128, i1 false), !tbaa [[TBAA7]]
29 ; CHECK-NEXT: [[V10:%.*]] = load <32 x i32>, ptr [[V9]], align 64, !tbaa [[TBAA7]]
30 ; CHECK-NEXT: [[V11:%.*]] = load <32 x i32>, ptr [[V8]], align 64, !tbaa [[TBAA9]]
31 ; CHECK-NEXT: [[V12:%.*]] = tail call <32 x i32> @llvm.hexagon.V6.vrmpyubv.acc.128B(<32 x i32> [[V10]], <32 x i32> [[V11]], <32 x i32> [[V0]])
32 ; CHECK-NEXT: store <32 x i32> [[V12]], ptr [[V9]], align 64, !tbaa [[TBAA7]]
33 ; CHECK-NEXT: [[V13]] = add nsw i32 [[V1]], -16
34 ; CHECK-NEXT: [[V14:%.*]] = icmp eq i32 [[V13]], 0
35 ; CHECK-NEXT: br i1 [[V14]], label [[B2:%.*]], label [[B1]], !prof [[PROF11:![0-9]+]]
37 ; CHECK-NEXT: ret i32 0
40 %v0 = load <32 x i32>, ptr %a2, align 64, !tbaa !0
43 b1: ; preds = %b1, %b0
44 %v1 = phi i32 [ %v13, %b1 ], [ 1024, %b0 ]
45 %v2 = phi ptr [ %a0, %b0 ], [ %v9, %b1 ]
46 %v3 = phi ptr [ %a1, %b0 ], [ %v8, %b1 ]
47 tail call void @llvm.memset.p0.i32(ptr noundef nonnull align 4 dereferenceable(128) %v2, i8 0, i32 128, i1 false), !tbaa !7
48 %v4 = getelementptr i8, ptr %v2, i32 0
49 %v5 = load <32 x i32>, ptr %v4, align 64, !tbaa !7
50 %v6 = load <32 x i32>, ptr %v3, align 64, !tbaa !9
51 %v7 = tail call <32 x i32> @llvm.hexagon.V6.vrmpyubv.acc.128B(<32 x i32> %v5, <32 x i32> %v6, <32 x i32> %v0)
52 store <32 x i32> %v7, ptr %v2, align 64, !tbaa !7
53 %v8 = getelementptr i8, ptr %v3, i32 128
54 %v9 = getelementptr i8, ptr %v2, i32 128
55 tail call void @llvm.memset.p0.i32(ptr noundef nonnull align 4 dereferenceable(128) %v9, i8 0, i32 128, i1 false), !tbaa !7
56 %v10 = load <32 x i32>, ptr %v9, align 64, !tbaa !7
57 %v11 = load <32 x i32>, ptr %v8, align 64, !tbaa !9
58 %v12 = tail call <32 x i32> @llvm.hexagon.V6.vrmpyubv.acc.128B(<32 x i32> %v10, <32 x i32> %v11, <32 x i32> %v0)
59 store <32 x i32> %v12, ptr %v9, align 64, !tbaa !7
60 %v13 = add nsw i32 %v1, -16
61 %v14 = icmp eq i32 %v13, 0
62 br i1 %v14, label %b2, label %b1, !prof !11
68 declare <32 x i32> @llvm.hexagon.V6.vrmpyubv.acc.128B(<32 x i32>, <32 x i32>, <32 x i32>) #1
69 declare void @llvm.memset.p0.i32(ptr nocapture writeonly, i8, i32, i1 immarg) #2
71 attributes #0 = { noinline "target-cpu"="hexagonv68" "target-features"="+hvxv68,+hvx-length128b" }
72 attributes #1 = { nocallback nofree nosync nounwind willreturn memory(none) }
73 attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
76 !1 = !{!"0x3a8ee80.w128.b0", !2, i64 0}
77 !2 = !{!"0x3a8ee80.w256.b0", !3, i64 0}
78 !3 = !{!"0x3a8ee80.w512.b0", !4, i64 0}
79 !4 = !{!"0x3a8ee80.w1024.b0", !5, i64 0}
80 !5 = !{!"0x3a8ee80", !6, i64 0}
83 !8 = !{!"0x3a0d520", !6, i64 0}
84 !9 = !{!10, !10, i64 0}
85 !10 = !{!"0x1d56420", !6, i64 0}
86 !11 = !{!"branch_weights", i32 1, i32 65535}