45 lines · plain
1; RUN: opt -O2 -S %s | FileCheck %s2; RUN: opt -passes="default<O2>" -S %s | FileCheck %s3 4target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"5target triple = "x86_64-apple-macosx"6 7; The loop below needs to be peeled first to eliminate the constant PHI %first8; before loop vectorization.9;10; Test case from PR47671.11 12define i32 @test(ptr readonly %p, ptr readnone %q) {13; CHECK-LABEL: define i32 @test(14; CHECK: vector.body:15; CHECK: %index.next = add nuw i64 %index, 816; CHECK: middle.block:17;18entry:19 %cmp.not7 = icmp eq ptr %p, %q20 br i1 %cmp.not7, label %exit, label %loop.ph21 22loop.ph:23 br label %loop24 25loop:26 %sum = phi i32 [ %sum.next, %loop ], [ 0, %loop.ph ]27 %first = phi i1 [ false, %loop ], [ true, %loop.ph ]28 %iv = phi ptr [ %iv.next, %loop ], [ %p, %loop.ph ]29 %add = add nsw i32 %sum, 230 %spec.select = select i1 %first, i32 %sum, i32 %add31 %lv = load i32, ptr %iv, align 432 %sum.next = add nsw i32 %lv, %spec.select33 %iv.next = getelementptr inbounds i32, ptr %iv, i64 134 %cmp.not = icmp eq ptr %iv.next, %q35 br i1 %cmp.not, label %loopexit, label %loop36 37loopexit:38 %sum.next.lcssa = phi i32 [ %sum.next, %loop ]39 br label %exit40 41exit:42 %sum.0.lcssa = phi i32 [ 0, %entry ], [ %sum.next.lcssa, %loopexit ]43 ret i32 %sum.0.lcssa44}45