Max Kazantsev | f766748 | 2018-02-05 08:09:49 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -loop-vectorize -S | FileCheck %s |
| 2 | |
| 3 | target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-ni:1" |
| 4 | target triple = "x86_64-unknown-linux-gnu" |
| 5 | |
| 6 | ; This cannot be correctly vectorized with type i1. |
| 7 | define i8 @test_01(i8 %c) #0 { |
| 8 | |
| 9 | ; CHECK-LABEL: @test_01( |
| 10 | ; CHECK-NOT: vector.body: |
| 11 | ; CHECK-NOT: zext i1 {{.*}} to i8 |
| 12 | |
| 13 | entry: |
| 14 | br label %loop |
| 15 | |
| 16 | exit: ; preds = %loop |
| 17 | ret i8 %accum.plus |
| 18 | |
| 19 | loop: ; preds = %loop, %entry |
| 20 | %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, 1 |
| 23 | %accum.plus = add nuw nsw i8 %accum.and, 3 |
| 24 | %iv.next = add nuw nsw i32 %iv, 1 |
| 25 | %cond = icmp ugt i32 %iv, 191 |
| 26 | br i1 %cond, label %exit, label %loop |
| 27 | } |
| 28 | |
| 29 | ; TODO: This can be vectorized with type i1 because the result is not used. |
| 30 | define void @test_02(i8 %c) #0 { |
| 31 | |
| 32 | ; CHECK-LABEL: @test_02( |
| 33 | ; CHECK-NOT: vector.body: |
| 34 | |
| 35 | entry: |
| 36 | br label %loop |
| 37 | |
| 38 | exit: ; preds = %loop |
| 39 | %lcssa = phi i8 [ %accum.plus, %loop ] |
| 40 | ret void |
| 41 | |
| 42 | loop: ; preds = %loop, %entry |
| 43 | %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, 1 |
| 46 | %accum.plus = add nuw nsw i8 %accum.and, 3 |
| 47 | %iv.next = add nuw nsw i32 %iv, 1 |
| 48 | %cond = icmp ugt i32 %iv, 191 |
| 49 | br i1 %cond, label %exit, label %loop |
| 50 | } |
| 51 | |
| 52 | ; This can be vectorized with type i1 because the result is truncated properly. |
| 53 | define i1 @test_03(i8 %c) #0 { |
| 54 | |
| 55 | ; CHECK-LABEL: @test_03( |
| 56 | ; CHECK: vector.body: |
| 57 | ; CHECK: zext i1 {{.*}} to i8 |
| 58 | |
| 59 | entry: |
| 60 | br label %loop |
| 61 | |
| 62 | exit: ; preds = %loop |
| 63 | %lcssa = phi i8 [ %accum.plus, %loop ] |
| 64 | %trunc = trunc i8 %lcssa to i1 |
| 65 | ret i1 %trunc |
| 66 | |
| 67 | loop: ; preds = %loop, %entry |
| 68 | %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, 1 |
| 71 | %accum.plus = add nuw nsw i8 %accum.and, 3 |
| 72 | %iv.next = add nuw nsw i32 %iv, 1 |
| 73 | %cond = icmp ugt i32 %iv, 191 |
| 74 | br i1 %cond, label %exit, label %loop |
| 75 | } |
| 76 | |
| 77 | ; This cannot be vectorized with type i1 because the result is truncated to a |
| 78 | ; wrong type. |
| 79 | ; TODO: It can also be vectorized with type i32 (or maybe i4?) |
| 80 | define i4 @test_04(i8 %c) #0 { |
| 81 | |
| 82 | ; CHECK-LABEL: @test_04( |
| 83 | ; CHECK-NOT: vector.body: |
| 84 | ; CHECK-NOT: zext i1 {{.*}} to i8 |
| 85 | |
| 86 | entry: |
| 87 | br label %loop |
| 88 | |
| 89 | exit: ; preds = %loop |
| 90 | %lcssa = phi i8 [ %accum.plus, %loop ] |
| 91 | %trunc = trunc i8 %lcssa to i4 |
| 92 | ret i4 %trunc |
| 93 | |
| 94 | loop: ; preds = %loop, %entry |
| 95 | %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, 1 |
| 98 | %accum.plus = add nuw nsw i8 %accum.and, 3 |
| 99 | %iv.next = add nuw nsw i32 %iv, 1 |
| 100 | %cond = icmp ugt i32 %iv, 191 |
| 101 | br i1 %cond, label %exit, label %loop |
| 102 | } |