1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=loop-vectorize -force-vector-width=2 -force-vector-interleave=1 -S %s | FileCheck %s
4 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-linux-gnu"
7 %pair = type { ptr, ptr }
9 define void @test_pr55375_interleave_opaque_ptr(ptr %start, ptr %end) {
10 ; CHECK-LABEL: @test_pr55375_interleave_opaque_ptr(
12 ; CHECK-NEXT: [[START2:%.*]] = ptrtoint ptr [[START:%.*]] to i64
13 ; CHECK-NEXT: [[END1:%.*]] = ptrtoint ptr [[END:%.*]] to i64
14 ; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[END1]], -16
15 ; CHECK-NEXT: [[TMP1:%.*]] = sub i64 [[TMP0]], [[START2]]
16 ; CHECK-NEXT: [[TMP2:%.*]] = lshr i64 [[TMP1]], 4
17 ; CHECK-NEXT: [[TMP3:%.*]] = add nuw nsw i64 [[TMP2]], 1
18 ; CHECK-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[TMP3]], 2
19 ; CHECK-NEXT: br i1 [[MIN_ITERS_CHECK]], label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
21 ; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[TMP3]], 2
22 ; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 [[TMP3]], [[N_MOD_VF]]
23 ; CHECK-NEXT: [[TMP4:%.*]] = mul i64 [[N_VEC]], 16
24 ; CHECK-NEXT: [[IND_END:%.*]] = getelementptr i8, ptr [[START]], i64 [[TMP4]]
25 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
27 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
28 ; CHECK-NEXT: [[OFFSET_IDX:%.*]] = mul i64 [[INDEX]], 16
29 ; CHECK-NEXT: [[TMP5:%.*]] = add i64 [[OFFSET_IDX]], 0
30 ; CHECK-NEXT: [[TMP6:%.*]] = add i64 [[OFFSET_IDX]], 16
31 ; CHECK-NEXT: [[TMP7:%.*]] = getelementptr i8, ptr [[START]], i64 [[TMP5]]
32 ; CHECK-NEXT: [[TMP8:%.*]] = getelementptr i8, ptr [[START]], i64 [[TMP6]]
33 ; CHECK-NEXT: [[TMP9:%.*]] = insertelement <2 x ptr> poison, ptr [[TMP7]], i32 0
34 ; CHECK-NEXT: [[TMP10:%.*]] = insertelement <2 x ptr> [[TMP9]], ptr [[TMP8]], i32 1
35 ; CHECK-NEXT: [[TMP12:%.*]] = shufflevector <2 x ptr> zeroinitializer, <2 x ptr> [[TMP10]], <4 x i32> <i32 0, i32 1, i32 2, i32 3>
36 ; CHECK-NEXT: [[INTERLEAVED_VEC:%.*]] = shufflevector <4 x ptr> [[TMP12]], <4 x ptr> poison, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
37 ; CHECK-NEXT: store <4 x ptr> [[INTERLEAVED_VEC]], ptr [[TMP7]], align 8
38 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 2
39 ; CHECK-NEXT: [[TMP13:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]
40 ; CHECK-NEXT: br i1 [[TMP13]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
41 ; CHECK: middle.block:
42 ; CHECK-NEXT: [[CMP_N:%.*]] = icmp eq i64 [[TMP3]], [[N_VEC]]
43 ; CHECK-NEXT: br i1 [[CMP_N]], label [[EXIT:%.*]], label [[SCALAR_PH]]
45 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi ptr [ [[IND_END]], [[MIDDLE_BLOCK]] ], [ [[START]], [[ENTRY:%.*]] ]
46 ; CHECK-NEXT: br label [[LOOP:%.*]]
48 ; CHECK-NEXT: [[IV:%.*]] = phi ptr [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
49 ; CHECK-NEXT: [[IV_1:%.*]] = getelementptr inbounds [[PAIR:%.*]], ptr [[IV]], i64 0, i32 1
50 ; CHECK-NEXT: store ptr [[IV]], ptr [[IV_1]], align 8
51 ; CHECK-NEXT: store ptr null, ptr [[IV]], align 8
52 ; CHECK-NEXT: [[IV_NEXT]] = getelementptr inbounds [[PAIR]], ptr [[IV]], i64 1
53 ; CHECK-NEXT: [[EC:%.*]] = icmp eq ptr [[IV_NEXT]], [[END]]
54 ; CHECK-NEXT: br i1 [[EC]], label [[EXIT]], label [[LOOP]], !llvm.loop [[LOOP3:![0-9]+]]
56 ; CHECK-NEXT: ret void
62 %iv = phi ptr [ %start, %entry ], [ %iv.next, %loop ]
63 %iv.1 = getelementptr inbounds %pair, ptr %iv, i64 0, i32 1
64 store ptr %iv, ptr %iv.1, align 8
65 store ptr null, ptr %iv, align 8
66 %iv.next = getelementptr inbounds %pair, ptr %iv, i64 1
67 %ec = icmp eq ptr %iv.next, %end
68 br i1 %ec, label %exit, label %loop