[TTI] getTypeBasedIntrinsicInstrCost - add basic handling for strided load/store...
[llvm-project.git] / llvm / test / Transforms / LoopVectorize / induction-ptrcasts.ll
blob0d5d6db39c7cd9aa1d75033ae412d03df6ef90a4
1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=loop-vectorize -force-vector-width=1 -force-vector-interleave=2 -S %s | FileCheck --check-prefix=VF1 %s
3 ; RUN: opt -passes=loop-vectorize -force-vector-width=2 -force-vector-interleave=1 -S %s | FileCheck --check-prefix=VF2 %s
5 @f = external dso_local global i32, align 4
7 define void @int_iv_based_on_pointer_iv(ptr %A) {
8 ; VF1-LABEL: @int_iv_based_on_pointer_iv(
9 ; VF1:       vector.body:
10 ; VF1-NEXT:    [[INDEX:%.*]] = phi i64 [ 0, %vector.ph ], [ [[INDEX_NEXT:%.*]], %vector.body ]
11 ; VF1-NEXT:    [[OFFSET_IDX:%.*]] = mul i64 [[INDEX]], 4
12 ; VF1-NEXT:    [[INDUCTION:%.*]] = add i64 [[OFFSET_IDX]], 0
13 ; VF1-NEXT:    [[INDUCTION3:%.*]] = add i64 [[OFFSET_IDX]], 4
14 ; VF1-NEXT:    [[TMP7:%.*]] = getelementptr inbounds i8, ptr [[A:%.*]], i64 [[INDUCTION]]
15 ; VF1-NEXT:    [[TMP8:%.*]] = getelementptr inbounds i8, ptr [[A]], i64 [[INDUCTION3]]
16 ; VF1-NEXT:    store i8 0, ptr [[TMP7]], align 1
17 ; VF1-NEXT:    store i8 0, ptr [[TMP8]], align 1
18 ; VF1-NEXT:    [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 2
19 ; VF1-NEXT:    [[TMP13:%.*]] = icmp eq i64 [[INDEX_NEXT]],
20 ; VF1-NEXT:    br i1 [[TMP13]], label %middle.block, label %vector.body
22 ; VF2-LABEL: @int_iv_based_on_pointer_iv(
23 ; VF2:       vector.body:
24 ; VF2-NEXT:    [[INDEX:%.*]] = phi i64 [ 0, %vector.ph ], [ [[INDEX_NEXT:%.*]], %vector.body ]
25 ; VF2-NEXT:    [[OFFSET_IDX:%.*]] = mul i64 [[INDEX]], 4
26 ; VF2-NEXT:    [[TMP3:%.*]] = add i64 [[OFFSET_IDX]], 0
27 ; VF2-NEXT:    [[TMP4:%.*]] = add i64 [[OFFSET_IDX]], 4
28 ; VF2-NEXT:    [[TMP9:%.*]] = getelementptr inbounds i8, ptr [[A:%.*]], i64 [[TMP3]]
29 ; VF2-NEXT:    [[TMP10:%.*]] = getelementptr inbounds i8, ptr [[A]], i64 [[TMP4]]
30 ; VF2-NEXT:    store i8 0, ptr [[TMP9]], align 1
31 ; VF2-NEXT:    store i8 0, ptr [[TMP10]], align 1
32 ; VF2-NEXT:    [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 2
33 ; VF2-NEXT:    [[TMP14:%.*]] = icmp eq i64 [[INDEX_NEXT]],
34 ; VF2-NEXT:    br i1 [[TMP14]], label %middle.block, label %vector.body
36 entry:
37   br label %loop
39 loop:
40   %iv.int = phi i64 [ 0, %entry ], [ %iv.int.next, %loop ]
41   %iv.ptr = phi ptr [ null, %entry ], [ %iv.ptr.next, %loop ]
42   %iv.ptr.next = getelementptr inbounds i32, ptr %iv.ptr, i64 1
43   %gep.A = getelementptr inbounds i8, ptr %A, i64 %iv.int
44   store i8 0, ptr %gep.A
45   %iv.int.next = ptrtoint ptr %iv.ptr.next to i64
46   %sub.ptr.sub = sub i64 ptrtoint (ptr @f to i64), %iv.int.next
47   %cmp = icmp sgt i64 %sub.ptr.sub, 0
48   br i1 %cmp, label %loop, label %exit
50 exit:
51   ret void