190 lines · plain
1; RUN: opt -passes=loop-vectorize -force-vector-width=2 -debug-only=loop-vectorize -disable-output < %s 2>&1 | FileCheck %s --check-prefix=VF_22; RUN: opt -passes=loop-vectorize -force-vector-width=4 -debug-only=loop-vectorize -disable-output < %s 2>&1 | FileCheck %s --check-prefix=VF_43; RUN: opt -passes=loop-vectorize -force-vector-width=8 -debug-only=loop-vectorize -disable-output < %s 2>&1 | FileCheck %s --check-prefix=VF_84; RUN: opt -passes=loop-vectorize -force-vector-width=16 -debug-only=loop-vectorize -disable-output < %s 2>&1 | FileCheck %s --check-prefix=VF_165; REQUIRES: asserts6 7target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"8target triple = "aarch64"9 10%i8.2 = type {i8, i8}11define void @i8_factor_2(ptr %data, i64 %n) {12entry:13 br label %for.body14 15; VF_8-LABEL: Checking a loop in 'i8_factor_2'16; VF_8: Found an estimated cost of 2 for VF 8 For instruction: %tmp2 = load i8, ptr %tmp0, align 117; VF_8-NEXT: Found an estimated cost of 0 for VF 8 For instruction: %tmp3 = load i8, ptr %tmp1, align 118; VF_8-NEXT: Found an estimated cost of 0 for VF 8 For instruction: store i8 %tmp2, ptr %tmp0, align 119; VF_8-NEXT: Found an estimated cost of 2 for VF 8 For instruction: store i8 %tmp3, ptr %tmp1, align 120; VF_16-LABEL: Checking a loop in 'i8_factor_2'21; VF_16: Found an estimated cost of 2 for VF 16 For instruction: %tmp2 = load i8, ptr %tmp0, align 122; VF_16-NEXT: Found an estimated cost of 0 for VF 16 For instruction: %tmp3 = load i8, ptr %tmp1, align 123; VF_16-NEXT: Found an estimated cost of 0 for VF 16 For instruction: store i8 %tmp2, ptr %tmp0, align 124; VF_16-NEXT: Found an estimated cost of 2 for VF 16 For instruction: store i8 %tmp3, ptr %tmp1, align 125for.body:26 %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]27 %tmp0 = getelementptr inbounds %i8.2, ptr %data, i64 %i, i32 028 %tmp1 = getelementptr inbounds %i8.2, ptr %data, i64 %i, i32 129 %tmp2 = load i8, ptr %tmp0, align 130 %tmp3 = load i8, ptr %tmp1, align 131 store i8 %tmp2, ptr %tmp0, align 132 store i8 %tmp3, ptr %tmp1, align 133 %i.next = add nuw nsw i64 %i, 134 %cond = icmp slt i64 %i.next, %n35 br i1 %cond, label %for.body, label %for.end36 37for.end:38 ret void39}40 41%i16.2 = type {i16, i16}42define void @i16_factor_2(ptr %data, i64 %n) {43entry:44 br label %for.body45 46; VF_4-LABEL: Checking a loop in 'i16_factor_2'47; VF_4: Found an estimated cost of 2 for VF 4 For instruction: %tmp2 = load i16, ptr %tmp0, align 248; VF_4-NEXT: Found an estimated cost of 0 for VF 4 For instruction: %tmp3 = load i16, ptr %tmp1, align 249; VF_4-NEXT: Found an estimated cost of 0 for VF 4 For instruction: store i16 %tmp2, ptr %tmp0, align 250; VF_4-NEXT: Found an estimated cost of 2 for VF 4 For instruction: store i16 %tmp3, ptr %tmp1, align 251; VF_8-LABEL: Checking a loop in 'i16_factor_2'52; VF_8: Found an estimated cost of 2 for VF 8 For instruction: %tmp2 = load i16, ptr %tmp0, align 253; VF_8-NEXT: Found an estimated cost of 0 for VF 8 For instruction: %tmp3 = load i16, ptr %tmp1, align 254; VF_8-NEXT: Found an estimated cost of 0 for VF 8 For instruction: store i16 %tmp2, ptr %tmp0, align 255; VF_8-NEXT: Found an estimated cost of 2 for VF 8 For instruction: store i16 %tmp3, ptr %tmp1, align 256; VF_16-LABEL: Checking a loop in 'i16_factor_2'57; VF_16: Found an estimated cost of 4 for VF 16 For instruction: %tmp2 = load i16, ptr %tmp0, align 258; VF_16-NEXT: Found an estimated cost of 0 for VF 16 For instruction: %tmp3 = load i16, ptr %tmp1, align 259; VF_16-NEXT: Found an estimated cost of 0 for VF 16 For instruction: store i16 %tmp2, ptr %tmp0, align 260; VF_16-NEXT: Found an estimated cost of 4 for VF 16 For instruction: store i16 %tmp3, ptr %tmp1, align 261for.body:62 %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]63 %tmp0 = getelementptr inbounds %i16.2, ptr %data, i64 %i, i32 064 %tmp1 = getelementptr inbounds %i16.2, ptr %data, i64 %i, i32 165 %tmp2 = load i16, ptr %tmp0, align 266 %tmp3 = load i16, ptr %tmp1, align 267 store i16 %tmp2, ptr %tmp0, align 268 store i16 %tmp3, ptr %tmp1, align 269 %i.next = add nuw nsw i64 %i, 170 %cond = icmp slt i64 %i.next, %n71 br i1 %cond, label %for.body, label %for.end72 73for.end:74 ret void75}76 77%i32.2 = type {i32, i32}78define void @i32_factor_2(ptr %data, i64 %n) {79entry:80 br label %for.body81 82; VF_2-LABEL: Checking a loop in 'i32_factor_2'83; VF_2: Found an estimated cost of 2 for VF 2 For instruction: %tmp2 = load i32, ptr %tmp0, align 484; VF_2-NEXT: Found an estimated cost of 0 for VF 2 For instruction: %tmp3 = load i32, ptr %tmp1, align 485; VF_2-NEXT: Found an estimated cost of 0 for VF 2 For instruction: store i32 %tmp2, ptr %tmp0, align 486; VF_2-NEXT: Found an estimated cost of 2 for VF 2 For instruction: store i32 %tmp3, ptr %tmp1, align 487; VF_4-LABEL: Checking a loop in 'i32_factor_2'88; VF_4: Found an estimated cost of 2 for VF 4 For instruction: %tmp2 = load i32, ptr %tmp0, align 489; VF_4-NEXT: Found an estimated cost of 0 for VF 4 For instruction: %tmp3 = load i32, ptr %tmp1, align 490; VF_4-NEXT: Found an estimated cost of 0 for VF 4 For instruction: store i32 %tmp2, ptr %tmp0, align 491; VF_4-NEXT: Found an estimated cost of 2 for VF 4 For instruction: store i32 %tmp3, ptr %tmp1, align 492; VF_8-LABEL: Checking a loop in 'i32_factor_2'93; VF_8: Found an estimated cost of 4 for VF 8 For instruction: %tmp2 = load i32, ptr %tmp0, align 494; VF_8-NEXT: Found an estimated cost of 0 for VF 8 For instruction: %tmp3 = load i32, ptr %tmp1, align 495; VF_8-NEXT: Found an estimated cost of 0 for VF 8 For instruction: store i32 %tmp2, ptr %tmp0, align 496; VF_8-NEXT: Found an estimated cost of 4 for VF 8 For instruction: store i32 %tmp3, ptr %tmp1, align 497; VF_16-LABEL: Checking a loop in 'i32_factor_2'98; VF_16: Found an estimated cost of 8 for VF 16 For instruction: %tmp2 = load i32, ptr %tmp0, align 499; VF_16-NEXT: Found an estimated cost of 0 for VF 16 For instruction: %tmp3 = load i32, ptr %tmp1, align 4100; VF_16-NEXT: Found an estimated cost of 0 for VF 16 For instruction: store i32 %tmp2, ptr %tmp0, align 4101; VF_16-NEXT: Found an estimated cost of 8 for VF 16 For instruction: store i32 %tmp3, ptr %tmp1, align 4102for.body:103 %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]104 %tmp0 = getelementptr inbounds %i32.2, ptr %data, i64 %i, i32 0105 %tmp1 = getelementptr inbounds %i32.2, ptr %data, i64 %i, i32 1106 %tmp2 = load i32, ptr %tmp0, align 4107 %tmp3 = load i32, ptr %tmp1, align 4108 store i32 %tmp2, ptr %tmp0, align 4109 store i32 %tmp3, ptr %tmp1, align 4110 %i.next = add nuw nsw i64 %i, 1111 %cond = icmp slt i64 %i.next, %n112 br i1 %cond, label %for.body, label %for.end113 114for.end:115 ret void116}117 118%i64.2 = type {i64, i64}119define void @i64_factor_2(ptr %data, i64 %n) {120entry:121 br label %for.body122 123; VF_2-LABEL: Checking a loop in 'i64_factor_2'124; VF_2: Found an estimated cost of 2 for VF 2 For instruction: %tmp2 = load i64, ptr %tmp0, align 8125; VF_2-NEXT: Found an estimated cost of 0 for VF 2 For instruction: %tmp3 = load i64, ptr %tmp1, align 8126; VF_2-NEXT: Found an estimated cost of 0 for VF 2 For instruction: store i64 %tmp2, ptr %tmp0, align 8127; VF_2-NEXT: Found an estimated cost of 2 for VF 2 For instruction: store i64 %tmp3, ptr %tmp1, align 8128; VF_4-LABEL: Checking a loop in 'i64_factor_2'129; VF_4: Found an estimated cost of 4 for VF 4 For instruction: %tmp2 = load i64, ptr %tmp0, align 8130; VF_4-NEXT: Found an estimated cost of 0 for VF 4 For instruction: %tmp3 = load i64, ptr %tmp1, align 8131; VF_4-NEXT: Found an estimated cost of 0 for VF 4 For instruction: store i64 %tmp2, ptr %tmp0, align 8132; VF_4-NEXT: Found an estimated cost of 4 for VF 4 For instruction: store i64 %tmp3, ptr %tmp1, align 8133; VF_8-LABEL: Checking a loop in 'i64_factor_2'134; VF_8: Found an estimated cost of 8 for VF 8 For instruction: %tmp2 = load i64, ptr %tmp0, align 8135; VF_8-NEXT: Found an estimated cost of 0 for VF 8 For instruction: %tmp3 = load i64, ptr %tmp1, align 8136; VF_8-NEXT: Found an estimated cost of 0 for VF 8 For instruction: store i64 %tmp2, ptr %tmp0, align 8137; VF_8-NEXT: Found an estimated cost of 8 for VF 8 For instruction: store i64 %tmp3, ptr %tmp1, align 8138; VF_16-LABEL: Checking a loop in 'i64_factor_2'139; VF_16: Found an estimated cost of 16 for VF 16 For instruction: %tmp2 = load i64, ptr %tmp0, align 8140; VF_16-NEXT: Found an estimated cost of 0 for VF 16 For instruction: %tmp3 = load i64, ptr %tmp1, align 8141; VF_16-NEXT: Found an estimated cost of 0 for VF 16 For instruction: store i64 %tmp2, ptr %tmp0, align 8142; VF_16-NEXT: Found an estimated cost of 16 for VF 16 For instruction: store i64 %tmp3, ptr %tmp1, align 8143for.body:144 %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]145 %tmp0 = getelementptr inbounds %i64.2, ptr %data, i64 %i, i32 0146 %tmp1 = getelementptr inbounds %i64.2, ptr %data, i64 %i, i32 1147 %tmp2 = load i64, ptr %tmp0, align 8148 %tmp3 = load i64, ptr %tmp1, align 8149 store i64 %tmp2, ptr %tmp0, align 8150 store i64 %tmp3, ptr %tmp1, align 8151 %i.next = add nuw nsw i64 %i, 1152 %cond = icmp slt i64 %i.next, %n153 br i1 %cond, label %for.body, label %for.end154 155for.end:156 ret void157}158 159%i64.8 = type {i64, i64, i64, i64, i64, i64, i64, i64}160define void @i64_factor_8(ptr %data, i64 %n) {161entry:162 br label %for.body163 164; The interleave factor in this test is 8, which is greater than the maximum165; allowed factor for AArch64 (4). Thus, we will fall back to the basic TTI166; implementation for determining the cost of the interleaved load group. The167; stores do not form a legal interleaved group because the group would contain168; gaps.169;170; VF_2-LABEL: Checking a loop in 'i64_factor_8'171; VF_2: Found an estimated cost of 8 for VF 2 For instruction: %tmp2 = load i64, ptr %tmp0, align 8172; VF_2-NEXT: Found an estimated cost of 8 for VF 2 For instruction: %tmp3 = load i64, ptr %tmp1, align 8173; VF_2-NEXT: Found an estimated cost of 8 for VF 2 For instruction: store i64 %tmp2, ptr %tmp0, align 8174; VF_2-NEXT: Found an estimated cost of 8 for VF 2 For instruction: store i64 %tmp3, ptr %tmp1, align 8175for.body:176 %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]177 %tmp0 = getelementptr inbounds %i64.8, ptr %data, i64 %i, i32 2178 %tmp1 = getelementptr inbounds %i64.8, ptr %data, i64 %i, i32 6179 %tmp2 = load i64, ptr %tmp0, align 8180 %tmp3 = load i64, ptr %tmp1, align 8181 store i64 %tmp2, ptr %tmp0, align 8182 store i64 %tmp3, ptr %tmp1, align 8183 %i.next = add nuw nsw i64 %i, 1184 %cond = icmp slt i64 %i.next, %n185 br i1 %cond, label %for.body, label %for.end186 187for.end:188 ret void189}190