1 ; RUN: opt -O2 -S %s | FileCheck %s
2 ; RUN: opt -passes='default<O2>' -S %s | FileCheck %s
4 target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-apple-macosx"
7 ; The loop below needs to be peeled first to eliminate the constant PHI %first
8 ; before loop vectorization.
10 ; Test case from PR47671.
12 define i32 @test(i32* readonly %p, i32* readnone %q) {
13 ; CHECK-LABEL: define i32 @test(
15 ; CHECK: %index.next = add nuw i64 %index, 8
16 ; CHECK: middle.block:
19 %cmp.not7 = icmp eq i32* %p, %q
20 br i1 %cmp.not7, label %exit, label %loop.ph
26 %sum = phi i32 [ %sum.next, %loop ], [ 0, %loop.ph ]
27 %first = phi i1 [ false, %loop ], [ true, %loop.ph ]
28 %iv = phi i32* [ %iv.next, %loop ], [ %p, %loop.ph ]
29 %add = add nsw i32 %sum, 2
30 %spec.select = select i1 %first, i32 %sum, i32 %add
31 %lv = load i32, i32* %iv, align 4
32 %sum.next = add nsw i32 %lv, %spec.select
33 %iv.next = getelementptr inbounds i32, i32* %iv, i64 1
34 %cmp.not = icmp eq i32* %iv.next, %q
35 br i1 %cmp.not, label %loopexit, label %loop
38 %sum.next.lcssa = phi i32 [ %sum.next, %loop ]
42 %sum.0.lcssa = phi i32 [ 0, %entry ], [ %sum.next.lcssa, %loopexit ]