103 lines · plain
1; RUN: opt < %s -passes=loop-vectorize -S | FileCheck %s2 3target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-ni:1"4target triple = "x86_64-unknown-linux-gnu"5 6; This cannot be correctly vectorized with type i1.7define i8 @test_01(i8 %c) #0 {8 9; CHECK-LABEL: @test_01(10; CHECK-NOT: vector.body:11; CHECK-NOT: zext i1 {{.*}} to i812 13entry:14 br label %loop15 16exit: ; preds = %loop17 ret i8 %accum.plus18 19loop: ; preds = %loop, %entry20 %accum.phi = phi i8 [ %c, %entry ], [ %accum.plus, %loop ]21 %iv = phi i32 [ 1, %entry ], [ %iv.next, %loop ]22 %accum.and = and i8 %accum.phi, 123 %accum.plus = add nuw nsw i8 %accum.and, 324 %iv.next = add nuw nsw i32 %iv, 125 %cond = icmp ugt i32 %iv, 19126 br i1 %cond, label %exit, label %loop27}28 29; TODO: This can be vectorized with type i1 because the result is not used.30define void @test_02(i8 %c) #0 {31 32; CHECK-LABEL: @test_02(33; CHECK-NOT: vector.body:34 35entry:36 br label %loop37 38exit: ; preds = %loop39 %lcssa = phi i8 [ %accum.plus, %loop ]40 ret void41 42loop: ; preds = %loop, %entry43 %accum.phi = phi i8 [ %c, %entry ], [ %accum.plus, %loop ]44 %iv = phi i32 [ 1, %entry ], [ %iv.next, %loop ]45 %accum.and = and i8 %accum.phi, 146 %accum.plus = add nuw nsw i8 %accum.and, 347 %iv.next = add nuw nsw i32 %iv, 148 %cond = icmp ugt i32 %iv, 19149 br i1 %cond, label %exit, label %loop50}51 52; This can be vectorized with type i1 because the result is truncated properly.53define i1 @test_03(i8 %c) #0 {54 55; CHECK-LABEL: @test_03(56; CHECK: vector.body:57; CHECK: zext i1 {{.*}} to i858 59entry:60 br label %loop61 62exit: ; preds = %loop63 %lcssa = phi i8 [ %accum.plus, %loop ]64 %trunc = trunc i8 %lcssa to i165 ret i1 %trunc66 67loop: ; preds = %loop, %entry68 %accum.phi = phi i8 [ %c, %entry ], [ %accum.plus, %loop ]69 %iv = phi i32 [ 1, %entry ], [ %iv.next, %loop ]70 %accum.and = and i8 %accum.phi, 171 %accum.plus = add nuw nsw i8 %accum.and, 372 %iv.next = add nuw nsw i32 %iv, 173 %cond = icmp ugt i32 %iv, 19174 br i1 %cond, label %exit, label %loop75}76 77; This cannot be vectorized with type i1 because the result is truncated to a78; wrong type.79; TODO: It can also be vectorized with type i32 (or maybe i4?)80define i4 @test_04(i8 %c) #0 {81 82; CHECK-LABEL: @test_04(83; CHECK-NOT: vector.body:84; CHECK-NOT: zext i1 {{.*}} to i885 86entry:87 br label %loop88 89exit: ; preds = %loop90 %lcssa = phi i8 [ %accum.plus, %loop ]91 %trunc = trunc i8 %lcssa to i492 ret i4 %trunc93 94loop: ; preds = %loop, %entry95 %accum.phi = phi i8 [ %c, %entry ], [ %accum.plus, %loop ]96 %iv = phi i32 [ 1, %entry ], [ %iv.next, %loop ]97 %accum.and = and i8 %accum.phi, 198 %accum.plus = add nuw nsw i8 %accum.and, 399 %iv.next = add nuw nsw i32 %iv, 1100 %cond = icmp ugt i32 %iv, 191101 br i1 %cond, label %exit, label %loop102}103