1 ; RUN: opt < %s -force-vector-width=2 -force-vector-interleave=2 -loop-vectorize -S | FileCheck %s
3 target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
5 ; CHECK-LABEL: @dead_instructions_01
7 ; This test ensures that we don't generate trivially dead instructions prior to
8 ; instruction simplification. We don't need to generate instructions
9 ; corresponding to the original induction variable update or branch condition,
10 ; since we rewrite the loop structure.
13 ; CHECK: %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
14 ; CHECK: %[[I0:.+]] = add i64 %index, 0
15 ; CHECK: %[[I2:.+]] = add i64 %index, 2
16 ; CHECK: getelementptr inbounds i64, i64* %a, i64 %[[I0]]
17 ; CHECK: getelementptr inbounds i64, i64* %a, i64 %[[I2]]
18 ; CHECK-NOT: add nuw nsw i64 %[[I0]], 1
19 ; CHECK-NOT: add nuw nsw i64 %[[I2]], 1
20 ; CHECK-NOT: icmp slt i64 {{.*}}, %n
21 ; CHECK: %index.next = add i64 %index, 4
22 ; CHECK: %[[CMP:.+]] = icmp eq i64 %index.next, %n.vec
23 ; CHECK: br i1 %[[CMP]], label %middle.block, label %vector.body
25 define i64 @dead_instructions_01(i64 *%a, i64 %n) {
30 %i = phi i64 [ %i.next, %for.body ], [ 0, %entry ]
31 %r = phi i64 [ %tmp2, %for.body ], [ 0, %entry ]
32 %tmp0 = getelementptr inbounds i64, i64* %a, i64 %i
33 %tmp1 = load i64, i64* %tmp0, align 8
34 %tmp2 = add i64 %tmp1, %r
35 %i.next = add nuw nsw i64 %i, 1
36 %cond = icmp slt i64 %i.next, %n
37 br i1 %cond, label %for.body, label %for.end
40 %tmp3 = phi i64 [ %tmp2, %for.body ]