1 ; RUN: opt < %s -loop-vectorize -S | FileCheck %s
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"
6 ; This cannot be correctly vectorized with type i1.
7 define i8 @test_01(i8 %c) #0 {
9 ; CHECK-LABEL: @test_01(
10 ; CHECK-NOT: vector.body:
11 ; CHECK-NOT: zext i1 {{.*}} to i8
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
29 ; TODO: This can be vectorized with type i1 because the result is not used.
30 define void @test_02(i8 %c) #0 {
32 ; CHECK-LABEL: @test_02(
33 ; CHECK-NOT: vector.body:
39 %lcssa = phi i8 [ %accum.plus, %loop ]
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
52 ; This can be vectorized with type i1 because the result is truncated properly.
53 define i1 @test_03(i8 %c) #0 {
55 ; CHECK-LABEL: @test_03(
57 ; CHECK: zext i1 {{.*}} to i8
63 %lcssa = phi i8 [ %accum.plus, %loop ]
64 %trunc = trunc i8 %lcssa to i1
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
77 ; This cannot be vectorized with type i1 because the result is truncated to a
79 ; TODO: It can also be vectorized with type i32 (or maybe i4?)
80 define i4 @test_04(i8 %c) #0 {
82 ; CHECK-LABEL: @test_04(
83 ; CHECK-NOT: vector.body:
84 ; CHECK-NOT: zext i1 {{.*}} to i8
90 %lcssa = phi i8 [ %accum.plus, %loop ]
91 %trunc = trunc i8 %lcssa to i4
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