143 lines · plain
1; RUN: opt -passes=loop-vectorize -force-vector-interleave=1 -force-vector-width=4 -S %s | FileCheck --check-prefix=VF4 %s2; RUN: opt -passes=loop-vectorize -force-vector-interleave=2 -force-vector-width=1 -S %s | FileCheck --check-prefix=IC2 %s3 4; rdar://problem/128481625 6target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"7 8@a = common global [2048 x i32] zeroinitializer, align 169 10define void @example12() {11; VF4-LABEL: @example12(12; VF4-LABEL: vector.body:13; VF4: [[VEC_IND:%.+]] = phi <4 x i32>14; VF4: store <4 x i32> [[VEC_IND]]15; VF4: middle.block:16;17; IC2-LABEL: @example12(18; IC2-LABEL: vector.body:19; IC2-NEXT: [[INDEX:%.+]] = phi i64 [ 0, %vector.ph ]20; IC2: [[TRUNC:%.+]] = trunc i64 [[INDEX]] to i3221; IC2-NEXT: [[TRUNC1:%.+]] = add i32 [[TRUNC]], 122; IC2: store i32 [[TRUNC]],23; IC2-NEXT: store i32 [[TRUNC1]],24;25entry:26 br label %loop27 28loop:29 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]30 %gep = getelementptr inbounds [2048 x i32], ptr @a, i64 0, i64 %iv31 %iv.trunc = trunc i64 %iv to i3232 store i32 %iv.trunc, ptr %gep, align 433 %iv.next = add i64 %iv, 134 %iv.next.trunc = trunc i64 %iv.next to i3235 %exitcond = icmp eq i32 %iv.next.trunc, 102436 br i1 %exitcond, label %exit, label %loop37 38exit:39 ret void40}41 42define void @redundant_iv_cast(ptr %dst) {43; VF4-LABEL: @redundant_iv_cast44; VF4: vector.body:45; VF4: [[VEC_IND:%.+]] = phi <4 x i16> [ <i16 0, i16 1, i16 2, i16 3>, %vector.ph ], [ [[VEC_IND_NEXT:%.+]], %vector.body ]46; VF4: store <4 x i16> [[VEC_IND]]47; VF4: [[VEC_IND_NEXT]] = add <4 x i16> [[VEC_IND]], splat (i16 4)48;49; IC2-LABEL: @redundant_iv_cast50; IC2: vector.body:51; IC2-NEXT: [[CAN_IV:%.+]] = phi i32 [ 0, %vector.ph ], [ [[CAN_IV_NEXT:%.+]], %vector.body ]52; IC2-NEXT: [[OFFSET_IDX:%.+]] = trunc i32 [[CAN_IV]] to i1653; IC2-NEXT: [[P1:%.+]] = add i16 [[OFFSET_IDX]], 154; IC2: store i16 [[OFFSET_IDX]]55; IC2-NEXT: store i16 [[P1]]56;57entry:58 br label %loop59 60loop:61 %j.0 = phi i16 [ 0, %entry ], [ %inc, %loop ]62 %ext = zext i16 %j.0 to i3263 %trunc = trunc i32 %ext to i1664 %gep = getelementptr inbounds i16, ptr %dst, i16 %j.065 store i16 %trunc, ptr %gep66 %0 = icmp eq i16 10000, %j.067 %inc = add i16 %j.0, 168 br i1 %0, label %exit, label %loop69 70 71exit:72 ret void73}74 75 76define void @cast_variable_step(i64 %step) {77; VF4-LABEL: @cast_variable_step(78; VF4-LABEL: vector.body:79; VF4: [[VEC_IND:%.+]] = phi <4 x i32>80; VF4: store <4 x i32> [[VEC_IND]]81; VF4: middle.block:82;83; IC2-LABEL: @cast_variable_step(84; IC2: [[TRUNC_STEP:%.+]] = trunc i64 %step to i3285; IC2: br label %vector.body86 87; IC2-LABEL: vector.body:88; IC2-NEXT: [[INDEX:%.+]] = phi i64 [ 0, %vector.ph ]89; IC2: [[MUL:%.+]] = mul i64 %index, %step90; IC2-NEXT: [[OFFSET_IDX:%.+]] = add i64 10, [[MUL]]91; IC2-NEXT: [[TRUNC_OFF:%.+]] = trunc i64 [[OFFSET_IDX]] to i3292; IC2-NEXT: [[STEP1:%.+]] = mul i32 1, [[TRUNC_STEP]]93; IC2-NEXT: [[T1:%.+]] = add i32 [[TRUNC_OFF]], [[STEP1]]94; IC2: store i32 [[TRUNC_OFF]],95; IC2-NEXT: store i32 [[T1]],96;97entry:98 br label %loop99 100loop:101 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]102 %iv.2 = phi i64 [ 10, %entry ], [ %iv.2.next, %loop ]103 %gep = getelementptr inbounds [2048 x i32], ptr @a, i64 0, i64 %iv104 %iv.2.trunc = trunc i64 %iv.2 to i32105 store i32 %iv.2.trunc, ptr %gep, align 4106 %iv.next = add i64 %iv, 1107 %iv.2.next = add i64 %iv.2, %step108 %exitcond = icmp eq i64 %iv.next, 1024109 br i1 %exitcond, label %exit, label %loop110 111exit:112 ret void113}114 115define void @cast_induction_tail_folding(ptr %A) {116; VF4-LABEL: @cast_induction_tail_folding(117; VF4-LABEL: vector.body:118; VF4-NEXT: br i1 true, label %pred.store.if, label %pred.store.continue119 120; IC2-LABEL: @cast_induction_tail_folding(121; IC2: [[INDEX:%.+]] = phi i32 [ 0, %vector.ph ]122; IC2-NEXT: [[INDEX0:%.+]] = add i32 [[INDEX]], 0123; IC2-NEXT: [[INDEX1:%.+]] = add i32 [[INDEX]], 1124; IC2-NEXT: = icmp ule i32 [[INDEX0]], 2125; IC2-NEXT: = icmp ule i32 [[INDEX1]], 2126;127entry:128 br label %loop129 130loop:131 %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]132 %iv.ext = sext i32 %iv to i64133 %iv.trunc = trunc i64 %iv.ext to i32134 %gep = getelementptr inbounds i32, ptr %A, i64 %iv.ext135 store i32 %iv.trunc, ptr %gep136 %iv.next = add i32 %iv, 1137 %c = icmp slt i32 %iv.next, 3138 br i1 %c, label %loop, label %exit139 140exit:141 ret void142}143