1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

[PhaseOrdering] Add test that requires peeling before vectorization.

Test case for PR47671.
This commit is contained in:
Florian Hahn 2020-09-29 09:46:57 +01:00
parent 0f296dd7a4
commit a4d04e324c

View File

@ -0,0 +1,42 @@
; RUN: opt -O2 -S %s | FileCheck %s
; RUN: opt -passes='default<O2>' -S %s | FileCheck %s
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx"
; The loop below needs to be peeled first to eliminate the constant PHI %first
; before loop vectorization.
;
; Test case from PR47671.
define i32 @test(i32* readonly %p, i32* readnone %q) {
; CHECK-LABEL: define i32 @test(
; CHECK-NOT: vector.body
;
entry:
%cmp.not7 = icmp eq i32* %p, %q
br i1 %cmp.not7, label %exit, label %loop.ph
loop.ph:
br label %loop
loop:
%sum = phi i32 [ %sum.next, %loop ], [ 0, %loop.ph ]
%first = phi i1 [ false, %loop ], [ true, %loop.ph ]
%iv = phi i32* [ %iv.next, %loop ], [ %p, %loop.ph ]
%add = add nsw i32 %sum, 2
%spec.select = select i1 %first, i32 %sum, i32 %add
%lv = load i32, i32* %iv, align 4
%sum.next = add nsw i32 %lv, %spec.select
%iv.next = getelementptr inbounds i32, i32* %iv, i64 1
%cmp.not = icmp eq i32* %iv.next, %q
br i1 %cmp.not, label %loopexit, label %loop
loopexit:
%sum.next.lcssa = phi i32 [ %sum.next, %loop ]
br label %exit
exit:
%sum.0.lcssa = phi i32 [ 0, %entry ], [ %sum.next.lcssa, %loopexit ]
ret i32 %sum.0.lcssa
}